MFEMVariable

Overview

MFEMVariable defines a finite element variable (mfem::ParGridFunction) with respect to a finite element space created on the problem's mesh. Multiple MFEMVariable objects can be created with respect to the same MFEMFESpace.

When creating an MFEMVariable, a number of auxiliary mfem::Coefficient and mfem::VectorCoefficient classes are declared for ease-of-use when referencing this variable in functions, kernels, and postprocessors.

Specifically for scalar variables, scalar coefficients are added representing:

  • the variable itself, with the same name as the variable name

  • the magnitude of the gradient of the variable (if available), with the suffix _grad_mag

and vector coefficients are added representing

  • the gradient of the variable (if available), with the suffix _grad.

For vector variables, scalar coefficients are added representing:

  • the magnitude of the variable, with the suffix _mag

  • the divergence of the variable (if available), with the suffix _div

  • the magnitude of the curl of the variable (if available), with the suffix _curl_mag

and vector coefficients are added representing

  • the variable itself, with the same name as the variable name

  • the curl of the variable (if available), with the suffix _curl.

Example Input File Syntax

Preferentially, users should create an MFEMVariable with respect to an MFEMFESpace:

[Problem<<<{"href": "../../../syntax/Problem/index.html"}>>>]
  type = MFEMProblem
[]

[FESpaces<<<{"href": "../../../syntax/FESpaces/index.html"}>>>]
  [H1FESpace]
    type = MFEMScalarFESpace<<<{"description": "Convenience class to construct scalar finite element spaces.", "href": "../fespaces/MFEMScalarFESpace.html"}>>>
    fec_type<<<{"description": "Specifies the family of FE shape functions."}>>> = H1
    fec_order<<<{"description": "Order of the FE shape function to use."}>>> = FIRST
  []
  [HCurlFESpace]
    type = MFEMVectorFESpace<<<{"description": "Convenience class to construct vector finite element spaces, abstracting away some of the mathematical complexity of specifying the dimensions.", "href": "../fespaces/MFEMVectorFESpace.html"}>>>
    fec_type<<<{"description": "Specifies the family of FE shape functions."}>>> = ND
    fec_order<<<{"description": "Order of the FE shape function to use."}>>> = FIRST
  []
[]

[Variables<<<{"href": "../../../syntax/Variables/index.html"}>>>]
  [concentration]
    type = MFEMVariable<<<{"description": "Class for adding MFEM variables to the problem (`mfem::ParGridFunction`s).", "href": "MFEMVariable.html"}>>>
    fespace<<<{"description": "The finite element space this variable is defined on."}>>> = H1FESpace
  []
[]
(test/tests/mfem/kernels/diffusion.i)

However, if a user creates a MOOSE variable in an MFEMProblem, then MOOSE should automatically create the corresponding MFEMFESpace and MFEMVariable for that type:

[Problem<<<{"href": "../../../syntax/Problem/index.html"}>>>]
  type = MFEMProblem
[]

[Variables<<<{"href": "../../../syntax/Variables/index.html"}>>>]
  [scalar_var]
    family<<<{"description": "Specifies the family of FE shape functions to use for this variable"}>>> = LAGRANGE
    order<<<{"description": "Specifies the order of the FE shape function to use for this variable (additional orders not listed are allowed)"}>>> = FIRST
  []
  [vector_var]
    family<<<{"description": "Specifies the family of FE shape functions to use for this variable"}>>> = LAGRANGE_VEC
    order<<<{"description": "Specifies the order of the FE shape function to use for this variable (additional orders not listed are allowed)"}>>> = FIRST
  []
[]
(test/tests/mfem/variables/mfem_variables_from_moose.i)

Input Parameters

  • fespaceThe finite element space this variable is defined on.

    C++ Type:MFEMFESpaceName

    Controllable:No

    Description:The finite element space this variable is defined on.

Required Parameters

  • arrayFalseTrue to make this variable a array variable regardless of number of components. If 'components' > 1, this will automatically be set to true.

    Default:False

    C++ Type:bool

    Controllable:No

    Description:True to make this variable a array variable regardless of number of components. If 'components' > 1, this will automatically be set to true.

  • array_var_component_namesOnly for use with array variables, allows setting custom names for each array variable component. If this not set, the default name for each array variable componenet is `base_name`+'_'+component number. If used, a name must be provided for each component and the values are used to name the components as `base_name`+'_'+ `array_var_component_names[component]`.

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:Only for use with array variables, allows setting custom names for each array variable component. If this not set, the default name for each array variable componenet is `base_name`+'_'+component number. If used, a name must be provided for each component and the values are used to name the components as `base_name`+'_'+ `array_var_component_names[component]`.

  • blockThe list of blocks (ids or names) that this object will be applied

    C++ Type:std::vector<SubdomainName>

    Controllable:No

    Description:The list of blocks (ids or names) that this object will be applied

  • components1Number of components for an array variable

    Default:1

    C++ Type:unsigned int

    Range:components>0

    Controllable:No

    Description:Number of components for an array variable

  • disable_p_refinementFalseTrue to disable p-refinement for this variable. Note that because this happens on the family basis, users need to have this flag consistently set for all variables in the same family. Currently MOOSE disables p-refinement for variables in the following families by default: LAGRANGE NEDELEC_ONE RAVIART_THOMAS LAGRANGE_VEC CLOUGH BERNSTEIN and RATIONAL_BERNSTEIN.

    Default:False

    C++ Type:bool

    Controllable:No

    Description:True to disable p-refinement for this variable. Note that because this happens on the family basis, users need to have this flag consistently set for all variables in the same family. Currently MOOSE disables p-refinement for variables in the following families by default: LAGRANGE NEDELEC_ONE RAVIART_THOMAS LAGRANGE_VEC CLOUGH BERNSTEIN and RATIONAL_BERNSTEIN.

  • familyLAGRANGESpecifies the family of FE shape functions to use for this variable

    Default:LAGRANGE

    C++ Type:MooseEnum

    Options:LAGRANGE, MONOMIAL, HERMITE, SCALAR, HIERARCHIC, CLOUGH, XYZ, SZABAB, BERNSTEIN, L2_LAGRANGE, L2_HIERARCHIC, NEDELEC_ONE, LAGRANGE_VEC, MONOMIAL_VEC, RAVIART_THOMAS, RATIONAL_BERNSTEIN, SIDE_HIERARCHIC, L2_HIERARCHIC_VEC, L2_LAGRANGE_VEC, L2_RAVIART_THOMAS

    Controllable:No

    Description:Specifies the family of FE shape functions to use for this variable

  • fvFalseTrue to make this variable a finite volume variable

    Default:False

    C++ Type:bool

    Controllable:No

    Description:True to make this variable a finite volume variable

  • initial_conditionSpecifies a constant initial condition for this variable

    C++ Type:std::vector<double>

    Unit:(no unit assumed)

    Controllable:No

    Description:Specifies a constant initial condition for this variable

  • initial_from_file_varGives the name of a variable for which to read an initial condition from a mesh file

    C++ Type:std::string

    Controllable:No

    Description:Gives the name of a variable for which to read an initial condition from a mesh file

  • orderFIRSTSpecifies the order of the FE shape function to use for this variable (additional orders not listed are allowed)

    Default:FIRST

    C++ Type:MooseEnum

    Options:CONSTANT, FIRST, SECOND, THIRD, FOURTH, FIFTH, SIXTH, SEVENTH, EIGHTH, NINTH, TENTH, ELEVENTH, TWELFTH, THIRTEENTH, FOURTEENTH, FIFTEENTH, SIXTEENTH, SEVENTEENTH, EIGHTTEENTH, NINETEENTH, TWENTIETH, TWENTYFIRST, TWENTYSECOND, TWENTYTHIRD, TWENTYFOURTH, TWENTYFIFTH, TWENTYSIXTH, TWENTYSEVENTH, TWENTYEIGHTH, TWENTYNINTH, THIRTIETH, THIRTYFIRST, THIRTYSECOND, THIRTYTHIRD, THIRTYFOURTH, THIRTYFIFTH, THIRTYSIXTH, THIRTYSEVENTH, THIRTYEIGHTH, THIRTYNINTH, FORTIETH, FORTYFIRST, FORTYSECOND, FORTYTHIRD

    Controllable:No

    Description:Specifies the order of the FE shape function to use for this variable (additional orders not listed are allowed)

  • solver_sysnl0If this variable is a solver variable, this is the solver system to which it should be added.

    Default:nl0

    C++ Type:SolverSystemName

    Controllable:No

    Description:If this variable is a solver variable, this is the solver system to which it should be added.

  • time_derivativeOptional name to assign to the time derivative of the variable in transient problems.

    C++ Type:VariableName

    Unit:(no unit assumed)

    Controllable:No

    Description:Optional name to assign to the time derivative of the variable in transient problems.

Optional Parameters

  • control_tagsAdds user-defined labels for accessing object parameters via control logic.

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:Adds user-defined labels for accessing object parameters via control logic.

  • eigenFalseTrue to make this variable an eigen variable

    Default:False

    C++ Type:bool

    Controllable:No

    Description:True to make this variable an eigen variable

  • enableTrueSet the enabled status of the MooseObject.

    Default:True

    C++ Type:bool

    Controllable:No

    Description:Set the enabled status of the MooseObject.

  • outputsVector of output names where you would like to restrict the output of variables(s) associated with this object

    C++ Type:std::vector<OutputName>

    Controllable:No

    Description:Vector of output names where you would like to restrict the output of variables(s) associated with this object

  • scalingSpecifies a scaling factor to apply to this variable

    C++ Type:std::vector<double>

    Unit:(no unit assumed)

    Controllable:No

    Description:Specifies a scaling factor to apply to this variable

  • use_dualFalseTrue to use dual basis for Lagrange multipliers

    Default:False

    C++ Type:bool

    Controllable:No

    Description:True to use dual basis for Lagrange multipliers

Advanced Parameters

Input Files