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 MFEM_ENABLED
11 
12 #pragma once
13 #include "libmesh/ignore_warnings.h"
14 #include "mfem.hpp"
15 #include "libmesh/restore_warnings.h"
16 #include "MFEMGeneralUserObject.h"
17 
23 {
24 public:
26 
28 
29  // Note: The simplest way to handle the boilerplate of constructing
30  // FiniteElementCollection and FiniteElementSpace objects in the
31  // base class while deferring their arguments to the subclasses was
32  // to build them after construction was finished. Rather than
33  // requiring the user to call an additional Init() function (which
34  // could easily be forgotten) instead they get built lazily, when
35  // required.
36 
38  inline std::shared_ptr<mfem::ParFiniteElementSpace> getFESpace() const
39  {
40  if (!_fespace)
42  return _fespace;
43  }
44 
46  inline std::shared_ptr<mfem::FiniteElementCollection> getFEC() const
47  {
48  if (!_fec)
50  return _fec;
51  }
52 
53  virtual bool isScalar() const = 0;
54 
55  virtual bool isVector() const = 0;
56 
57 protected:
59  const int _ordering;
60 
62  virtual std::string getFECName() const = 0;
63 
66  virtual int getVDim() const = 0;
67 
69  int getBasis(const std::string & basis_name) const;
70 
71 private:
73  void buildFEC(const std::string & fec_name) const;
74 
76  mutable std::shared_ptr<mfem::FiniteElementCollection> _fec{nullptr};
77 
79  void buildFESpace(const int vdim) const;
81  mutable std::shared_ptr<mfem::ParFiniteElementSpace> _fespace{nullptr};
82 
85  mfem::ParMesh & _pmesh;
86 };
87 
88 #endif
void buildFEC(const std::string &fec_name) const
Constructs the fec from the fec name.
Definition: MFEMFESpace.C:39
virtual int getVDim() const =0
Get the number of degrees of freedom per basis function needed in this finite element space...
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:59
MFEMFESpace(const InputParameters &parameters)
Definition: MFEMFESpace.C:28
int getBasis(const std::string &basis_name) const
Get the quadrature basis enum associated with the given name.
Definition: MFEMFESpace.C:66
std::shared_ptr< mfem::FiniteElementCollection > getFEC() const
Returns a shared pointer to the constructed fec.
Definition: MFEMFESpace.h:46
virtual bool isScalar() const =0
static InputParameters validParams()
Definition: MFEMFESpace.C:16
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:76
mfem::ParMesh & _pmesh
Mesh FESpace is defined with respect to.
Definition: MFEMFESpace.h:85
Constructs and stores an mfem::ParFiniteElementSpace object.
Definition: MFEMFESpace.h:22
std::shared_ptr< mfem::ParFiniteElementSpace > _fespace
Stores the constructed fespace.
Definition: MFEMFESpace.h:81
const InputParameters & parameters() const
Get the parameters of the object.
std::shared_ptr< mfem::ParFiniteElementSpace > getFESpace() const
Returns a shared pointer to the constructed fespace.
Definition: MFEMFESpace.h:38
virtual bool isVector() const =0
void buildFESpace(const int vdim) const
Constructs the fespace.
Definition: MFEMFESpace.C:94