Line data Source code
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 : 18 : registerMooseObject("MooseApp", MFEMVariable); 19 : 20 : InputParameters 21 9106 : MFEMVariable::validParams() 22 : { 23 9106 : InputParameters params = MFEMGeneralUserObject::validParams(); 24 : // Create user-facing 'boundary' input for restricting inheriting object to boundaries. 25 9106 : params.addRequiredParam<UserObjectName>("fespace", 26 : "The finite element space this variable is defined on."); 27 : // Require moose variable parameters (not used!) 28 9106 : params += MooseVariableBase::validParams(); 29 9106 : params.addClassDescription( 30 : "Class for adding MFEM variables to the problem (`mfem::ParGridFunction`s)."); 31 9106 : params.registerBase("MooseVariableBase"); 32 9106 : return params; 33 0 : } 34 : 35 250 : MFEMVariable::MFEMVariable(const InputParameters & parameters) 36 : : MFEMGeneralUserObject(parameters), 37 250 : _fespace(getUserObject<MFEMFESpace>("fespace")), 38 500 : _gridfunction(buildGridFunction()) 39 : { 40 250 : *_gridfunction = 0.0; 41 250 : } 42 : 43 : const std::shared_ptr<mfem::ParGridFunction> 44 250 : MFEMVariable::buildGridFunction() 45 : { 46 500 : return std::make_shared<mfem::ParGridFunction>(_fespace.getFESpace().get()); 47 : } 48 : 49 : #endif