https://mooseframework.inl.gov
MFEMVectorFESpace.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 "MFEMVectorFESpace.h"
13 
15 
18 {
20  params.addClassDescription(
21  "Convenience class to construct vector finite element spaces, abstracting away some of the "
22  "mathematical complexity of specifying the dimensions.");
23  MooseEnum fec_types("H1 ND RT L2", "H1", true);
24  params.addParam<MooseEnum>("fec_type", fec_types, "Specifies the family of FE shape functions.");
25  params.addParam<std::string>("closed_basis",
26  "GaussLobatto",
27  "Specifies the closed quadrature basis used for vector elements.");
28  params.addParam<std::string>("open_basis",
29  "GaussLegendre",
30  "Specifies the open quadrature basis used for vector elements.");
31  params.addParam<int>("range_dim",
32  0,
33  "The number of components of the vectors in reference space. Zero "
34  "(the default) means it will be the same as the problem dimension. "
35  "Note that MFEM does not currently support 2D vectors in 1D space "
36  "for ND and RT elements.");
37  return params;
38 }
39 
41  : MFEMSimplifiedFESpace(parameters),
42  _fec_type(parameters.get<MooseEnum>("fec_type")),
43  _range_dim(parameters.get<int>("range_dim"))
44 {
45 }
46 
47 std::string
49 {
50  const int pdim = getProblemDim();
51  std::string actual_type = _fec_type;
52  if ((_fec_type == "ND" || _fec_type == "RT") && _range_dim != 0 && _range_dim != pdim)
53  {
54  if (_range_dim != 3)
55  mooseError("No " + _fec_type + " finite element collection available for " +
56  std::to_string(_range_dim) + "D vectors in " + std::to_string(pdim) + "D space.");
57  actual_type += "_R" + std::to_string(pdim) + "D";
58  }
59 
60  const char cb = mfem::BasisType::GetChar(getBasis(getParam<std::string>("closed_basis")));
61  const std::string closed_basis(1, cb);
62  const char ob = mfem::BasisType::GetChar(getBasis(getParam<std::string>("open_basis")));
63  const std::string open_basis(1, ob);
64 
65  // This is to get around an MFEM bug where if you pass the full name of the default element type,
66  // it crashes
67  const std::string basis =
68  (closed_basis + open_basis == "Gg" ? "" : "@" + closed_basis + open_basis);
69 
70  return actual_type + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order);
71 }
72 
73 int
75 {
76  if (_fec_type == "H1" || _fec_type == "L2")
77  {
78  return _range_dim == 0 ? getProblemDim() : _range_dim;
79  }
80  else
81  {
82  return 1;
83  }
84 }
85 
86 #endif
MFEMVectorFESpace(const InputParameters &parameters)
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:1155
virtual int getVDim() const override
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...
registerMooseObject("MooseApp", MFEMVectorFESpace)
virtual std::string getFECName() const override
Get the name of the desired FECollection.
int getBasis(const std::string &basis_name) const
Get the quadrature basis enum associated with the given name.
Definition: MFEMFESpace.C:66
const std::string _fec_type
Name of the family of finite element collections to use.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
const int _fec_order
Order of the basis functions in the finite element collection.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
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...
int getProblemDim() const
Returns the dimension of the problem (i.e., the highest dimension of the reference elements in the me...
void ErrorVector unsigned int
Class with common parameters for MFEMVectorFESpace and MFEMScalarFESpace.
const int _range_dim
The number of vector components in the reference space.