16 #include "libmesh/replicated_mesh.h" 17 #include "libmesh/unstructured_mesh.h" 18 #include "libmesh/mesh_modification.h" 19 #include "libmesh/point.h" 20 #include "libmesh/node.h" 30 "Combine multiple meshes (or copies of one mesh) together into one (disjoint) mesh. Can " 31 "optionally translate those meshes before combining them.");
35 "The input MeshGenerators. This can either be N generators or 1 generator. If only 1 is " 36 "given then 'positions' must also be given.");
40 "The (optional) position of each given mesh. If N 'inputs' were given then this must either " 41 "be left blank or N positions must be given. If 1 input was given then this MUST be " 44 params.
addParam<std::vector<FileName>>(
45 "positions_file",
"Alternative way to provide the position of each given mesh.");
52 _meshes(getMeshes(
"inputs")),
53 _input_names(getParam<
std::vector<MeshGeneratorName>>(
"inputs"))
56 paramError(
"input_names",
"You need to specify at least one MeshGenerator as an input.");
59 mooseError(
"Both 'positions' and 'positions_file' cannot be specified simultaneously in " 66 "If only one input mesh is given, then 'positions' or 'positions_file' must also " 75 _positions = getParam<std::vector<Point>>(
"positions");
79 paramError(
"positions",
"If only one input mesh is given, then 'positions' cannot be empty.");
85 "If more than one input mesh is provided then the number of positions provided must " 86 "exactly match the number of input meshes.");
90 std::vector<FileName> positions_file = getParam<std::vector<FileName>>(
"positions_file");
93 if ((
_input_names.size() == 1) && positions_file.empty())
95 "If only one input mesh is given, then 'positions_file' cannot be empty.");
97 for (
const auto & f : positions_file)
106 if (data.size() && (
_input_names.size() != data.size()))
108 "If more than one input mesh is provided then the number of positions must " 109 "exactly match the number of input meshes.");
111 for (
const auto & d : data)
117 std::unique_ptr<MeshBase>
145 MeshTools::Modification::translate(
152 mesh->set_isnt_prepared();
170 MeshTools::Modification::translate(
184 copy = input_mesh->clone();
187 if (!translated_mesh)
193 MeshTools::Modification::translate(
200 for (
auto translated_node_ptr : translated_mesh->node_ptr_range())
202 auto & translated_node = *translated_node_ptr;
203 auto & input_node = input_mesh->node_ref(translated_node_ptr->id());
205 for (MooseIndex(LIBMESH_DIM) i = 0; i < LIBMESH_DIM; i++)
206 translated_node(i) = input_node(i);
210 final_mesh->set_isnt_prepared();
218 dof_id_type node_delta = destination.max_node_id();
219 dof_id_type elem_delta = destination.max_elem_id();
222 #ifdef LIBMESH_ENABLE_UNIQUE_ID 223 destination.parallel_max_unique_id();
229 destination.copy_nodes_and_elements(source,
243 BoundaryInfo & boundary = destination.get_boundary_info();
244 const BoundaryInfo & other_boundary = source.get_boundary_info();
245 for (
const auto & t : other_boundary.build_node_list())
246 boundary.add_node(std::get<0>(t) + node_delta, std::get<1>(t));
248 for (
const auto & t : other_boundary.build_side_list())
249 boundary.add_side(std::get<0>(t) + elem_delta, std::get<1>(t), std::get<2>(t));
251 for (
const auto & t : other_boundary.build_edge_list())
252 boundary.add_edge(std::get<0>(t) + elem_delta, std::get<1>(t), std::get<2>(t));
254 for (
const auto & t : other_boundary.build_shellface_list())
255 boundary.add_shellface(std::get<0>(t) + elem_delta, std::get<1>(t), std::get<2>(t));
257 for (
auto block_name_id_pair : source.get_subdomain_name_map())
258 destination.set_subdomain_name_map().insert(block_name_id_pair);
260 for (
auto nodeset_name_id_pair : other_boundary.get_nodeset_name_map())
261 boundary.set_nodeset_name_map().insert(nodeset_name_id_pair);
263 for (
auto sideset_name_id_pair : other_boundary.get_sideset_name_map())
264 boundary.set_sideset_name_map().insert(sideset_name_id_pair);
266 for (
auto edgeset_name_id_pair : other_boundary.get_edgeset_name_map())
267 boundary.set_edgeset_name_map().insert(edgeset_name_id_pair);
void read()
Perform the actual data reading.
Collects multiple meshes into a single (unconnected) mesh.
Utility class for reading delimited data (e.g., CSV data).
void fillPositions()
Fill the offset positions for each 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.
const Parallel::Communicator & _communicator
const std::vector< Point > getDataAsPoints() const
Get the data in Point format.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
registerMooseObject("MooseApp", CombinerGenerator)
const std::vector< MeshGeneratorName > & _input_names
The mesh generators to use.
void setFormatFlag(FormatFlag value)
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 ...
static InputParameters validParams()
const std::string _name
The name of this class.
static InputParameters validParams()
void copyIntoMesh(UnstructuredMesh &destination, const UnstructuredMesh &source)
Helper funciton for copying one mesh into another.
std::vector< Point > _positions
The (offsets) positions for each mesh.
const std::vector< std::unique_ptr< MeshBase > * > _meshes
CombinerGenerator(const InputParameters ¶meters)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
MeshGenerators are objects that can modify or add to an existing mesh.