41 "A string representing the Moose Object that will be built by this Action");
43 params.
addParam<
bool>(
"second_order",
45 "Converts a first order mesh to a second order " 46 "mesh. Note: This is NOT needed if you are reading " 47 "an actual first order mesh.");
49 params.
addParam<std::vector<SubdomainID>>(
"block_id",
"IDs of the block id/name pairs");
50 params.
addParam<std::vector<SubdomainName>>(
51 "block_name",
"Names of the block id/name pairs (must correspond with \"block_id\"");
53 params.
addParam<std::vector<BoundaryID>>(
"boundary_id", {},
"IDs of the boundary id/name pairs");
54 params.
addParam<std::vector<BoundaryName>>(
57 "Names of the boundary id/name pairs (must correspond with \"boundary_id\"");
59 params.
addParam<
bool>(
"construct_side_list_from_node_list",
61 "If true, construct side lists from the nodesets in the mesh (i.e. if " 62 "every node on a give side is in a nodeset then add that side to a " 65 params.
addParam<std::vector<std::string>>(
67 "The variables corresponding to the x y z displacements of the mesh. If " 68 "this is provided then the displacements will be taken into account during " 69 "the computation. Creation of the displaced mesh can be suppressed even if " 70 "this is set by setting 'use_displaced_mesh = false'.");
74 "Create the displaced mesh if the 'displacements' " 75 "parameter is set. If this is 'false', a displaced mesh will not be created, " 76 "regardless of whether 'displacements' is set.");
77 params.
addParam<std::vector<BoundaryName>>(
78 "ghosted_boundaries", {},
"Boundaries to be ghosted if using Nemesis");
79 params.
addParam<std::vector<Real>>(
"ghosted_boundaries_inflation",
80 "If you are using ghosted boundaries you will want to set " 81 "this value to a vector of amounts to inflate the bounding " 82 "boxes by. ie if you are running a 3D problem you might set " 83 "it to '0.2 0.1 0.4'");
86 "uniform_refine", 0,
"Specify the level of uniform refinement applied to the initial mesh");
88 params.
addParam<
bool>(
"skip_deletion_repartition_after_refine",
90 "If the flag is true, uniform refinements will run more efficiently, " 91 "but at the same time, there might be extra ghosting elements. " 92 "The number of layers of additional ghosting elements depends " 93 "on the number of uniform refinement levels. This flag " 94 "should be used only when you have a 'fine enough' coarse mesh and want " 95 "to refine the mesh by a few levels. Otherwise, it might introduce an " 96 "unbalanced workload and too large ghosting domain. ");
98 params.
addParam<
bool>(
"skip_partitioning",
100 "If true the mesh won't be partitioned. This may cause large load " 106 "Use split distributed mesh files; is overriden by the --use-split command line option");
107 params.
addParam<std::string>(
"split_file",
109 "Optional name of split mesh file(s) to write/read; is overridden " 110 "by the --split-file command line option");
115 params.
addParamNamesToGroup(
"second_order construct_side_list_from_node_list skip_partitioning",
125 _use_split(getParam<bool>(
"use_split") || _app.getParam<bool>(
"use_split")),
126 _split_file(_app.isParamSetByUser(
"split_file") ? _app.getParam<
std::string>(
"split_file")
127 : getParam<
std::string>(
"split_file"))
135 for (
const auto & bnd_name :
getParam<std::vector<BoundaryName>>(
"ghosted_boundaries"))
136 mesh->addGhostedBoundary(
mesh->getBoundaryID(bnd_name));
140 std::vector<Real> ghosted_boundaries_inflation =
141 getParam<std::vector<Real>>(
"ghosted_boundaries_inflation");
142 mesh->setGhostedBoundaryInflation(ghosted_boundaries_inflation);
145 mesh->ghostGhostedBoundaries();
147 if (getParam<bool>(
"second_order"))
148 mesh->getMesh().all_second_order(
true);
150 #ifdef LIBMESH_ENABLE_AMR 151 unsigned int level = getParam<unsigned int>(
"uniform_refine");
157 mesh->setUniformRefineLevel(level, getParam<bool>(
"skip_deletion_repartition_after_refine"));
158 #endif // LIBMESH_ENABLE_AMR 163 std::vector<SubdomainID> ids = getParam<std::vector<SubdomainID>>(
"block_id");
164 std::vector<SubdomainName> names = getParam<std::vector<SubdomainName>>(
"block_name");
165 std::set<SubdomainName> seen_it;
167 if (ids.size() != names.size())
168 mooseError(
"You must supply the same number of block ids and names parameters");
170 for (
unsigned int i = 0; i < ids.size(); ++i)
172 if (seen_it.find(names[i]) != seen_it.end())
173 mooseError(
"The following dynamic block name is not unique: " + names[i]);
174 seen_it.insert(names[i]);
175 mesh->setSubdomainName(ids[i], names[i]);
180 std::vector<BoundaryID> ids = getParam<std::vector<BoundaryID>>(
"boundary_id");
181 std::vector<BoundaryName> names = getParam<std::vector<BoundaryName>>(
"boundary_name");
182 std::set<SubdomainName> seen_it;
184 if (ids.size() != names.size())
185 mooseError(
"You must supply the same number of boundary ids and names parameters");
187 for (
unsigned int i = 0; i < ids.size(); ++i)
189 if (seen_it.find(names[i]) != seen_it.end())
190 mooseError(
"The following dynamic boundary name is not unique: " + names[i]);
191 mesh->setBoundaryName(ids[i], names[i]);
192 seen_it.insert(names[i]);
196 if (getParam<bool>(
"construct_side_list_from_node_list"))
197 mesh->getMesh().get_boundary_info().build_side_list_from_node_list();
200 if (getParam<bool>(
"skip_partitioning"))
201 mesh->getMesh().skip_partitioning(getParam<bool>(
"skip_partitioning"));
214 if (split_file !=
"" && split_file_ext !=
"cpr" && split_file_ext !=
"cpa.gz")
217 if (
_type !=
"FileMesh")
219 if (split_file.empty())
220 mooseError(
"Cannot use split mesh for a non-file mesh without specifying --split-file on " 221 "command line or the Mesh/split_file parameter");
228 new_pars.set<MeshFileName>(
"file") = split_file;
229 new_pars.set<
MooseApp *>(
"_moose_app") = moose_object_params.
get<
MooseApp *>(
"_moose_app");
230 moose_object_params = new_pars;
234 if (!split_file.empty())
235 moose_object_params.
set<MeshFileName>(
"file") = split_file;
237 moose_object_params.
set<MeshFileName>(
"file") =
241 moose_object_params.
set<
bool>(
"_is_split") =
true;
252 TIME_SECTION(
"SetupMeshAction::act::setup_mesh", 1,
"Setting Up Mesh",
true);
264 if (!generator_actions.empty())
270 _type =
"MeshGeneratorMesh";
284 for (
auto generator_action_ptr : generator_actions)
285 if (dynamic_cast<AddMeshGeneratorAction *>(generator_action_ptr))
287 mooseError(
"Mesh Generators present but the [Mesh] block is set to construct a \"",
289 "\" mesh, which does not use Mesh Generators in constructing the mesh. ");
304 TIME_SECTION(
"SetupMeshAction::act::set_mesh_base", 1,
"Setting Mesh",
true);
318 mesh_generator_system.
getSavedMesh(mesh_generator_system.mainMeshGeneratorName());
319 if (
_mesh->allowRemoteElementRemoval() != mesh_base->allow_remote_element_removal())
320 mooseError(
"The MooseMesh and libmesh::MeshBase object coming from mesh generators are " 321 "out of sync with respect to whether remote elements can be deleted");
322 mooseAssert(mesh_base,
"Null mesh");
323 _mesh->setMeshBase(std::move(mesh_base));
328 std::vector<bool> use_dm;
329 for (
const auto & mg_name : mg_names)
330 if (hasMeshProperty<bool>(
"use_distributed_mesh", mg_name))
331 use_dm.push_back(getMeshProperty<bool>(
"use_distributed_mesh", mg_name));
335 if (std::adjacent_find(use_dm.begin(), use_dm.end(), std::not_equal_to<bool>()) !=
337 mooseError(
"You cannot use mesh generators that set different values of the mesh " 338 "property 'use_distributed_mesh' within the same simulation.");
342 _mesh->setParallelType(ptype);
345 _mesh->setMeshBase(
_mesh->buildMeshBaseObject());
352 TIME_SECTION(
"SetupMeshAction::act::set_mesh_base", 1,
"Initializing Mesh",
true);
363 if (
isParamValid(
"displacements") && getParam<bool>(
"use_displaced_mesh"))
368 _mesh->getMesh().allow_remote_element_removal());
370 std::vector<std::string> displacements =
371 getParam<std::vector<std::string>>(
"displacements");
373 mooseError(
"Number of displacements must be greater than or equal to the dimension of " const std::string _split_file
The split mesh file (if any); comes from either Mesh/split_file or –split-file.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
static InputParameters validParams()
std::vector< std::string > getMeshGeneratorNames() const
static InputParameters validParams()
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
std::unique_ptr< libMesh::MeshBase > getSavedMesh(const std::string &name)
Get the saved mesh by name.
registerMooseAction("MooseApp", SetupMeshAction, "setup_mesh")
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Base class for MOOSE-based applications.
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
bool isRestarting() const
Whether or not this is a "restart" calculation.
void extractParams(const std::string &prefix, InputParameters &p)
This function attempts to extract values from the input file based on the contents of the passed para...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
std::string getExtension(const std::string &filename, const bool rfind=false)
Gets the extension of the passed file name.
std::string stripExtension(const std::string &s, const bool rfind=false)
Removes any file extension from the given string s (i.e.
std::string _registered_identifier
Moose::Builder & builder()
Returns a writable reference to the builder.
std::shared_ptr< MooseMesh > & _displaced_mesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
const std::string & _current_task
The current action (even though we have separate instances for each action)
const MooseMesh * masterMesh() const
Returns a pointer to the master mesh.
MooseApp & _app
The MOOSE application this is associated with.
std::string modifyParamsForUseSplit(InputParameters &moose_object_params) const
Modifies the MooseObject's parameters to build the right type of Mesh when using splits.
SetupMeshAction(const InputParameters ¶ms)
void setupMesh(MooseMesh *mesh)
const MooseMesh * masterDisplacedMesh() const
Returns a pointer to the master displaced mesh.
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
std::shared_ptr< MooseMesh > & _mesh
std::string _type
The Object type that is being created.
virtual std::unique_ptr< MooseMesh > safeClone() const =0
A safer version of the clone() method that hands back an allocated object wrapped in a smart pointer...
InputParameters _moose_object_pars
The parameters for the object to be created.
static InputParameters validParams()
bool useMasterMesh() const
Returns whether to use the parent app mesh as the mesh for this app.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
bool isRecovering() const
Whether or not this is a "recover" calculation.
const bool _use_split
Whether or not to use a split mesh; comes from either Mesh/use_split or –use-split.
bool isParamSetByUser(const std::string &nm) const