https://mooseframework.inl.gov
MFEMFESpace.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 "MFEMObject.h"
15 
20 class MFEMFESpace : public MFEMObject
21 {
22 public:
24 
26 
27  // Note: The simplest way to handle the boilerplate of constructing
28  // FiniteElementCollection and FiniteElementSpace objects in the
29  // base class while deferring their arguments to the subclasses was
30  // to build them after construction was finished. Rather than
31  // requiring the user to call an additional Init() function (which
32  // could easily be forgotten) instead they get built lazily, when
33  // required.
34 
36  inline std::shared_ptr<mfem::ParFiniteElementSpace> getFESpace() const
37  {
38  if (!_fespace)
39  buildFESpace();
40  return _fespace;
41  }
42 
44  inline std::shared_ptr<mfem::FiniteElementCollection> getFEC() const
45  {
46  if (!_fec)
47  buildFEC();
48  return _fec;
49  }
50 
51  virtual bool isScalar() const = 0;
52 
53  virtual bool isVector() const = 0;
54 
55 protected:
57  const int _ordering;
58 
60  virtual std::string getFECName() const = 0;
61 
64  virtual int getVDim() const = 0;
65 
68  mfem::ParMesh & _pmesh;
69 
70 private:
72  void buildFEC() const;
74  mutable std::shared_ptr<mfem::FiniteElementCollection> _fec{nullptr};
75 
77  void buildFESpace() const;
79  mutable std::shared_ptr<mfem::ParFiniteElementSpace> _fespace{nullptr};
80 };
81 
82 #endif
Thin base for MFEM objects backed directly by MooseObject instead of UserObject.
Definition: MFEMObject.h:25
virtual int getVDim() const =0
Get the number of degrees of freedom per basis function needed in this finite element space...
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const int _ordering
Type of ordering of the vector dofs when _vdim > 1.
Definition: MFEMFESpace.h:57
MFEMFESpace(const InputParameters &parameters)
Definition: MFEMFESpace.C:29
std::shared_ptr< mfem::FiniteElementCollection > getFEC() const
Returns a shared pointer to the constructed fec.
Definition: MFEMFESpace.h:44
virtual bool isScalar() const =0
void buildFEC() const
Constructs the fec from the fec name.
Definition: MFEMFESpace.C:40
static InputParameters validParams()
Definition: MFEMFESpace.C:16
void buildFESpace() const
Constructs the fespace.
Definition: MFEMFESpace.C:47
virtual std::string getFECName() const =0
Get the name of the desired FECollection.
std::shared_ptr< mfem::FiniteElementCollection > _fec
Stores the constructed fecollection.
Definition: MFEMFESpace.h:74
mfem::ParMesh & _pmesh
Mesh FESpace is defined with respect to.
Definition: MFEMFESpace.h:68
Constructs and stores an mfem::ParFiniteElementSpace object.
Definition: MFEMFESpace.h:20
std::shared_ptr< mfem::ParFiniteElementSpace > _fespace
Stores the constructed fespace.
Definition: MFEMFESpace.h:79
std::shared_ptr< mfem::ParFiniteElementSpace > getFESpace() const
Returns a shared pointer to the constructed fespace.
Definition: MFEMFESpace.h:36
virtual bool isVector() const =0