LCOV - code coverage report
Current view: top level - include/mfem/fespaces - MFEMFESpace.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 8 8 100.0 %
Date: 2026-05-29 20:35:17 Functions: 2 2 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             : #pragma once
      13             : 
      14             : #include "MFEMObject.h"
      15             : 
      16             : /**
      17             :  * Constructs and stores an mfem::ParFiniteElementSpace object. Access using the
      18             :  * getFESpace() accessor.
      19             :  */
      20             : class MFEMFESpace : public MFEMObject
      21             : {
      22             : public:
      23             :   static InputParameters validParams();
      24             : 
      25             :   MFEMFESpace(const InputParameters & parameters);
      26             : 
      27             :   // Note: The simplest way to handle the boilerplate of constructing
      28             :   // FiniteElementCollection and FiniteElementSpace objects in the
      29             :   // base class while deferring their arguments to the subclasses was
      30             :   // to build them after construction was finished. Rather than
      31             :   // requiring the user to call an additional Init() function (which
      32             :   // could easily be forgotten) instead they get built lazily, when
      33             :   // required.
      34             : 
      35             :   /// Returns a shared pointer to the constructed fespace.
      36        6119 :   inline std::shared_ptr<mfem::ParFiniteElementSpace> getFESpace() const
      37             :   {
      38        6119 :     if (!_fespace)
      39        2572 :       buildFESpace();
      40        6103 :     return _fespace;
      41             :   }
      42             : 
      43             :   /// Returns a shared pointer to the constructed fec.
      44        8538 :   inline std::shared_ptr<mfem::FiniteElementCollection> getFEC() const
      45             :   {
      46        8538 :     if (!_fec)
      47        2572 :       buildFEC();
      48        8522 :     return _fec;
      49             :   }
      50             : 
      51             :   virtual bool isScalar() const = 0;
      52             : 
      53             :   virtual bool isVector() const = 0;
      54             : 
      55             : protected:
      56             :   /// Type of ordering of the vector dofs when _vdim > 1.
      57             :   const int _ordering;
      58             : 
      59             :   /// Get the name of the desired FECollection.
      60             :   virtual std::string getFECName() const = 0;
      61             : 
      62             :   /// Get the number of degrees of freedom per basis function needed
      63             :   /// in this finite element space.
      64             :   virtual int getVDim() const = 0;
      65             : 
      66             :   /// Mesh FESpace is defined with respect to. May differ from main problem mesh if
      67             :   /// FESpace is defined on an MFEMSubMesh.
      68             :   mfem::ParMesh & _pmesh;
      69             : 
      70             : private:
      71             :   /// Constructs the fec from the fec name.
      72             :   void buildFEC() const;
      73             :   /// Stores the constructed fecollection
      74             :   mutable std::shared_ptr<mfem::FiniteElementCollection> _fec{nullptr};
      75             : 
      76             :   /// Constructs the fespace.
      77             :   void buildFESpace() const;
      78             :   /// Stores the constructed fespace.
      79             :   mutable std::shared_ptr<mfem::ParFiniteElementSpace> _fespace{nullptr};
      80             : };
      81             : 
      82             : #endif

Generated by: LCOV version 1.14