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<BoundaryName>>(
66 "ghosted_boundaries", {},
"Boundaries to be ghosted if using Nemesis");
67 params.
addParam<std::vector<Real>>(
"ghosted_boundaries_inflation",
68 "If you are using ghosted boundaries you will want to set "
69 "this value to a vector of amounts to inflate the bounding "
70 "boxes by. ie if you are running a 3D problem you might set "
71 "it to '0.2 0.1 0.4'");
74 "uniform_refine", 0,
"Specify the level of uniform refinement applied to the initial mesh");
76 params.
addParam<
bool>(
"skip_deletion_repartition_after_refine",
78 "If the flag is true, uniform refinements will run more efficiently, "
79 "but at the same time, there might be extra ghosting elements. "
80 "The number of layers of additional ghosting elements depends "
81 "on the number of uniform refinement levels. This flag "
82 "should be used only when you have a 'fine enough' coarse mesh and want "
83 "to refine the mesh by a few levels. Otherwise, it might introduce an "
84 "unbalanced workload and too large ghosting domain. ");
86 params.
addParam<
bool>(
"skip_partitioning",
88 "If true the mesh won't be partitioned. This may cause large load "
94 "Use split distributed mesh files; is overriden by the --use-split command line option");
95 params.
addParam<std::string>(
"split_file",
97 "Optional name of split mesh file(s) to write/read; is overridden "
98 "by the --split-file command line option");
102 params.
addParamNamesToGroup(
"second_order construct_side_list_from_node_list skip_partitioning",
112 _use_split(getParam<bool>(
"use_split") || _app.getParam<bool>(
"use_split")),
113 _split_file(_app.isParamSetByUser(
"split_file") ? _app.getParam<
std::string>(
"split_file")
114 : getParam<
std::string>(
"split_file"))
122 for (
const auto & bnd_name : getParam<std::vector<BoundaryName>>(
"ghosted_boundaries"))
123 mesh->addGhostedBoundary(
mesh->getBoundaryID(bnd_name));
127 std::vector<Real> ghosted_boundaries_inflation =
128 getParam<std::vector<Real>>(
"ghosted_boundaries_inflation");
129 mesh->setGhostedBoundaryInflation(ghosted_boundaries_inflation);
132 mesh->ghostGhostedBoundaries();
134 if (getParam<bool>(
"second_order"))
135 mesh->getMesh().all_second_order(
true);
137#ifdef LIBMESH_ENABLE_AMR
138 unsigned int level = getParam<unsigned int>(
"uniform_refine");
144 mesh->setUniformRefineLevel(level, getParam<bool>(
"skip_deletion_repartition_after_refine"));
150 std::vector<SubdomainID> ids = getParam<std::vector<SubdomainID>>(
"block_id");
151 std::vector<SubdomainName> names = getParam<std::vector<SubdomainName>>(
"block_name");
152 std::set<SubdomainName> seen_it;
154 if (ids.size() != names.size())
155 mooseError(
"You must supply the same number of block ids and names parameters");
157 for (
unsigned int i = 0; i < ids.size(); ++i)
159 if (seen_it.find(names[i]) != seen_it.end())
160 mooseError(
"The following dynamic block name is not unique: " + names[i]);
161 seen_it.insert(names[i]);
162 mesh->setSubdomainName(ids[i], names[i]);
167 std::vector<BoundaryID> ids = getParam<std::vector<BoundaryID>>(
"boundary_id");
168 std::vector<BoundaryName> names = getParam<std::vector<BoundaryName>>(
"boundary_name");
169 std::set<SubdomainName> seen_it;
171 if (ids.size() != names.size())
172 mooseError(
"You must supply the same number of boundary ids and names parameters");
174 for (
unsigned int i = 0; i < ids.size(); ++i)
176 if (seen_it.find(names[i]) != seen_it.end())
177 mooseError(
"The following dynamic boundary name is not unique: " + names[i]);
178 mesh->setBoundaryName(ids[i], names[i]);
179 seen_it.insert(names[i]);
183 if (getParam<bool>(
"construct_side_list_from_node_list"))
184 mesh->getMesh().get_boundary_info().build_side_list_from_node_list();
187 if (getParam<bool>(
"skip_partitioning"))
188 mesh->getMesh().skip_partitioning(getParam<bool>(
"skip_partitioning"));
201 if (split_file !=
"" && split_file_ext !=
"cpr" && split_file_ext !=
"cpa.gz")
204 if (
_type !=
"FileMesh")
206 if (split_file.empty())
207 mooseError(
"Cannot use split mesh for a non-file mesh without specifying --split-file on "
208 "command line or the Mesh/split_file parameter");
215 new_pars.set<MeshFileName>(
"file") = split_file;
218 moose_object_params = new_pars;
222 if (!split_file.empty())
223 moose_object_params.
set<MeshFileName>(
"file") = split_file;
225 moose_object_params.
set<MeshFileName>(
"file") =
229 moose_object_params.
set<
bool>(
"_is_split") =
true;
240 TIME_SECTION(
"SetupMeshAction::act::setup_mesh", 1,
"Setting Up Mesh",
true);
252 if (!generator_actions.empty())
260 bool has_mfem_generator =
false;
261#ifdef MOOSE_MFEM_ENABLED
264 if (
const auto *
const mesh_generator_action =
266 if (
const auto *
const is_mfem =
267 mesh_generator_action->getObjectParams().queryParam<
bool>(
268 "_mfem_mesh_generator"))
269 has_mfem_generator = *is_mfem;
272 _type = has_mfem_generator ?
"MFEMMeshGeneratorMesh" :
"MeshGeneratorMesh";
286 for (
auto generator_action_ptr : generator_actions)
289 mooseError(
"Mesh Generators present but the [Mesh] block is set to construct a \"",
291 "\" mesh, which does not use Mesh Generators in constructing the mesh. ");
306 TIME_SECTION(
"SetupMeshAction::act::set_mesh_base", 1,
"Setting Mesh",
true);
320 mesh_generator_system.
getSavedMesh(mesh_generator_system.mainMeshGeneratorName());
321 if (
_mesh->allowRemoteElementRemoval() != mesh_base->allow_remote_element_removal())
322 mooseError(
"The MooseMesh and libmesh::MeshBase object coming from mesh generators are "
323 "out of sync with respect to whether remote elements can be deleted");
324 mooseAssert(mesh_base,
"Null mesh");
325 _mesh->setMeshBase(std::move(mesh_base));
330 std::vector<bool> use_dm;
331 for (
const auto & mg_name : mg_names)
332 if (hasMeshProperty<bool>(
"use_distributed_mesh", mg_name))
333 use_dm.push_back(getMeshProperty<bool>(
"use_distributed_mesh", mg_name));
337 if (std::adjacent_find(use_dm.begin(), use_dm.end(), std::not_equal_to<bool>()) !=
339 mooseError(
"You cannot use mesh generators that set different values of the mesh "
340 "property 'use_distributed_mesh' within the same simulation.");
344 _mesh->setParallelType(ptype);
347 _mesh->setMeshBase(
_mesh->buildMeshBaseObject());
354 TIME_SECTION(
"SetupMeshAction::act::set_mesh_base", 1,
"Initializing Mesh",
true);
registerMooseAction("MooseApp", SetupMeshAction, "setup_mesh")
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
std::string _registered_identifier
std::shared_ptr< MooseMesh > & _mesh
MooseApp & _app
The MOOSE application this is associated with.
const std::string & _current_task
The current action (even though we have separate instances for each action)
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
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)
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
static InputParameters validParams()
std::unique_ptr< libMesh::MeshBase > getSavedMesh(const std::string &name)
Get the saved mesh by name.
Base class for MOOSE-based applications.
std::vector< std::string > getMeshGeneratorNames() const
bool isRestarting() const
Whether or not this is a "restart" calculation.
const MooseMesh * masterMesh() const
Returns a pointer to the master mesh.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
Moose::Builder & builder()
Returns a writable reference to the builder.
bool isRecovering() const
Whether or not this is a "recover" calculation.
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
bool useMasterMesh() const
Returns whether to use the parent app mesh as the mesh for this app.
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
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...
const InputParameters & _pars
The object's parameters.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
static const std::string app_param
The name of the parameter that contains the MooseApp.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
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()
std::string _type
The Object type that is being created.
void extractParams(const hit::Node *const section_node, InputParameters &p)
Attempt to extract values from input starting with the section in input in section_node based on the ...
Factory & _factory
The Factory associated with the MooseApp.
std::string modifyParamsForUseSplit(InputParameters &moose_object_params) const
Modifies the MooseObject's parameters to build the right type of Mesh when using splits.
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
const std::string _split_file
The split mesh file (if any); comes from either Mesh/split_file or –split-file.
const bool _use_split
Whether or not to use a split mesh; comes from either Mesh/use_split or –use-split.
void setupMesh(MooseMesh *mesh)
static InputParameters validParams()
SetupMeshAction(const InputParameters ¶ms)
std::string getExtension(const std::string &filename, const bool rfind)
std::string stripExtension(const std::string &s, const bool rfind)