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 MFEM_ENABLED
11 
12 #include "MFEMVariable.h"
13 #include "MooseVariableBase.h"
14 #include "libmesh/ignore_warnings.h"
15 #include <mfem.hpp>
16 #include "libmesh/restore_warnings.h"
17 
19 
22 {
24  // Create user-facing 'boundary' input for restricting inheriting object to boundaries.
25  params.addRequiredParam<UserObjectName>("fespace",
26  "The finite element space this variable is defined on.");
27  // Require moose variable parameters (not used!)
29  params.addClassDescription(
30  "Class for adding MFEM variables to the problem (`mfem::ParGridFunction`s).");
31  params.registerBase("MooseVariableBase");
32  return params;
33 }
34 
36  : MFEMGeneralUserObject(parameters),
37  _fespace(getUserObject<MFEMFESpace>("fespace")),
38  _gridfunction(buildGridFunction())
39 {
40  *_gridfunction = 0.0;
41 }
42 
43 const std::shared_ptr<mfem::ParGridFunction>
45 {
46  return std::make_shared<mfem::ParGridFunction>(_fespace.getFESpace().get());
47 }
48 
49 #endif
static InputParameters validParams()
const MFEMFESpace & _fespace
Definition: MFEMVariable.h:34
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:41
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:35
const std::shared_ptr< mfem::ParGridFunction > buildGridFunction()
Constructs the gridfunction.
Definition: MFEMVariable.C:44
Constructs and stores an mfem::ParFiniteElementSpace object.
Definition: MFEMFESpace.h:22
static InputParameters validParams()
Definition: MFEMVariable.C:21
std::shared_ptr< mfem::ParFiniteElementSpace > getFESpace() const
Returns a shared pointer to the constructed fespace.
Definition: MFEMFESpace.h:38