15 #include "libmesh/node.h" 16 #include "libmesh/mesh_serializer.h" 25 "The input mesh that contains boundary_1");
27 "The input mesh that contains boundary_2");
29 "boundary_1",
"the first boundary that needs to be connected.");
31 "boundary_2",
"the second boundary that needs to be connected.");
33 "mesh_1_shift", Point(0.0, 0.0, 0.0),
"Translation vector to be applied to input_mesh_1");
35 "mesh_2_shift", Point(0.0, 0.0, 0.0),
"Translation vector to be applied to input_mesh_2");
37 "num_layers",
"num_layers>0",
"Number of layers of elements created between the boundaries.");
40 "input_boundary_1_id",
42 "Boundary ID to be assigned to the boundary defined by positions_vector_1.");
44 "input_boundary_2_id",
46 "Boundary ID to be assigned to the boundary defined by positions_vector_2.");
49 "Boundary ID to be assigned to the boundary connecting " 50 "starting points of the positions_vectors.");
53 "Boundary ID to be assigned to the boundary connecting ending " 54 "points of the positions_vectors.");
58 "Whether QUAD4 instead of TRI3 elements are used to construct the transition layer.");
63 "Parameter used to set up biasing of the layers: bias_parameter > 0.0 is used as the biasing " 64 "factor; bias_parameter = 0.0 activates automatic biasing based on local node density on " 65 "both input boundaries.");
70 "Gaussian parameter used to smoothen local node density for automatic biasing; this " 71 "parameter is not used if another biasing option is selected.");
75 "Whether to output the input meshes stitched with the transition layer connector.");
76 params.
addClassDescription(
"This FillBetweenSidesetsGenerator object is designed to generate a " 77 "transition layer to connect two boundaries of two input meshes.");
83 _input_name_1(getParam<MeshGeneratorName>(
"input_mesh_1")),
84 _input_name_2(getParam<MeshGeneratorName>(
"input_mesh_2")),
85 _boundary_1(getParam<
std::vector<BoundaryName>>(
"boundary_1")),
86 _boundary_2(getParam<
std::vector<BoundaryName>>(
"boundary_2")),
87 _mesh_1_shift(getParam<Point>(
"mesh_1_shift")),
88 _mesh_2_shift(getParam<Point>(
"mesh_2_shift")),
89 _num_layers(getParam<unsigned
int>(
"num_layers")),
93 _begin_side_boundary_id(getParam<
boundary_id_type>(
"begin_side_boundary_id")),
95 _use_quad_elements(getParam<bool>(
"use_quad_elements")),
96 _bias_parameter(getParam<
Real>(
"bias_parameter")),
97 _sigma(getParam<
Real>(
"gaussian_sigma")),
98 _keep_inputs(getParam<bool>(
"keep_inputs")),
99 _input_1(getMeshByName(_input_name_1)),
100 _input_2(getMeshByName(_input_name_2))
103 paramError(
"input_mesh_2",
"This parameter must be different from input_mesh_1.");
106 std::unique_ptr<MeshBase>
109 auto input_mesh_1 = std::move(
_input_1);
110 auto input_mesh_2 = std::move(
_input_2);
116 if (*(input_mesh_1->elem_dimensions().begin()) != 2 ||
117 *(input_mesh_1->elem_dimensions().rbegin()) != 2)
118 paramError(
"input_mesh_1",
"Only 2D meshes are supported.");
119 if (*(input_mesh_2->elem_dimensions().begin()) != 2 ||
120 *(input_mesh_2->elem_dimensions().rbegin()) != 2)
121 paramError(
"input_mesh_2",
"Only 2D meshes are supported.");
123 MeshTools::Modification::translate(
125 MeshTools::Modification::translate(
128 const auto input_mesh_1_external_bids =
130 const auto input_mesh_2_external_bids =
133 for (
unsigned int i = 1; i < input_mesh_1_external_bids.size(); i++)
136 *input_mesh_1, input_mesh_1_external_bids[i], input_mesh_1_external_bids.front(),
true);
138 for (
unsigned int i = 1; i < input_mesh_2_external_bids.size(); i++)
141 *input_mesh_2, input_mesh_2_external_bids[i], input_mesh_2_external_bids.front(),
true);
145 input_mesh_1_external_bids.front()))
146 paramError(
"boundary_1",
"The boundary provided is not an external boundary.");
148 input_mesh_2_external_bids.front()))
149 paramError(
"boundary_2",
"The boundary provided is not an external boundary.");
151 Real max_input_mesh_1_node_radius;
152 Real max_input_mesh_2_node_radius;
153 std::vector<dof_id_type> boundary_1_ordered_nodes;
154 std::vector<dof_id_type> boundary_2_ordered_nodes;
160 max_input_mesh_1_node_radius,
161 boundary_1_ordered_nodes,
163 input_mesh_1_external_bids.front());
173 max_input_mesh_2_node_radius,
174 boundary_2_ordered_nodes,
176 input_mesh_2_external_bids.front());
183 std::vector<Point> positions_vector_1;
184 std::vector<Point> positions_vector_2;
186 for (
auto & boundary_1_node_id : boundary_1_ordered_nodes)
187 positions_vector_1.push_back(*input_mesh_1->node_ptr(boundary_1_node_id));
189 for (
auto & boundary_2_node_id : boundary_2_ordered_nodes)
190 positions_vector_2.push_back(*input_mesh_2->node_ptr(boundary_2_node_id));
218 mesh->prepare_for_use();
219 mesh->stitch_meshes(*input_mesh_1,
221 input_mesh_1_external_bids.front(),
227 mesh->stitch_meshes(*input_mesh_2,
229 input_mesh_2_external_bids.front(),
virtual const char * what() const
Get out the error message.
const std::string & _name
The name of this class.
const Point _mesh_1_shift
Translation applied to the first input mesh.
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh(unsigned int dim=libMesh::invalid_uint)
Build a replicated mesh.
const MeshGeneratorName _input_name_2
Name of the mesh which contains the second input boundary.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const Point _mesh_2_shift
Translation applied to the second input mesh.
std::unique_ptr< MeshBase > & _input_2
The mesh which contains the second input boundary.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const boundary_id_type _begin_side_boundary_id
ID to be assigned to the boundary that connects the starting points of positions_vectors.
const boundary_id_type _end_side_boundary_id
ID to be assigned to the boundary that connects the ending points of positions_vectors.
const boundary_id_type _input_boundary_1_id
ID to be assigned to the boundary that corresponds to the input boundary on the first input mesh...
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
std::unique_ptr< MeshBase > & _input_1
The mesh which contains the first input boundary.
auto max(const L &left, const R &right)
This FillBetweenSidesetsGenerator object is designed to generate a transition layer to connect two bo...
const std::vector< BoundaryName > _boundary_2
Name of the second input boundary for the transition layer generation.
registerMooseObject("MooseApp", FillBetweenSidesetsGenerator)
static InputParameters validParams()
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()
const Real _bias_parameter
A parameter used to set up mesh biasing of the layers.
const boundary_id_type _input_boundary_2_id
ID to be assigned to the boundary that corresponds to the input boundary on the second input mesh...
Provides a way for users to bail out of the current solve.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real _sigma
Parameter used for Gaussian blurring of local node density.
const subdomain_id_type _block_id
Subdomain ID to be assigned to the generated transition layer.
FillBetweenSidesetsGenerator(const InputParameters ¶meters)
Point meshCentroidCalculator(const MeshBase &mesh)
Calculates the centroid of a MeshBase.
void changeBoundaryId(MeshBase &mesh, const libMesh::boundary_id_type old_id, const libMesh::boundary_id_type new_id, bool delete_prev)
Changes the old boundary ID to a new ID in the mesh.
const bool _keep_inputs
Whether the input meshes are retained in the output.
const bool _use_quad_elements
A boolean parameter to determine whether QUAD4 elements are used instead of TRI3 elements.
const unsigned int _num_layers
Number of sublayers of the mesh to be generated.
MeshGenerators are objects that can modify or add to an existing mesh.
void ErrorVector unsigned int
const std::string & _type
The type of this class.
const std::vector< BoundaryName > _boundary_1
Name of the first input boundary for the transition layer generation.
const MeshGeneratorName _input_name_1
Name of the mesh which contains the first input boundary.