13 #include "libmesh/replicated_mesh.h" 14 #include "libmesh/face_quad4.h" 15 #include "libmesh/exodusII_io.h" 16 #include "libmesh/mesh_communication.h" 17 #include "libmesh/mesh_tools.h" 27 params.
addParam<std::vector<std::string>>(
28 "exodus_extra_element_integers",
29 "The variable names in the mesh file for loading extra element integers");
30 params.
addParam<
bool>(
"use_for_exodus_restart",
32 "True to indicate that the mesh file this generator is reading can be used " 33 "for restarting variables");
34 params.
addParam<
bool>(
"skip_partitioning",
36 "True to skip partitioning, only after this mesh generator, " 37 "because the mesh was pre-split for example.");
38 params.
addParam<
bool>(
"allow_renumbering",
40 "Whether to allow the mesh to renumber nodes and elements. Note that this " 41 "parameter is only relevant for non-exodus files, e.g. if reading from " 42 "checkpoint for example. For exodus we always disallow renumbering.");
43 params.
addParam<
bool>(
"clear_spline_nodes",
45 "If clear_spline_nodes=true, IsoGeometric Analyis spline nodes " 46 "and constraints are removed from an IGA mesh, after which only " 47 "C^0 Rational-Bernstein-Bezier elements will remain.");
54 _file_name(getParam<MeshFileName>(
"file")),
55 _skip_partitioning(getParam<bool>(
"skip_partitioning")),
56 _allow_renumbering(getParam<bool>(
"allow_renumbering"))
60 std::unique_ptr<MeshBase>
69 bool has_exodus_integers =
isParamValid(
"exodus_extra_element_integers");
73 auto exreader = std::make_shared<ExodusII_IO>(*mesh);
76 if (has_exodus_integers)
77 exreader->set_extra_integer_vars(
78 getParam<std::vector<std::string>>(
"exodus_extra_element_integers"));
84 mesh->allow_renumbering(
false);
88 if (
mesh->processor_id() == 0)
92 if (getParam<bool>(
"clear_spline_nodes"))
93 MeshTools::clear_spline_nodes(*
mesh);
95 MeshCommunication().broadcast(*
mesh);
99 mesh->skip_partitioning(
true);
100 mesh->prepare_for_use();
101 mesh->skip_partitioning(
false);
106 mooseError(
"\"exodus_extra_element_integers\" should be given only for Exodus mesh files");
108 mooseError(
"\"use_for_exodus_restart\" should be given only for Exodus mesh files");
116 mesh->read(file_name);
133 const std::string old_ending =
"_mesh.cpr";
134 if (std::equal(old_ending.rbegin(), old_ending.rend(), file_name.rbegin()))
136 const std::string new_ending =
"-mesh.cpr";
137 auto new_path = file_name;
138 new_path.replace(new_path.size() - old_ending.size(), old_ending.size(), new_ending, 0);
141 std::stringstream warning;
143 <<
"The supplied checkpoint " << std::filesystem::path(file_name).filename()
144 <<
" uses the previous default checkpoint suffix of \"" << old_ending
145 <<
"\".\nThe new default checkpoint suffix is \"" << new_ending <<
"\".\n\n" 146 <<
"Your supplied checkpoint was not found, but one with the new ending was found in\n\"" 147 << new_path <<
"\".\n\n" 148 <<
"The above checkpoint is being used instead.\nYou should modify your input " 150 object.paramWarning(
"file", warning.str());
const MeshFileName & _file_name
the path/name of the file containing the mesh
const bool _skip_partitioning
whether to skip partitioning after loading the mesh
static const RestartableDataMapName MESH_META_DATA
Generates a mesh by reading it from an file.
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.
void setExReaderForRestart(std::shared_ptr< ExodusII_IO > &&exreader)
Set the Exodus reader to restart variables from an Exodus mesh file.
std::string convertLatestCheckpoint(std::string orig)
Replaces "LATEST" placeholders with the latest checkpoint file name.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
bool getExodusFileRestart() const
Whether or not we need to use a separate Exodus reader to read the mesh BEFORE we create the mesh...
FileMeshGenerator(const InputParameters ¶meters)
void possiblyLoadRestartableMetaData(const RestartableDataMapName &name, const std::filesystem::path &folder_base)
Loads the restartable meta data for name if it is available with the folder base folder_base.
Every object that can be built by the factory should be derived from this class.
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
Checks to see if a file is readable (exists and permissions)
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
MooseApp & _app
The MOOSE application this is associated with.
static InputParameters validParams()
static std::string deduceCheckpointPath(const MooseObject &object, const std::string &file_name)
Helper for deducing a checkpoint file given the path.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
registerMooseObject("MooseApp", FileMeshGenerator)
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.
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
Build a MeshBase object whose underlying type will be determined by the Mesh input file block...
bool pathExists(const std::string &path)
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
const bool _allow_renumbering
Whether to allow renumbering (for non-exodus files) when the mesh is read and prepared for use...