17 #include "libmesh/replicated_mesh.h" 18 #include "libmesh/unstructured_mesh.h" 19 #include "libmesh/mesh_modification.h" 20 #include "libmesh/point.h" 21 #include "libmesh/node.h" 31 "Combine multiple meshes (or copies of one mesh) together into one (disjoint) mesh. Can " 32 "optionally translate those meshes before combining them.");
36 "The input MeshGenerators. This can either be N generators or 1 generator. If only 1 is " 37 "given then 'positions' must also be given.");
41 "The (optional) position of each given mesh. If N 'inputs' were given then this must either " 42 "be left blank or N positions must be given. If 1 input was given then this MUST be " 45 params.
addParam<std::vector<FileName>>(
46 "positions_file",
"Alternative way to provide the position of each given mesh.");
48 params.
addParam<
bool>(
"avoid_merging_subdomains",
50 "Whether to prevent merging subdomains by offsetting ids. The first mesh " 51 "in the input will keep the same subdomains ids, the others will have " 52 "offsets. All subdomain names will remain valid");
53 params.
addParam<
bool>(
"avoid_merging_boundaries",
55 "Whether to prevent merging sidesets by offsetting ids. The first mesh " 56 "in the input will keep the same boundary ids, the others will have " 57 "offsets. All boundary names will remain valid");
64 _meshes(getMeshes(
"inputs")),
65 _input_names(getParam<
std::vector<MeshGeneratorName>>(
"inputs")),
66 _avoid_merging_subdomains(getParam<bool>(
"avoid_merging_subdomains")),
67 _avoid_merging_boundaries(getParam<bool>(
"avoid_merging_boundaries"))
70 paramError(
"input_names",
"You need to specify at least one MeshGenerator as an input.");
73 mooseError(
"Both 'positions' and 'positions_file' cannot be specified simultaneously in " 80 "If only one input mesh is given, then 'positions' or 'positions_file' must also " 89 _positions = getParam<std::vector<Point>>(
"positions");
93 paramError(
"positions",
"If only one input mesh is given, then 'positions' cannot be empty.");
99 "If more than one input mesh is provided then the number of positions provided must " 100 "exactly match the number of input meshes.");
104 std::vector<FileName> positions_file = getParam<std::vector<FileName>>(
"positions_file");
107 if ((
_input_names.size() == 1) && positions_file.empty())
109 "If only one input mesh is given, then 'positions_file' cannot be empty.");
111 for (
const auto & f : positions_file)
120 if (data.size() && (
_input_names.size() != data.size()))
122 "If more than one input mesh is provided then the number of positions must " 123 "exactly match the number of input meshes.");
125 for (
const auto & d : data)
131 std::unique_ptr<MeshBase>
151 MeshTools::Modification::translate(
166 MeshTools::Modification::translate(
178 mesh->set_isnt_prepared();
196 MeshTools::Modification::translate(
210 copy = input_mesh->clone();
213 if (!translated_mesh)
219 MeshTools::Modification::translate(
231 for (
auto translated_node_ptr : translated_mesh->node_ptr_range())
233 auto & translated_node = *translated_node_ptr;
234 auto & input_node = input_mesh->node_ref(translated_node_ptr->id());
236 for (MooseIndex(LIBMESH_DIM) i = 0; i < LIBMESH_DIM; i++)
237 translated_node(i) = input_node(i);
241 final_mesh->set_isnt_prepared();
const std::string & _name
The name of this class.
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 bool _avoid_merging_boundaries
Boolean to control whether to prevent merging boundaries.
Collects multiple meshes into a single (unconnected) mesh.
const std::vector< Point > getDataAsPoints() const
Get the data in Point format.
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 bool _avoid_merging_subdomains
Boolean to control whether to prevent merging subdomains.
registerMooseObject("MooseApp", CombinerGenerator)
const std::vector< MeshGeneratorName > & _input_names
The mesh generators to use.
void setFormatFlag(FormatFlag value)
void copyIntoMesh(MeshGenerator &mg, UnstructuredMesh &destination, const UnstructuredMesh &source, const bool avoid_merging_subdomains, const bool avoid_merging_boundaries, const Parallel::Communicator &communicator)
Helper function for copying one mesh into another.
void read()
Perform the actual data reading.
static InputParameters validParams()
static InputParameters validParams()
Utility class for reading delimited data (e.g., CSV data).
std::vector< Point > _positions
The (offsets) positions for each mesh.
const std::vector< std::unique_ptr< MeshBase > * > _meshes
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
CombinerGenerator(const InputParameters ¶meters)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MeshGenerators are objects that can modify or add to an existing mesh.