16 #include "libmesh/mesh_modification.h" 17 #include "libmesh/mesh_serializer.h" 18 #include "libmesh/unstructured_mesh.h" 28 "input",
"The input mesh based on which to create the conformal boundary layer.");
30 "The total thickness of the boundary layer to be created.");
32 "num_layers", 1,
"num_layers>0",
"The total number of boundary layers to be created.");
36 "The bias factor for the thickness of each layer of elements. A value > 1 leads to thicker " 37 "layers away from the input mesh, while a value < 1 leads to thicker layers close to the " 38 "input mesh. The default value of 1 leads to uniform layer thickness.");
40 MooseEnum boundary_layer_direction(
"OUTWARD INWARD",
"OUTWARD");
42 "boundary_layer_direction",
43 boundary_layer_direction,
44 "In which direction the boundary layer is created with respect to the side normal of the " 45 "elements along the boundary of the input mesh.");
47 params.
addParam<std::vector<BoundaryName>>(
49 std::vector<BoundaryName>(),
50 "The names of the boundaries around which the boundary layer will be created.");
52 params.
addParam<BoundaryName>(
"interface_name",
53 "The optional boundary name to be assigned to the interface " 54 "between the generated boundary layer and the input mesh.");
57 "The optional boundary name to be assigned to the surface of the generated boundary layer.");
59 params.
addParam<SubdomainName>(
"subdomain_name",
60 "Subdomain name to set for the boundary layer mesh.");
61 params.
addParam<
SubdomainID>(
"subdomain_id",
"Subdomain id to set for the boundary layer mesh.");
63 MooseEnum tri_elem_type(
"TRI3 TRI6 TRI7",
"TRI3");
66 "The type of triangular elements to use for the boundary layer.");
70 "Whether to keep the input mesh in the final output. If false, only the " 71 "boundary layers will be included in the output mesh.");
74 "Generate a 2D layered mesh that represents a conformal boundary layer along " 75 "the boundary of an input 2D mesh or a 1D loop mesh.");
83 _input(getMesh(
"input")),
84 _thickness(getParam<
Real>(
"thickness")),
85 _num_layers(getParam<unsigned
int>(
"num_layers")),
86 _layer_bias(getParam<
Real>(
"layer_bias")),
87 _boundary_layer_direction(
89 _boundary_names(getParam<
std::vector<BoundaryName>>(
"boundary_names")),
90 _interface_name(isParamValid(
"interface_name") ? getParam<BoundaryName>(
"interface_name")
92 _surface_name(isParamValid(
"surface_name") ? getParam<BoundaryName>(
"surface_name")
94 _subdomain_name(isParamValid(
"subdomain_name") ? getParam<SubdomainName>(
"subdomain_name")
96 _output_subdomain_id(isParamValid(
"subdomain_id") ? getParam<
SubdomainID>(
"subdomain_id") : 0),
97 _tri_elem_type(parameters.
get<
MooseEnum>(
"tri_elem_type")),
98 _keep_input(getParam<bool>(
"keep_input"))
102 std::unique_ptr<MeshBase>
110 std::unique_ptr<MeshBase> input_mesh = std::move(
_input);
129 const boundary_id_type interface_bid = outward ? ring_innermost : ring_outermost;
130 const boundary_id_type surface_bid = outward ? ring_outermost : ring_innermost;
136 if (!ring_u.is_prepared())
138 if (!inp_u.is_prepared())
139 inp_u.prepare_for_use();
141 const auto ring_bids = ring_u.get_boundary_info().get_global_boundary_ids();
142 const auto inp_bids = inp_u.get_boundary_info().get_global_boundary_ids();
146 bool overlap =
false;
147 for (
auto b : inp_bids)
148 if (ring_bids.count(b))
153 for (
auto b : inp_bids)
154 inp_u.get_boundary_info().renumber_id(b, max_bid + (
idx++));
155 ext_id = max_bid +
idx;
158 ext_id = max_bid + 1;
159 inp_u.comm().max(ext_id);
160 bool has_ext =
false;
162 mooseAssert(has_ext,
"A 2D-XY mesh should have an external boundary.");
166 ring_u.stitch_meshes(inp_u,
178 auto & bi = ring->get_boundary_info();
181 bi.remove_id(interface_bid);
183 bi.remove_id(surface_bid);
187 bool has_conflict =
false;
190 const auto interface_user_bcid =
192 if (interface_user_bcid == surface_bid && !
_surface_name.empty())
202 const auto surface_user_bcid =
205 *ring, has_conflict ?
boundary_id_type(10001) : surface_bid, surface_user_bcid);
213 ring->unset_is_prepared();
static InputParameters validParams()
const std::vector< BoundaryName > _boundary_names
Optional subset of boundary names on the input mesh that define the seed boundary.
const Real _layer_bias
Bias factor for the thickness of each layer.
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
registerMooseObject("MooseApp", XYTriangleBoundaryLayerGenerator)
const BoundaryName _interface_name
Optional boundary name for the interface between the generated boundary layer and the input mesh...
const unsigned int _num_layers
Number of element layers in the boundary layer.
auto max(const L &left, const R &right)
void allowRemoteElementRemoval(bool allow_removal)
Set whether to allow remote element removal.
MooseMesh *const _mesh
Pointer to the owning mesh.
enum XYTriangleBoundaryLayerGenerator::BoundaryLayerDirection _boundary_layer_direction
const Real _thickness
The total thickness of the boundary layer to be created.
const MooseEnum _tri_elem_type
Triangular element type for the boundary layer.
BoundaryLayerDirection
Whether the boundary layer is grown outward or inward with respect to the input boundary.
boundary_id_type BoundaryID
const bool _keep_input
Whether to keep the input mesh in the final output (stitched to the boundary layer) ...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.
static InputParameters validParams()
std::unique_ptr< MeshBase > & _input
Input mesh defining the boundary on which to grow the boundary layer.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const SubdomainName _subdomain_name
Optional subdomain name for the generated boundary layer.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const BoundaryName _surface_name
Optional boundary name for the outer surface of the generated boundary layer.
const SubdomainID _output_subdomain_id
Optional subdomain id for the generated boundary layer.
Generate a 2D layered mesh that represents a conformal boundary layer along the boundary of an input ...
XYTriangleBoundaryLayerGenerator(const InputParameters ¶meters)
std::unique_ptr< MeshBase > buildBoundaryLayerRing(MeshGenerator &mg, MeshBase &input_mesh, const std::vector< BoundaryName > &boundary_names, unsigned int num_layers, Real thickness, Real layer_bias, bool outward, const MooseEnum &tri_elem_type, SubdomainID output_subdomain_id, const SubdomainName &output_subdomain_name)
Builds a conformal boundary-layer ring of triangulated annuli along a boundary of an input 2D mesh (o...
MeshGenerators are objects that can modify or add to an existing mesh.
void ErrorVector unsigned int
const Elem & get(const ElemType type_in)
void addExternalBoundary(MeshBase &mesh, const BoundaryID extern_bid, bool &has_external_bid)
Adds a sideset for the external boundary of the mesh (e.g.