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 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 : 19 : registerMooseObject("MooseApp", MFEMVariable); 20 : 21 : InputParameters 22 10876 : MFEMVariable::validParams() 23 : { 24 10876 : InputParameters params = MFEMGeneralUserObject::validParams(); 25 : // Create user-facing 'boundary' input for restricting inheriting object to boundaries. 26 32628 : params.addRequiredParam<UserObjectName>("fespace", 27 : "The finite element space this variable is defined on."); 28 : // Require moose variable parameters (not used!) 29 10876 : params += MooseVariableBase::validParams(); 30 21752 : params.addClassDescription( 31 : "Class for adding MFEM variables to the problem (`mfem::ParGridFunction`s)."); 32 21752 : params.registerBase("MooseVariableBase"); 33 32628 : params.addParam<VariableName>( 34 : "time_derivative", 35 : "Optional name to assign to the time derivative of the variable in transient problems."); 36 10876 : return params; 37 0 : } 38 : 39 879 : MFEMVariable::MFEMVariable(const InputParameters & parameters) 40 : : MFEMGeneralUserObject(parameters), 41 879 : _fespace(getUserObject<MFEMFESpace>("fespace")), 42 879 : _gridfunction(buildGridFunction()), 43 887 : _time_derivative_name( 44 2637 : isParamValid("time_derivative") 45 879 : ? getParam<VariableName>("time_derivative") 46 : : VariableName( 47 871 : getMFEMProblem().getProblemData().time_derivative_map.createTimeDerivativeName( 48 1750 : name()))) 49 : { 50 879 : *_gridfunction = 0.0; 51 879 : } 52 : 53 : const std::shared_ptr<mfem::ParGridFunction> 54 879 : MFEMVariable::buildGridFunction() 55 : { 56 879 : return std::make_shared<mfem::ParGridFunction>(_fespace.getFESpace().get()); 57 : } 58 : 59 : #endif