https://mooseframework.inl.gov
MFEMFESpace.C
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 #include "MFEMFESpace.h"
13 #include "MFEMProblem.h"
14 
17 {
19  params.registerBase("MFEMFESpace");
20  MooseEnum ordering("NODES VDIM", "VDIM", false);
21  params.addParam<MooseEnum>("ordering", ordering, "Ordering style to use for vector DoFs.");
22  params.addParam<int>("vdim", 1, "The number of degrees of freedom per basis function.");
23  params.addParam<std::string>("submesh",
24  "Submesh to define the FESpace on. Leave blank to use base mesh.");
25  return params;
26 }
27 
29  : MFEMGeneralUserObject(parameters),
30  _ordering(parameters.get<MooseEnum>("ordering")),
31  _pmesh(
32  parameters.isParamValid("submesh")
33  ? getMFEMProblem().getProblemData().submeshes.GetRef(getParam<std::string>("submesh"))
34  : const_cast<mfem::ParMesh &>(getMFEMProblem().mesh().getMFEMParMesh()))
35 {
36 }
37 
38 void
39 MFEMFESpace::buildFEC(const std::string & fec_name) const
40 {
41  auto name = fec_name.c_str();
42  // Handle a few cases that were not supported by mfem::FiniteElementCollection::New as of v4.7
43  if (!strncmp(name, "RT_R1D", 6))
44  {
45  _fec = std::make_shared<mfem::RT_R1D_FECollection>(atoi(name + 11), atoi(name + 7));
46  }
47  else if (!strncmp(name, "RT_R2D", 6))
48  {
49  _fec = std::make_shared<mfem::RT_R2D_FECollection>(atoi(name + 11), atoi(name + 7));
50  }
51  else if (!strncmp(name, "ND_R1D", 6))
52  {
53  _fec = std::make_shared<mfem::ND_R1D_FECollection>(atoi(name + 11), atoi(name + 7));
54  }
55  else if (!strncmp(name, "ND_R2D", 6))
56  {
57  _fec = std::make_shared<mfem::ND_R2D_FECollection>(atoi(name + 11), atoi(name + 7));
58  }
59  else
60  {
61  _fec = std::shared_ptr<mfem::FiniteElementCollection>(mfem::FiniteElementCollection::New(name));
62  }
63 }
64 
65 void
66 MFEMFESpace::buildFESpace(const int vdim) const
67 {
68  _fespace =
69  std::make_shared<mfem::ParFiniteElementSpace>(&_pmesh, getFEC().get(), vdim, _ordering);
70 }
71 
72 #endif
void buildFEC(const std::string &fec_name) const
Constructs the fec from the fec name.
Definition: MFEMFESpace.C:39
static InputParameters validParams()
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1135
MeshBase & mesh
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
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
This class adds a getMFEMProblem method.
std::shared_ptr< mfem::FiniteElementCollection > getFEC() const
Returns a shared pointer to the constructed fec.
Definition: MFEMFESpace.h:46
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
static InputParameters validParams()
Definition: MFEMFESpace.C:16
std::shared_ptr< mfem::FiniteElementCollection > _fec
Stores the constructed fecollection.
Definition: MFEMFESpace.h:73
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
mfem::ParMesh & _pmesh
Mesh FESpace is defined with respect to.
Definition: MFEMFESpace.h:82
std::shared_ptr< mfem::ParFiniteElementSpace > _fespace
Stores the constructed fespace.
Definition: MFEMFESpace.h:78
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
void buildFESpace(const int vdim) const
Constructs the fespace.
Definition: MFEMFESpace.C:66