https://mooseframework.inl.gov
MFEMScalarFESpace.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 MFEM_ENABLED
11 
12 #include "MFEMScalarFESpace.h"
13 
15 
18 {
20  params.addClassDescription("Convenience class to construct scalar finite element spaces.");
21  MooseEnum fec_types("H1 L2", "H1", true);
22  params.addParam<MooseEnum>("fec_type", fec_types, "Specifies the family of FE shape functions.");
23  params.addParam<std::string>(
24  "basis", "GaussLobatto", "Specifies the quadrature basis used for scalar elements.");
25 
26  return params;
27 }
28 
30  : MFEMSimplifiedFESpace(parameters), _fec_type(parameters.get<MooseEnum>("fec_type"))
31 {
32 }
33 
34 std::string
36 {
37  const char b = mfem::BasisType::GetChar(getBasis(getParam<std::string>("basis")));
38  std::string basis(1, b);
39 
40  // This is to get around an MFEM bug where if you pass the full name of the default element type,
41  // it crashes
42  if (_fec_type == "H1")
43  basis = (basis == "G" ? "" : "@" + basis);
44  else if (_fec_type == "L2")
45  {
46  if (basis != "g")
47  mooseInfo("L2 finite element space only supports GaussLegendre basis. Ignoring " +
48  getParam<std::string>("basis") +
49  " basis choice and using GaussLegendre instead.\n");
50 
51  basis = "";
52  }
53 
54  return _fec_type + basis + "_" + std::to_string(getProblemDim()) + "D_P" +
55  std::to_string(_fec_order);
56 }
57 
58 int
60 {
61  return 1;
62 }
63 
64 #endif
registerMooseObject("MooseApp", MFEMScalarFESpace)
virtual int getVDim() const override
Get the number of degrees of freedom per basis function needed in this finite element space...
void mooseInfo(Args &&... args) const
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
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
int getBasis(const std::string &basis_name) const
Get the quadrature basis enum associated with the given name.
Definition: MFEMFESpace.C:66
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
MFEMScalarFESpace(const InputParameters &parameters)
const int _fec_order
Order of the basis functions in the finite element collection.
virtual std::string getFECName() const override
Get the name of the desired FECollection.
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...
const std::string _fec_type
Name of the family of finite element collections to use.
int getProblemDim() const
Returns the dimension of the problem (i.e., the highest dimension of the reference elements in the me...
Class with common parameters for MFEMVectorFESpace and MFEMScalarFESpace.