10 #ifdef MOOSE_MFEM_ENABLED 14 #include "libmesh/mesh_generation.h" 27 "Number of serial refinements to perform on the mesh. Equivalent to uniform_refine.");
31 "Number of serial refinements to perform on the mesh. Equivalent to serial_refine");
33 "parallel_refine", 0,
"Number of parallel refinements to perform on the mesh.");
34 params.
addParam<std::string>(
"displacement",
"Optional variable to use for mesh displacement.");
35 params.
addParam<
bool>(
"nonconforming",
37 "Ensures the mesh is non-conforming: necessary for refining quad/hex " 38 "meshes and load (re)balancing.");
39 params.
addParam<
bool>(
"reorder_mesh",
41 "Determines whether we reorder the mesh to improve dynamic partitioning. " 42 "Only Hilbert sorting is supported at present.");
68 std::ifstream input(checkpoint_file);
70 mooseError(
"Unable to open MFEM recovery mesh file '", checkpoint_file,
"'.");
82 TIME_SECTION(
"buildMesh", 2,
"Reading Mesh");
89 "Cannot define serial_refine and uniform_refine to be nonzero at the same time (they " 90 "are the same variable). Please choose one.\n");
94 : getParam<unsigned int>(
"uniform_refine"));
100 if (getParam<bool>(
"reorder_mesh"))
102 mfem::Array<int> ordering;
103 mfem_ser_mesh.GetHilbertElementOrdering(ordering);
104 mfem_ser_mesh.ReorderElements(ordering);
110 if (getParam<bool>(
"nonconforming"))
111 mfem_ser_mesh.EnsureNCMesh(
true);
127 std::vector<std::filesystem::path>
132 mooseAssert(
_mfem_par_mesh,
"MFEM parallel mesh is not initialized");
134 const auto checkpoint_file =
135 file_base.string() +
".mfem.mesh." + std::to_string(this->
processor_id());
136 std::ofstream output(checkpoint_file);
138 mooseError(
"Unable to open MFEM recovery mesh file '", checkpoint_file,
"' for writing.");
141 return {checkpoint_file};
150 *nodes += displacement;
156 auto & dummy =
static_cast<UnstructuredMesh &
>(
getMesh());
157 MeshTools::Generation::build_point(dummy);
159 MeshTools::Generation::build_square(dummy, 1, 1, 0., 1., 0., 1., ElemType::QUAD9);
165 for (
unsigned int i = 0; i < nref; ++i)
166 mesh.UniformRefinement();
169 std::unique_ptr<MooseMesh>
static const std::string & checkpointSuffix()
The file suffix for the checkpoint mesh.
std::vector< std::filesystem::path > writeRecoveryFiles(const std::filesystem::path &file_base) override
Write the mesh files needed for recovery/checkpointing.
unsigned int dimension() const override
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
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 ...
void uniformRefinement(mfem::Mesh &mesh, const unsigned int nref) const
Performs a uniform refinement on the chosen mesh nref times.
std::optional< std::string > _mesh_displacement_variable
Holds name of variable used for mesh displacement, if set.
const Parallel::Communicator & comm() const
virtual void init()
Initialize the Mesh object.
virtual std::vector< std::filesystem::path > writeRecoveryFiles(const std::filesystem::path &file_base)
Write the mesh files needed for recovery/checkpointing.
std::unique_ptr< T > copyConstruct(const T &object)
Copy constructs the object object.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
void init() override
Build MFEM ParMesh and a placeholder MOOSE mesh.
static InputParameters validParams()
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
void buildDummyMooseMesh()
Builds a placeholder mesh when no MOOSE mesh is required.
void buildMesh() override
Must be overridden by child classes.
std::unique_ptr< MooseMesh > safeClone() const override
Clones the mesh.
MooseApp & _app
The MOOSE application this is associated with.
bool allowRecovery() const
Returns whether this mesh is allowed to read a recovery file.
registerMooseObject("MooseApp", MFEMMesh)
MFEMMesh(const InputParameters ¶meters)
std::shared_ptr< mfem::ParMesh > _mfem_par_mesh
Smart pointers to mfem::ParMesh object.
void displace(mfem::GridFunction const &displacement)
Displace the nodes of the mesh by the given displacement.
MFEMMesh inherits a MOOSE mesh class which allows us to work with other MOOSE objects.
static InputParameters validParams()
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...
virtual std::string getFileName() const override
Returns the name of the mesh file read to produce this mesh if any or an empty string otherwise...
processor_id_type processor_id() const
bool isRecovering() const
Whether or not this is a "recover" calculation.
std::string getRestartRecoverFileBase() const
The file_base for the recovery file.
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.