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 "MooseMesh.h"
15
23class MFEMMesh : public MooseMesh
24{
25public:
27
29
33 mfem::ParMesh & getMFEMParMesh() { return *_mfem_par_mesh; }
34 const mfem::ParMesh & getMFEMParMesh() const;
35
39 std::shared_ptr<mfem::ParMesh> getMFEMParMeshPtr() { return _mfem_par_mesh; }
40
44 void init() override;
45 std::vector<std::filesystem::path>
46 writeRecoveryFiles(const std::filesystem::path & file_base) override;
47
51 bool shouldDisplace() const { return _mesh_displacement_variable.has_value(); }
52
56 std::optional<std::reference_wrapper<std::string const>> getMeshDisplacementVariable() const
57 {
59 }
60
65 void displace(mfem::GridFunction const & displacement);
66
67 bool isDistributedMesh() const override { return true; }
68 unsigned int dimension() const override { return _mfem_par_mesh->Dimension(); }
69 unsigned int spatialDimension() const override { return _mfem_par_mesh->SpaceDimension(); }
70 SubdomainID nSubdomains() const override { return _mfem_par_mesh->attributes.Size(); }
71 dof_id_type nActiveElem() const override { return _mfem_par_mesh->GetGlobalNE(); }
72 dof_id_type nActiveLocalElem() const override { return _mfem_par_mesh->GetNE(); }
73
74 void buildMesh() override final;
75
76protected:
80 virtual mfem::Mesh buildSerialMFEMMesh() = 0;
81
86
90 void uniformRefinement(mfem::Mesh & mesh, const unsigned int nref) const;
91
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
subdomain_id_type SubdomainID
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Abstract MooseMesh base for all MFEM-backed mesh types (MFEMFileMesh, MFEMMeshGeneratorMesh).
Definition MFEMMesh.h:24
SubdomainID nSubdomains() const override
Definition MFEMMesh.h:70
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:33
std::optional< std::reference_wrapper< std::string const > > getMeshDisplacementVariable() const
Returns an optional reference to displacement variable name.
Definition MFEMMesh.h:56
unsigned int dimension() const override
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
Definition MFEMMesh.h:68
std::vector< std::filesystem::path > writeRecoveryFiles(const std::filesystem::path &file_base) override
Write the mesh files needed for recovery/checkpointing.
Definition MFEMMesh.C:119
dof_id_type nActiveElem() const override
Definition MFEMMesh.h:71
static InputParameters validParams()
Definition MFEMMesh.C:19
void uniformRefinement(mfem::Mesh &mesh, const unsigned int nref) const
Performs a uniform refinement on the chosen mesh nref times.
Definition MFEMMesh.C:154
bool isDistributedMesh() const override
Returns the final Mesh distribution type.
Definition MFEMMesh.h:67
std::shared_ptr< mfem::ParMesh > getMFEMParMeshPtr()
Copy a shared_ptr to the mfem::ParMesh object.
Definition MFEMMesh.h:39
void displace(mfem::GridFunction const &displacement)
Displace the nodes of the mesh by the given displacement.
Definition MFEMMesh.C:136
unsigned int spatialDimension() const override
Returns MeshBase::spatial_dimension.
Definition MFEMMesh.h:69
virtual mfem::Mesh buildSerialMFEMMesh()=0
Build and return the serial mfem::Mesh for this object.
void buildDummyMooseMesh()
Builds a dimension-compatible libMesh placeholder after initializing the MFEM mesh.
Definition MFEMMesh.C:143
dof_id_type nActiveLocalElem() const override
Definition MFEMMesh.h:72
void init() override
Initialize the MFEM ParMesh and placeholder MOOSE mesh.
Definition MFEMMesh.C:48
std::shared_ptr< mfem::ParMesh > _mfem_par_mesh
Smart pointer to mfem::ParMesh object.
Definition MFEMMesh.h:101
void buildMesh() override final
Must be overridden by child classes.
Definition MFEMMesh.C:74
bool shouldDisplace() const
Returns true if mesh displacement is required.
Definition MFEMMesh.h:51
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95