https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMMesh.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
12#pragma once
13
14#include "FileMesh.h"
15
20class MFEMMesh : public FileMesh
21{
22public:
24
26
27 virtual ~MFEMMesh();
28
34 mfem::ParMesh & getMFEMParMesh() { return *_mfem_par_mesh; }
35 const mfem::ParMesh & getMFEMParMesh() const;
36
40 std::shared_ptr<mfem::ParMesh> getMFEMParMeshPtr() { return _mfem_par_mesh; }
41
45 void init() override;
46 void buildMesh() override;
47 std::vector<std::filesystem::path>
48 writeRecoveryFiles(const std::filesystem::path & file_base) override;
49
53 std::unique_ptr<MooseMesh> safeClone() const override;
54
58 bool shouldDisplace() const { return _mesh_displacement_variable.has_value(); }
59
63 std::optional<std::reference_wrapper<std::string const>> getMeshDisplacementVariable() const
64 {
66 }
67
72 void displace(mfem::GridFunction const & displacement);
73
74 bool isDistributedMesh() const override { return true; }
75 unsigned int dimension() const override { return _mfem_par_mesh->Dimension(); }
76 unsigned int spatialDimension() const override { return _mfem_par_mesh->SpaceDimension(); }
77 SubdomainID nSubdomains() const override { return _mfem_par_mesh->attributes.Size(); }
78 dof_id_type nActiveElem() const override { return _mfem_par_mesh->GetGlobalNE(); }
79 dof_id_type nActiveLocalElem() const override { return _mfem_par_mesh->GetNE(); }
80
81private:
86
90 void uniformRefinement(mfem::Mesh & mesh, const unsigned int nref) const;
91
95 std::optional<std::string> _mesh_displacement_variable;
96
101 std::shared_ptr<mfem::ParMesh> _mfem_par_mesh{nullptr};
102};
103
104inline const mfem::ParMesh &
106{
107 return const_cast<MFEMMesh *>(this)->getMFEMParMesh();
108}
109
110#endif
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
MFEMMesh inherits a MOOSE mesh class which allows us to work with other MOOSE objects.
Definition MFEMMesh.h:21
SubdomainID nSubdomains() const override
Definition MFEMMesh.h:77
virtual ~MFEMMesh()
Definition MFEMMesh.C:51
std::optional< std::string > _mesh_displacement_variable
Holds name of variable used for mesh displacement, if set.
Definition MFEMMesh.h:95
mfem::ParMesh & getMFEMParMesh()
Accessors for the _mfem_par_mesh object.
Definition MFEMMesh.h:34
std::unique_ptr< MooseMesh > safeClone() const override
Clones the mesh.
Definition MFEMMesh.C:170
std::optional< std::reference_wrapper< std::string const > > getMeshDisplacementVariable() const
Returns an optional reference to displacement variable name.
Definition MFEMMesh.h:63
unsigned int dimension() const override
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
Definition MFEMMesh.h:75
std::vector< std::filesystem::path > writeRecoveryFiles(const std::filesystem::path &file_base) override
Write the mesh files needed for recovery/checkpointing.
Definition MFEMMesh.C:128
dof_id_type nActiveElem() const override
Definition MFEMMesh.h:78
static InputParameters validParams()
Definition MFEMMesh.C:21
void uniformRefinement(mfem::Mesh &mesh, const unsigned int nref) const
Performs a uniform refinement on the chosen mesh nref times.
Definition MFEMMesh.C:163
bool isDistributedMesh() const override
Returns the final Mesh distribution type.
Definition MFEMMesh.h:74
std::shared_ptr< mfem::ParMesh > getMFEMParMeshPtr()
Copy a shared_ptr to the mfem::ParMesh object.
Definition MFEMMesh.h:40
void displace(mfem::GridFunction const &displacement)
Displace the nodes of the mesh by the given displacement.
Definition MFEMMesh.C:145
unsigned int spatialDimension() const override
Returns MeshBase::spatial_dimension.
Definition MFEMMesh.h:76
void buildDummyMooseMesh()
Builds a placeholder mesh when no MOOSE mesh is required.
Definition MFEMMesh.C:154
dof_id_type nActiveLocalElem() const override
Definition MFEMMesh.h:79
void init() override
Build MFEM ParMesh and a placeholder MOOSE mesh.
Definition MFEMMesh.C:54
std::shared_ptr< mfem::ParMesh > _mfem_par_mesh
Smart pointers to mfem::ParMesh object.
Definition MFEMMesh.h:101
bool shouldDisplace() const
Returns true if mesh displacement is required.
Definition MFEMMesh.h:58
void buildMesh() override
Must be overridden by child classes.
Definition MFEMMesh.C:80
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131