https://mooseframework.inl.gov
MFEMVariable.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 "MFEMVariable.h"
13 #include "MFEMProblem.h"
14 #include "MooseVariableBase.h"
15 #include "libmesh/ignore_warnings.h"
16 #include <mfem.hpp>
17 #include "libmesh/restore_warnings.h"
18 
20 
23 {
25  // Create user-facing 'boundary' input for restricting inheriting object to boundaries.
26  params.addRequiredParam<UserObjectName>("fespace",
27  "The finite element space this variable is defined on.");
28  // Require moose variable parameters (not used!)
30  params.addClassDescription(
31  "Class for adding MFEM variables to the problem (`mfem::ParGridFunction`s).");
32  params.registerBase("MooseVariableBase");
33  params.addParam<VariableName>(
34  "time_derivative",
35  "Optional name to assign to the time derivative of the variable in transient problems.");
36  return params;
37 }
38 
40  : MFEMGeneralUserObject(parameters),
41  _fespace(getUserObject<MFEMFESpace>("fespace")),
42  _gridfunction(buildGridFunction()),
43  _time_derivative_name(
44  isParamValid("time_derivative")
45  ? getParam<VariableName>("time_derivative")
46  : VariableName(
47  getMFEMProblem().getProblemData().time_derivative_map.createTimeDerivativeName(
48  name())))
49 {
50  *_gridfunction = 0.0;
51 }
52 
53 const std::shared_ptr<mfem::ParGridFunction>
55 {
56  return std::make_shared<mfem::ParGridFunction>(_fespace.getFESpace().get());
57 }
58 
59 #endif
static InputParameters validParams()
std::string name(const ElemQuality q)
const MFEMFESpace & _fespace
Definition: MFEMVariable.h:37
static InputParameters validParams()
registerMooseObject("MooseApp", MFEMVariable)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::shared_ptr< mfem::ParGridFunction > _gridfunction
Stores the constructed gridfunction.
Definition: MFEMVariable.h:44
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
Constructs and stores an mfem::ParGridFunction object.
Definition: MFEMVariable.h:20
MFEMVariable(const InputParameters &parameters)
Definition: MFEMVariable.C:39
This class adds a getMFEMProblem method.
const std::shared_ptr< mfem::ParGridFunction > buildGridFunction()
Constructs the gridfunction.
Definition: MFEMVariable.C:54
Constructs and stores an mfem::ParFiniteElementSpace object.
Definition: MFEMFESpace.h:22
static InputParameters validParams()
Definition: MFEMVariable.C:22
std::shared_ptr< mfem::ParFiniteElementSpace > getFESpace() const
Returns a shared pointer to the constructed fespace.
Definition: MFEMFESpace.h:38