LCOV - code coverage report
Current view: top level - src/mfem/fespaces - MFEMVectorFESpace.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31730 (e8b711) with base e0c998 Lines: 44 46 95.7 %
Date: 2025-10-29 16:49:47 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        9958 : MFEMVectorFESpace::validParams()
      18             : {
      19        9958 :   InputParameters params = MFEMSimplifiedFESpace::validParams();
      20       19916 :   params.addClassDescription(
      21             :       "Convenience class to construct vector finite element spaces, abstracting away some of the "
      22             :       "mathematical complexity of specifying the dimensions.");
      23       39832 :   MooseEnum fec_types("H1 ND RT L2", "H1");
      24       39832 :   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       39832 :                                "GaussLobatto");
      27       39832 :   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       39832 :                         "GaussLegendre");
      33       39832 :   params.addParam<MooseEnum>(
      34             :       "open_basis", basis_types, "Specifies the open basis used for ND and RT elements.");
      35       19916 :   basis_types = "GaussLobatto";
      36       39832 :   params.addParam<MooseEnum>(
      37             :       "basis",
      38             :       basis_types,
      39             :       "Specifies the basis used for H1 and L2 vector elements. H1 spaces require a closed basis "
      40             :       "(GaussLobatto Positive ClosedUniform Serendipity ClosedGL)");
      41       19916 :   params.addParam<int>("range_dim",
      42       19916 :                        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       19916 :   return params;
      48        9958 : }
      49             : 
      50         363 : MFEMVectorFESpace::MFEMVectorFESpace(const InputParameters & parameters)
      51             :   : MFEMSimplifiedFESpace(parameters),
      52         363 :     _fec_type(getParam<MooseEnum>("fec_type")),
      53        1089 :     _range_dim(getParam<int>("range_dim"))
      54             : {
      55         363 : }
      56             : 
      57             : std::string
      58         363 : MFEMVectorFESpace::getFECName() const
      59             : {
      60         363 :   const int pdim = getProblemDim();
      61         363 :   std::string actual_type = _fec_type;
      62         363 :   if ((_fec_type == "ND" || _fec_type == "RT") && _range_dim != 0 && _range_dim != pdim)
      63             :   {
      64          24 :     if (_range_dim != 3)
      65         112 :       mooseError("No  " + _fec_type + " finite element collection available for " +
      66         144 :                  std::to_string(_range_dim) + "D vectors in " + std::to_string(pdim) + "D space.");
      67           8 :     actual_type += "_R" + std::to_string(pdim) + "D";
      68             :   }
      69             : 
      70         347 :   std::string basis = _fec_type == "L2" ? "_T" : "@";
      71             : 
      72         347 :   if (_fec_type == "ND" || _fec_type == "RT")
      73             :   {
      74         810 :     if (isParamSetByUser("basis"))
      75           0 :       mooseWarning("basis parameter ignored, using closed_basis/open_basis parameters instead");
      76         540 :     basis += mfem::BasisType::GetChar(getParam<MooseEnum>("closed_basis"));
      77         810 :     basis += mfem::BasisType::GetChar(getParam<MooseEnum>("open_basis"));
      78             :   }
      79          77 :   else if (_fec_type == "H1" || _fec_type == "L2")
      80             :   {
      81         385 :     if (isParamSetByUser("closed_basis") || isParamSetByUser("open_basis"))
      82           0 :       mooseWarning("closed_basis/open_basis parameter ignored, using basis parameter instead");
      83          77 :     basis += _fec_type == "L2"
      84         295 :                  ? std::to_string(getParam<MooseEnum>("basis"))
      85         244 :                  : std::string({mfem::BasisType::GetChar(getParam<MooseEnum>("basis"))});
      86             :   }
      87             : 
      88             :   // This is to get around an MFEM bug (to be removed in #31525)
      89        1007 :   basis = (basis == "@Gg" || basis == "@G" || basis == "_T0") ? "" : basis;
      90             : 
      91         694 :   return actual_type + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order);
      92         363 : }
      93             : 
      94             : int
      95         363 : MFEMVectorFESpace::getVDim() const
      96             : {
      97         363 :   if (_fec_type == "H1" || _fec_type == "L2")
      98             :   {
      99          77 :     return _range_dim == 0 ? getProblemDim() : _range_dim;
     100             :   }
     101             :   else
     102             :   {
     103         286 :     return 1;
     104             :   }
     105             : }
     106             : 
     107             : #endif

Generated by: LCOV version 1.14