LCOV - code coverage report
Current view: top level - src/mfem/fespaces - MFEMFESpace.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 909fe5 Lines: 44 53 83.0 %
Date: 2025-08-29 20:01:24 Functions: 5 5 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 "MFEMFESpace.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : InputParameters
      16       27052 : MFEMFESpace::validParams()
      17             : {
      18       27052 :   InputParameters params = MFEMGeneralUserObject::validParams();
      19       54104 :   params.registerBase("MFEMFESpace");
      20      108208 :   MooseEnum ordering("NODES VDIM", "VDIM", false);
      21      108208 :   params.addParam<MooseEnum>("ordering", ordering, "Ordering style to use for vector DoFs.");
      22      108208 :   params.addParam<int>("vdim", 1, "The number of degrees of freedom per basis function.");
      23       81156 :   params.addParam<std::string>("submesh",
      24             :                                "Submesh to define the FESpace on. Leave blank to use base mesh.");
      25       54104 :   return params;
      26       27052 : }
      27             : 
      28         567 : MFEMFESpace::MFEMFESpace(const InputParameters & parameters)
      29             :   : MFEMGeneralUserObject(parameters),
      30         567 :     _ordering(parameters.get<MooseEnum>("ordering")),
      31         567 :     _pmesh(
      32         567 :         parameters.isParamValid("submesh")
      33        1163 :             ? getMFEMProblem().getProblemData().submeshes.GetRef(getParam<std::string>("submesh"))
      34        1672 :             : const_cast<mfem::ParMesh &>(getMFEMProblem().mesh().getMFEMParMesh()))
      35             : {
      36         567 : }
      37             : 
      38             : void
      39         559 : MFEMFESpace::buildFEC(const std::string & fec_name) const
      40             : {
      41         559 :   auto name = fec_name.c_str();
      42             :   // Handle a few cases that were not supported by mfem::FiniteElementCollection::New as of v4.7
      43         559 :   if (!strncmp(name, "RT_R1D", 6))
      44             :   {
      45           1 :     _fec = std::make_shared<mfem::RT_R1D_FECollection>(atoi(name + 11), atoi(name + 7));
      46             :   }
      47         558 :   else if (!strncmp(name, "RT_R2D", 6))
      48             :   {
      49           2 :     _fec = std::make_shared<mfem::RT_R2D_FECollection>(atoi(name + 11), atoi(name + 7));
      50             :   }
      51         556 :   else if (!strncmp(name, "ND_R1D", 6))
      52             :   {
      53           2 :     _fec = std::make_shared<mfem::ND_R1D_FECollection>(atoi(name + 11), atoi(name + 7));
      54             :   }
      55         554 :   else if (!strncmp(name, "ND_R2D", 6))
      56             :   {
      57           1 :     _fec = std::make_shared<mfem::ND_R2D_FECollection>(atoi(name + 11), atoi(name + 7));
      58             :   }
      59             :   else
      60             :   {
      61         553 :     _fec = std::shared_ptr<mfem::FiniteElementCollection>(mfem::FiniteElementCollection::New(name));
      62             :   }
      63         559 : }
      64             : 
      65             : int
      66         716 : MFEMFESpace::getBasis(const std::string & basis_name) const
      67             : {
      68             : 
      69         716 :   if (!strcmp(basis_name.c_str(), "GaussLegendre"))
      70         181 :     return mfem::BasisType::GaussLegendre;
      71         535 :   else if (!strcmp(basis_name.c_str(), "GaussLobatto"))
      72         518 :     return mfem::BasisType::GaussLobatto;
      73          17 :   else if (!strcmp(basis_name.c_str(), "Positive"))
      74           0 :     return mfem::BasisType::Positive;
      75          17 :   else if (!strcmp(basis_name.c_str(), "OpenUniform"))
      76           0 :     return mfem::BasisType::OpenUniform;
      77          17 :   else if (!strcmp(basis_name.c_str(), "ClosedUniform"))
      78           0 :     return mfem::BasisType::ClosedUniform;
      79          17 :   else if (!strcmp(basis_name.c_str(), "OpenHalfUniform"))
      80           0 :     return mfem::BasisType::OpenHalfUniform;
      81          17 :   else if (!strcmp(basis_name.c_str(), "Serendipity"))
      82           0 :     return mfem::BasisType::Serendipity;
      83          17 :   else if (!strcmp(basis_name.c_str(), "ClosedGL"))
      84           0 :     return mfem::BasisType::ClosedGL;
      85          17 :   else if (!strcmp(basis_name.c_str(), "IntegratedGLL"))
      86          17 :     return mfem::BasisType::IntegratedGLL;
      87           0 :   else if (!strcmp(basis_name.c_str(), "NumBasisTypes"))
      88           0 :     return mfem::BasisType::NumBasisTypes;
      89             :   else
      90           0 :     mooseError("Unknown basis type: ", basis_name);
      91             : }
      92             : 
      93             : void
      94         567 : MFEMFESpace::buildFESpace(const int vdim) const
      95             : {
      96             :   _fespace =
      97         567 :       std::make_shared<mfem::ParFiniteElementSpace>(&_pmesh, getFEC().get(), vdim, _ordering);
      98         559 : }
      99             : 
     100             : #endif

Generated by: LCOV version 1.14