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" 18 #include "libmesh/sparse_matrix.h" 28 params.
addParam<std::vector<std::string>>(
29 "exodus_extra_element_integers",
30 "The variable names in the mesh file for loading extra element integers");
31 params.
addParam<
bool>(
"use_for_exodus_restart",
33 "True to indicate that the mesh file this generator is reading can be used " 34 "for restarting variables");
35 params.
addParam<
bool>(
"skip_partitioning",
37 "True to skip partitioning, only after this mesh generator, " 38 "because the mesh was pre-split for example.");
39 params.
addParam<
bool>(
"allow_renumbering",
41 "Whether to allow the mesh to renumber nodes and elements, if not " 42 "overridden by a global parameter or by a requirement (e.g. an exodus " 43 "restart or a constraint matrix) that disables renumbering.");
44 params.
addParam<
bool>(
"clear_spline_nodes",
46 "If clear_spline_nodes=true, IsoGeometric Analyis spline nodes " 47 "and constraints are removed from an IGA mesh, after which only " 48 "C^0 Rational-Bernstein-Bezier elements will remain.");
49 params.
addParam<
bool>(
"discontinuous_spline_extraction",
51 "If discontinuous_spline_extraction=true, " 52 "Rational-Bernstein-Bezier elements extracted from a spline mesh " 53 "will be disconnected from neighboring elements, coupled only via " 54 "their extraction operators. This may be less efficient than the " 55 "default C^0 extracted mesh, but may be necessary if the extracted " 56 "mesh is non-conforming.");
58 "constraint_matrix",
"",
"The name of a constraint matrix file to apply to the mesh");
61 "Whether to attempt preconditioning with constraint matrix application");
64 "clear_spline_nodes discontinuous_spline_extraction constraint_matrix",
65 "IsoGeometric Analysis (IGA) and other mesh constraint options");
71 _file_name(getParam<MeshFileName>(
"file")),
72 _matrix_file_name(getParam<MatrixFileName>(
"constraint_matrix")),
73 _matrix_preconditioning(getParam<
Real>(
"constraint_preconditioning")),
74 _skip_partitioning(getParam<bool>(
"skip_partitioning")),
75 _allow_renumbering(getParam<bool>(
"allow_renumbering"))
79 "The 'constraint_preconditioning' parameter is only applicable to " 80 "meshes loaded with a corresponding 'constraint_matrix'.");
83 "This version of MOOSE only supports a 'constraint_preconditioning' " 84 "value of 1.0 if it is enabled. Non-binary preconditioning values " 85 "are reserved for future use.");
88 std::unique_ptr<MeshBase>
99 mesh->allow_renumbering(
false);
104 _file_name.rfind(
".ele") == std::string::npos;
105 bool has_exodus_integers =
isParamValid(
"exodus_extra_element_integers");
109 auto exreader = std::make_shared<libMesh::ExodusII_IO>(*mesh);
112 if (has_exodus_integers)
113 exreader->set_extra_integer_vars(
114 getParam<std::vector<std::string>>(
"exodus_extra_element_integers"));
120 eventually_allow_renumbering =
false;
121 mesh->allow_renumbering(
false);
125 if (
mesh->processor_id() == 0)
127 if (getParam<bool>(
"discontinuous_spline_extraction"))
128 exreader->set_discontinuous_bex(
true);
132 if (getParam<bool>(
"clear_spline_nodes"))
133 MeshTools::clear_spline_nodes(*
mesh);
139 mesh->skip_partitioning(
true);
140 mesh->prepare_for_use();
141 mesh->skip_partitioning(
false);
146 mooseError(
"\"exodus_extra_element_integers\" should be given only for Exodus mesh files");
148 mooseError(
"\"use_for_exodus_restart\" should be given only for Exodus mesh files");
155 mesh->read(file_name);
170 matrix->get_transpose(*matrix);
175 mesh->cache_elem_data();
178 mesh->allow_renumbering(eventually_allow_renumbering);
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.
std::string convertLatestCheckpoint(std::string orig)
Replaces "LATEST" placeholders with the latest checkpoint file name.
static std::unique_ptr< SparseMatrix< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
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.
const MatrixFileName & _matrix_file_name
the path/name of any file containing a matrix of mesh constraints
MooseApp & _app
The MOOSE application this is associated with.
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 Real _matrix_preconditioning
Whether (and later, how much) libMesh should try constraint matrix preconditioning.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("MooseApp", FileMeshGenerator)
void broadcast(MeshBase &) const
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()
void setExReaderForRestart(std::shared_ptr< libMesh::ExodusII_IO > &&exreader)
Set the Exodus reader to restart variables from an Exodus mesh file.
const bool _allow_renumbering
Whether to allow renumbering (for non-exodus files) when the mesh is read and prepared for use...