14 #include "libmesh/node.h" 23 "The input mesh that contains curve 1");
25 "The input mesh that contains curve 1");
27 "mesh_1_shift", Point(0.0, 0.0, 0.0),
"Translation vector to be applied to input_mesh_1");
29 "mesh_2_shift", Point(0.0, 0.0, 0.0),
"Translation vector to be applied to input_mesh_2");
31 "num_layers",
"num_layers>0",
"Number of layers of elements created between the boundaries.");
34 "input_boundary_1_id",
36 "Boundary ID to be assigned to the boundary defined by positions_vector_1.");
38 "input_boundary_2_id",
40 "Boundary ID to be assigned to the boundary defined by positions_vector_2.");
43 "Boundary ID to be assigned to the boundary connecting " 44 "starting points of the positions_vectors.");
47 "Boundary ID to be assigned to the boundary connecting ending " 48 "points of the positions_vectors.");
52 "Whether QUAD4 instead of TRI3 elements are used to construct the transition layer.");
57 "Parameter used to set up biasing of the layers: bias_parameter > 0.0 is used as the biasing " 58 "factor; bias_parameter = 0.0 activates automatic biasing based on local node density on " 59 "both input boundaries.");
64 "Gaussian parameter used to smoothen local node density for automatic biasing; this " 65 "parameter is not used if another biasing option is selected.");
66 params.
addClassDescription(
"This FillBetweenCurvesGenerator object is designed to generate a " 67 "transition layer to connect two boundaries of two input meshes.");
73 _input_name_1(getParam<MeshGeneratorName>(
"input_mesh_1")),
74 _input_name_2(getParam<MeshGeneratorName>(
"input_mesh_2")),
75 _mesh_1_shift(getParam<Point>(
"mesh_1_shift")),
76 _mesh_2_shift(getParam<Point>(
"mesh_2_shift")),
77 _num_layers(getParam<unsigned
int>(
"num_layers")),
81 _begin_side_boundary_id(getParam<
boundary_id_type>(
"begin_side_boundary_id")),
83 _use_quad_elements(getParam<bool>(
"use_quad_elements")),
84 _bias_parameter(getParam<
Real>(
"bias_parameter")),
85 _sigma(getParam<
Real>(
"gaussian_sigma")),
86 _input_1(getMeshByName(_input_name_1)),
87 _input_2(getMeshByName(_input_name_2))
90 paramError(
"input_mesh_2",
"This parameter must be different from input_mesh_1.");
93 std::unique_ptr<MeshBase>
99 paramError(
"input_mesh_1",
"Input is not a replicated mesh, which is required.");
101 paramError(
"input_mesh_2",
"Input is not a replicated mesh, which is required.");
103 MeshTools::Modification::translate(
105 MeshTools::Modification::translate(
108 Real max_input_mesh_1_node_radius;
109 Real max_input_mesh_2_node_radius;
110 std::vector<dof_id_type> curve_1_ordered_nodes;
111 std::vector<dof_id_type> curve_2_ordered_nodes;
116 max_input_mesh_1_node_radius,
117 curve_1_ordered_nodes,
128 max_input_mesh_2_node_radius,
129 curve_2_ordered_nodes,
137 std::vector<Point> positions_vector_1;
138 std::vector<Point> positions_vector_2;
140 for (
auto & curve_1_node_id : curve_1_ordered_nodes)
141 positions_vector_1.push_back(*input_mesh_1->node_ptr(curve_1_node_id));
143 for (
auto & curve_2_node_id : curve_2_ordered_nodes)
144 positions_vector_2.push_back(*input_mesh_2->node_ptr(curve_2_node_id));
165 BoundaryInfo & boundary =
mesh->get_boundary_info();
166 const BoundaryInfo & input_bdy_1 = input_mesh_1->get_boundary_info();
167 const BoundaryInfo & input_bdy_2 = input_mesh_2->get_boundary_info();
171 if (!
mesh->is_prepared())
172 mesh->prepare_for_use();
173 auto pl =
mesh->sub_point_locator();
176 const auto node_list_mesh1 = input_bdy_1.build_node_list();
177 for (
const auto & t : node_list_mesh1)
179 mooseAssert(pl->locate_node(*input_mesh_1->node_ptr(std::get<0>(t))),
180 "We should have found the old node in input mesh 1");
181 boundary.add_node(pl->locate_node(*input_mesh_1->node_ptr(std::get<0>(t))), std::get<1>(t));
182 offset =
std::max(std::get<1>(t), offset);
185 const auto node_list_mesh2 = input_bdy_2.build_node_list();
186 for (
const auto & t : node_list_mesh2)
188 mooseAssert(pl->locate_node(*input_mesh_1->node_ptr(std::get<0>(t))),
189 "We should have found the old node in input mesh 2");
190 boundary.add_node(pl->locate_node(*input_mesh_2->node_ptr(std::get<0>(t))),
191 std::get<1>(t) + offset);
194 for (
const auto & nodeset_pair : input_bdy_1.get_nodeset_name_map())
195 boundary.set_nodeset_name_map().insert(nodeset_pair);
196 for (
const auto & [bnd_id, bnd_name] : input_bdy_2.get_nodeset_name_map())
197 boundary.set_nodeset_name_map()[bnd_id + offset] = bnd_name;
198 if (node_list_mesh1.size() + node_list_mesh2.size())
199 mesh->set_isnt_prepared();
207 Point pt_tmp = Point(0.0, 0.0, 0.0);
208 Real length_tmp = 0.0;
209 for (
const auto elem : curve.element_ptr_range())
211 Real elem_length = elem->hmax();
212 pt_tmp += (elem->vertex_average()) * elem_length;
213 length_tmp += elem_length;
215 return pt_tmp / length_tmp;
FillBetweenCurvesGenerator(const InputParameters ¶meters)
const boundary_id_type _end_side_boundary_id
ID to be assigned to the boundary that connects the ending points of positions_vectors.
const MeshGeneratorName _input_name_1
Name of the mesh which contains the first input boundary.
virtual const char * what() const
Get out the error message.
const std::string & _name
The name of this class.
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh(unsigned int dim=libMesh::invalid_uint)
Build a replicated mesh.
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 Real _sigma
Parameter used for Gaussian blurring of local node density.
const boundary_id_type _begin_side_boundary_id
ID to be assigned to the boundary that connects the starting points of positions_vectors.
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.
Point curveCentroidPoint(const ReplicatedMesh &curve)
Calculates the centroid of a curve mesh.
const bool _use_quad_elements
A boolean parameter to determine whether QUAD4 elements are used instead of TRI3 elements.
auto max(const L &left, const R &right)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const unsigned int _num_layers
Number of sublayers of the mesh to be generated.
const subdomain_id_type _block_id
Subdomain ID to be assigned to the generated transition layer.
std::unique_ptr< MeshBase > & _input_1
The mesh which contains the first input boundary.
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...
const Point _mesh_2_shift
Translation applied to the second input mesh.
static InputParameters validParams()
const Point _mesh_1_shift
Translation applied to the first input mesh.
std::unique_ptr< MeshBase > & _input_2
The mesh which contains the second input boundary.
This FillBetweenCurvesGenerator object is designed to generate a transition layer to connect two curv...
Provides a way for users to bail out of the current solve.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
registerMooseObject("MooseApp", FillBetweenCurvesGenerator)
const MeshGeneratorName _input_name_2
Name of the mesh which contains the second input boundary.
const Real _bias_parameter
A parameter used to set up mesh biasing of the layers.
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.
static InputParameters validParams()