Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
GridUniformChannelWithMeshedSquarePrism< dim, spacedim > Class Template Reference

#include <grid_uniform_channel_with_meshed_square_prism.h>

Public Member Functions

 GridUniformChannelWithMeshedSquarePrism (const std::string &grid_arguments)
void make_grid (Triangulation< dim, spacedim > &triangulation)
void make_grid (Triangulation< 2, 2 > &triangulation)
void make_grid (Triangulation< 3, 3 > &triangulation)

Private Member Functions

void generate_2d_channel_mesh (Triangulation< 2 > &triangulation, const Point< 2 > &bottom_left, const Point< 2 > &top_right, const Point< 2 > &center, const double inner_half_side, const double outer_half_side, const double inner_rotation_angle, const unsigned int pad_bottom, const unsigned int pad_top, const unsigned int pad_left, const unsigned int pad_right, const bool colorize)

Private Attributes

Point< dim > bottom_left
Point< dim > top_right
Point< dim > center
double inner_half_side
double outer_half_side
double inner_rotation_angle
unsigned int pad_bottom
unsigned int pad_top
unsigned int pad_left
unsigned int pad_right
double height
unsigned int n_slices
bool mesh_obstacle
bool colorize

Detailed Description

template<int dim, int spacedim>
class GridUniformChannelWithMeshedSquarePrism< dim, spacedim >

Generates a rectangular channel mesh with a meshed square obstacle in 2D (extruded to a square prism in 3D). By default, this geometry defines two material IDs. The obstacle is assigned the material_id = 1 and the remaining domain is assigned material_id = 0.

The mesh consists of three nested regions around the obstacle center:

  • An inner square of half-side inner_half_side (material_id = 1).
  • A transition ring between inner_half_side and outer_half_side.
  • Rectangular padding regions that fill the gap between the transition square and the channel boundary defined by bottom_left / top_right.

The number of subdivisions in each padding direction (bottom, top, left, right) can be controlled independently. In 3D, the 2D cross-section is extruded along the z-axis with a configurable height and number of slices. The slices refer to the number of layers in the z direction, so the total number of cells in the z direction will be n_slices - 1. It follows that the minimum number of slices is 2, which corresponds to a single layer of cells in the z direction. Note that it is always assumed that the channel bottom is at z=0 and the channel top is at z=height.

Definition at line 40 of file grid_uniform_channel_with_meshed_square_prism.h.

Constructor & Destructor Documentation

◆ GridUniformChannelWithMeshedSquarePrism()

template<int dim, int spacedim>
GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::GridUniformChannelWithMeshedSquarePrism ( const std::string & grid_arguments)

Constructor that parses geometry parameters from a colon-separated string.

Parameters
[in]grid_argumentsA colon-separated string with the following fields (coordinates are comma-separated):
# Field Format Required Description
0 bottom_left x,y yes Bottom-left corner of the channel before extrusion
1 top_right x,y yes Top-right corner of the channel before extrusion
2 center x,y yes Center of the square obstacle
3 inner_half_side double yes Half-side of the inner square obstacle
4 outer_half_side double yes Half-side of the outer transition square
5 rotation_deg double no In-plane rotation (degrees) applied to the inner region (default: 0)
6 pad_bottom int no N cells below the transition (default: 0)
7 pad_top int no N cells above the transition (default: 0)
8 pad_left int no N cells left of the transition (default: 0)
9 pad_right int no N cells right of the transition (default: 0)
10 height double no Extrusion height in z, 3D only (default: 1.0)
11 n_slices int no Number of z-layers, 3D only (default and min: 2)
12 mesh_obstacle true/false no Whether to mesh the inner square obstacle (default: false)
13 colorize true/false no Assign distinct boundary IDs (default: false)

Example:

"0,0 : 10,2 : 5,1 : 0.1 : 0.3 : 15 : 2 : 2 : 5 : 5 : 2. : 2
: false: true "

When colorize is true, boundary IDs follow the subdivided_hyper_rectangle convention: 0 (-x), 1 (+x), 2 (-y), 3 (+y). In 3D, the extruded bottom (z=0) gets id 4 and top (z=height) gets id 5.

Definition at line 19 of file grid_uniform_channel_with_meshed_square_prism.cc.

References bottom_left, center, colorize, height, inner_half_side, inner_rotation_angle, mesh_obstacle, n_slices, outer_half_side, pad_bottom, pad_left, pad_right, pad_top, top_right, and value_string_to_tensor().

Member Function Documentation

◆ generate_2d_channel_mesh()

template<int dim, int spacedim>
void GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::generate_2d_channel_mesh ( Triangulation< 2 > & triangulation,
const Point< 2 > & bottom_left,
const Point< 2 > & top_right,
const Point< 2 > & center,
const double inner_half_side,
const double outer_half_side,
const double inner_rotation_angle,
const unsigned int pad_bottom,
const unsigned int pad_top,
const unsigned int pad_left,
const unsigned int pad_right,
const bool colorize )
private

Generate the 2D channel mesh geometry with a meshed square obstacle.

This private helper creates the composite 2D triangulation by merging:

  • A modified hyper_ball_balanced from deal.ii so the inner vertex are placed to form the inner square of half-side inner_half_side and the outer vertices are placed to form the outer square of half-side outer_half_side. When rotated, the inner vertices are rotated by inner_rotation_angle while only half of the outer vertices are rotated and projected to the closest point on the outer square. The other half are attached to the outer square corners. The choice of which outer vertices are rotated and which are attached to the corners is made on a closest-angle basis to minimize the distortion of the transition cells.
  • Up to 8 rectangular padding sub-meshes filling the gap between the transition square and the channel boundary. Those are set up in a way that their vertices line up with the vertices projected from the transition region to avoid the need of introducing new vertices when merging the triangulations.

Material IDs are assigned as follows: 1 for the inner obstacle and 0 for the rest of the channel.

If colorize is true, boundary IDs are set following the subdivided_hyper_rectangle convention: 0 (-x), 1 (+x), 2 (-y), 3 (+y).

Parameters
[out]triangulationThe triangulation to fill.
[in]bottom_leftBottom-left corner of the channel.
[in]top_rightTop-right corner of the channel.
[in]centerCenter of the square obstacle.
[in]inner_half_sideHalf-side of the inner square obstacle.
[in]outer_half_sideHalf-side of the outer transition square.
[in]inner_rotation_angleIn-plane rotation angle in degrees.
[in]pad_bottomNumber of subdivisions in the bottom padding.
[in]pad_topNumber of subdivisions in the top padding.
[in]pad_leftNumber of subdivisions in the left padding.
[in]pad_rightNumber of subdivisions in the right padding.
[in]mesh_obstacleWhether to mesh the inner square obstacle or leave it as a hole.
[in]colorizeWhether to assign distinct boundary IDs.

Definition at line 175 of file grid_uniform_channel_with_meshed_square_prism.cc.

References bottom_left, center, colorize, inner_half_side, inner_rotation_angle, mesh_obstacle, outer_half_side, pad_bottom, pad_left, pad_right, pad_top, and top_right.

◆ make_grid() [1/3]

◆ make_grid() [2/3]

◆ make_grid() [3/3]

template<int dim, int spacedim>
void GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::make_grid ( Triangulation< dim, spacedim > & triangulation)

Generate the 2D/3D channel mesh with a meshed square obstacle.

For 2D: Delegates geometry construction to generate_2d_channel_mesh(). The boundary IDs are assigned following the subdivided_hyper_rectangle convention when colorize is enabled: 0 (-x), 1 (+x), 2 (-y), 3 (+y).

For 3D: Delegates geometry construction to generate_2d_channel_mesh(), then extrudes the mesh along the z-axis and attaches the new boundary IDs. The lateral boundary IDs are inherited from the 2D mesh when colorize is enabled. The extruded bottom (z = 0) gets boundary_id = 4 and the top (z = height) gets boundary_id = 5.

Parameters
[out]triangulationThe triangulation to fill with the channel mesh.

Definition at line 672 of file grid_uniform_channel_with_meshed_square_prism.cc.

Member Data Documentation

◆ bottom_left

template<int dim, int spacedim>
Point<dim> GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::bottom_left
private

Point that define the bottom-left of the channel in the xy-plane.

Definition at line 149 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ center

template<int dim, int spacedim>
Point<dim> GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::center
private

Point that define the center of the obstacle in the xy-plane.

Definition at line 153 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ colorize

template<int dim, int spacedim>
bool GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::colorize
private

Whether to assign distinct boundary IDs to the channel boundaries following the subdivided_hyper_rectangle convention.

Definition at line 185 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ height

template<int dim, int spacedim>
double GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::height
private

Extrusion height in the z direction, 3D only.

Definition at line 177 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ inner_half_side

template<int dim, int spacedim>
double GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::inner_half_side
private

Half-side of the inner square obstacle.

Definition at line 155 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ inner_rotation_angle

template<int dim, int spacedim>
double GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::inner_rotation_angle
private

In-plane rotation angle in radians applied to the inner mesh pattern.

Definition at line 159 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ mesh_obstacle

template<int dim, int spacedim>
bool GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::mesh_obstacle
private

Whether to mesh the inner square obstacle or leave it as a hole.

Definition at line 182 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ n_slices

template<int dim, int spacedim>
unsigned int GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::n_slices
private

Number of layers in the z direction, 3D only. Minimum is 2, which corresponds to a single layer of cells in the z direction.

Definition at line 180 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ outer_half_side

template<int dim, int spacedim>
double GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::outer_half_side
private

Half-side of the outer transition square.

Definition at line 157 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ pad_bottom

template<int dim, int spacedim>
unsigned int GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::pad_bottom
private

Number of additional cells to be added to pad the channel from center - inner_half_side - outer_half_side to the channel bottom boundary (-y direction).

Definition at line 163 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ pad_left

template<int dim, int spacedim>
unsigned int GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::pad_left
private

Number of additional cells to be added to pad the channel from center - inner_half_side - outer_half_side to the channel left boundary (-x direction).

Definition at line 171 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ pad_right

template<int dim, int spacedim>
unsigned int GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::pad_right
private

Number of additional cells to be added to pad the channel from center + inner_half_side + outer_half_side to the channel right boundary (+x direction).

Definition at line 175 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ pad_top

template<int dim, int spacedim>
unsigned int GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::pad_top
private

Number of additional cells to be added to pad the channel from center + inner_half_side + outer_half_side to the channel top boundary (+y direction).

Definition at line 167 of file grid_uniform_channel_with_meshed_square_prism.h.

◆ top_right

template<int dim, int spacedim>
Point<dim> GridUniformChannelWithMeshedSquarePrism< dim, spacedim >::top_right
private

Point that define the top-right of the channel in the xy-plane.

Definition at line 151 of file grid_uniform_channel_with_meshed_square_prism.h.


The documentation for this class was generated from the following files: