LCOV - code coverage report
Current view: top level - src/mfem/fespaces - MFEMVectorFESpace.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 34 34 100.0 %
Date: 2025-07-17 01:28:37 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 MFEM_ENABLED
      11             : 
      12             : #include "MFEMVectorFESpace.h"
      13             : 
      14             : registerMooseObject("MooseApp", MFEMVectorFESpace);
      15             : 
      16             : InputParameters
      17        8876 : MFEMVectorFESpace::validParams()
      18             : {
      19        8876 :   InputParameters params = MFEMSimplifiedFESpace::validParams();
      20        8876 :   params.addClassDescription(
      21             :       "Convenience class to construct vector finite element spaces, abstracting away some of the "
      22             :       "mathematical complexity of specifying the dimensions.");
      23        8876 :   MooseEnum fec_types("H1 ND RT L2", "H1", true);
      24        8876 :   params.addParam<MooseEnum>("fec_type", fec_types, "Specifies the family of FE shape functions.");
      25        8876 :   params.addParam<std::string>("closed_basis",
      26             :                                "GaussLobatto",
      27             :                                "Specifies the closed quadrature basis used for vector elements.");
      28        8876 :   params.addParam<std::string>("open_basis",
      29             :                                "GaussLegendre",
      30             :                                "Specifies the open quadrature basis used for vector elements.");
      31       26628 :   params.addParam<int>("range_dim",
      32       17752 :                        0,
      33             :                        "The number of components of the vectors in reference space. Zero "
      34             :                        "(the default) means it will be the same as the problem dimension. "
      35             :                        "Note that MFEM does not currently support 2D vectors in 1D space "
      36             :                        "for ND and RT elements.");
      37       17752 :   return params;
      38        8876 : }
      39             : 
      40         123 : MFEMVectorFESpace::MFEMVectorFESpace(const InputParameters & parameters)
      41             :   : MFEMSimplifiedFESpace(parameters),
      42         123 :     _fec_type(parameters.get<MooseEnum>("fec_type")),
      43         246 :     _range_dim(parameters.get<int>("range_dim"))
      44             : {
      45         123 : }
      46             : 
      47             : std::string
      48         123 : MFEMVectorFESpace::getFECName() const
      49             : {
      50         123 :   const int pdim = getProblemDim();
      51         123 :   std::string actual_type = _fec_type;
      52         123 :   if ((_fec_type == "ND" || _fec_type == "RT") && _range_dim != 0 && _range_dim != pdim)
      53             :   {
      54          12 :     if (_range_dim != 3)
      55          56 :       mooseError("No  " + _fec_type + " finite element collection available for " +
      56          72 :                  std::to_string(_range_dim) + "D vectors in " + std::to_string(pdim) + "D space.");
      57           4 :     actual_type += "_R" + std::to_string(pdim) + "D";
      58             :   }
      59             : 
      60         115 :   const char cb = mfem::BasisType::GetChar(getBasis(getParam<std::string>("closed_basis")));
      61         115 :   const std::string closed_basis(1, cb);
      62         115 :   const char ob = mfem::BasisType::GetChar(getBasis(getParam<std::string>("open_basis")));
      63         115 :   const std::string open_basis(1, ob);
      64             : 
      65             :   // This is to get around an MFEM bug where if you pass the full name of the default element type,
      66             :   // it crashes
      67             :   const std::string basis =
      68         115 :       (closed_basis + open_basis == "Gg" ? "" : "@" + closed_basis + open_basis);
      69             : 
      70         345 :   return actual_type + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order);
      71         123 : }
      72             : 
      73             : int
      74         123 : MFEMVectorFESpace::getVDim() const
      75             : {
      76         123 :   if (_fec_type == "H1" || _fec_type == "L2")
      77             :   {
      78          40 :     return _range_dim == 0 ? getProblemDim() : _range_dim;
      79             :   }
      80             :   else
      81             :   {
      82          83 :     return 1;
      83             :   }
      84             : }
      85             : 
      86             : #endif

Generated by: LCOV version 1.14