LCOV - code coverage report
Current view: top level - src/mfem/fespaces - MFEMVectorFESpace.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 43 45 95.6 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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 "MFEMVectorFESpace.h"
      13             : 
      14             : registerMooseObject("MooseApp", MFEMVectorFESpace);
      15             : 
      16             : InputParameters
      17        4180 : MFEMVectorFESpace::validParams()
      18             : {
      19        4180 :   InputParameters params = MFEMSimplifiedFESpace::validParams();
      20        8360 :   params.addClassDescription(
      21             :       "Convenience class to construct vector finite element spaces, abstracting away some of the "
      22             :       "mathematical complexity of specifying the dimensions.");
      23       16720 :   MooseEnum fec_types("H1 ND RT L2 L2Int", "H1");
      24       16720 :   params.addParam<MooseEnum>("fec_type", fec_types, "Specifies the family of FE shape functions.");
      25             :   MooseEnum closed_basis_types("GaussLobatto=1 ClosedUniform=4 Serendipity=6 ClosedGL=7",
      26       16720 :                                "GaussLobatto");
      27       16720 :   params.addParam<MooseEnum>("closed_basis",
      28             :                              closed_basis_types,
      29             :                              "Specifies the closed basis used for ND and RT elements.");
      30             :   MooseEnum basis_types("GaussLegendre GaussLobatto Positive OpenUniform ClosedUniform "
      31             :                         "OpenHalfUniform Serendipity ClosedGL IntegratedGLL",
      32       16720 :                         "GaussLegendre");
      33       16720 :   params.addParam<MooseEnum>(
      34             :       "open_basis", basis_types, "Specifies the open basis used for ND and RT elements.");
      35        8360 :   basis_types = "GaussLobatto";
      36       16720 :   params.addParam<MooseEnum>(
      37             :       "basis",
      38             :       basis_types,
      39             :       "Specifies the basis used for H1 and L2(Int) vector elements. H1 spaces require a closed "
      40             :       "basis (GaussLobatto Positive ClosedUniform Serendipity ClosedGL)");
      41        8360 :   params.addParam<int>("range_dim",
      42        8360 :                        0,
      43             :                        "The number of components of the vectors in reference space. Zero "
      44             :                        "(the default) means it will be the same as the problem dimension. "
      45             :                        "Note that MFEM does not currently support 2D vectors in 1D space "
      46             :                        "for ND and RT elements.");
      47             : 
      48        8360 :   return params;
      49        4180 : }
      50             : 
      51        1041 : MFEMVectorFESpace::MFEMVectorFESpace(const InputParameters & parameters)
      52             :   : MFEMSimplifiedFESpace(parameters),
      53        1041 :     _fec_type(getParam<MooseEnum>("fec_type")),
      54        3123 :     _range_dim(getParam<int>("range_dim"))
      55             : {
      56        1041 : }
      57             : 
      58             : std::string
      59        1041 : MFEMVectorFESpace::getFECName() const
      60             : {
      61        1041 :   const int pdim = getProblemDim();
      62        1041 :   std::string actual_type = _fec_type;
      63        1041 :   if ((_fec_type == "ND" || _fec_type == "RT") && _range_dim != 0 && _range_dim != pdim)
      64             :   {
      65          24 :     if (_range_dim != 3)
      66         112 :       mooseError("No  " + _fec_type + " finite element collection available for " +
      67         144 :                  std::to_string(_range_dim) + "D vectors in " + std::to_string(pdim) + "D space.");
      68           8 :     actual_type += "_R" + std::to_string(pdim) + "D";
      69             :   }
      70             : 
      71        1025 :   std::string basis = _fec_type == "L2" || _fec_type == "L2Int" ? "_T" : "@";
      72             : 
      73        1025 :   if (_fec_type == "ND" || _fec_type == "RT")
      74             :   {
      75        2301 :     if (isParamSetByUser("basis"))
      76           0 :       mooseWarning("basis parameter ignored, using closed_basis/open_basis parameters instead");
      77        1534 :     basis += mfem::BasisType::GetChar(getParam<MooseEnum>("closed_basis"));
      78        2301 :     basis += mfem::BasisType::GetChar(getParam<MooseEnum>("open_basis"));
      79             :   }
      80         258 :   else if (_fec_type == "H1" || _fec_type == "L2" || _fec_type == "L2Int")
      81             :   {
      82        1290 :     if (isParamSetByUser("closed_basis") || isParamSetByUser("open_basis"))
      83           0 :       mooseWarning("closed_basis/open_basis parameter ignored, using basis parameter instead");
      84         143 :     basis += _fec_type == "L2" || _fec_type == "L2Int"
      85        1076 :                  ? std::to_string(getParam<MooseEnum>("basis"))
      86         754 :                  : std::string({mfem::BasisType::GetChar(getParam<MooseEnum>("basis"))});
      87             :   }
      88             : 
      89        2050 :   return actual_type + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order);
      90        1041 : }
      91             : 
      92             : int
      93        1041 : MFEMVectorFESpace::getVDim() const
      94             : {
      95        1041 :   if (_fec_type == "H1" || _fec_type == "L2" || _fec_type == "L2Int")
      96             :   {
      97         258 :     return _range_dim == 0 ? getProblemDim() : _range_dim;
      98             :   }
      99             :   else
     100             :   {
     101         783 :     return 1;
     102             :   }
     103             : }
     104             : 
     105             : #endif

Generated by: LCOV version 1.14