LCOV - code coverage report
Current view: top level - include/mfem/integrators - ScaleIntegrator.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 9 10 90.0 %
Date: 2026-05-29 20:35:17 Functions: 3 3 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 "libmesh/ignore_warnings.h"
      15             : #include "mfem/miniapps/common/pfem_extras.hpp"
      16             : #include "libmesh/restore_warnings.h"
      17             : 
      18             : #include "MooseError.h"
      19             : 
      20             : namespace Moose::MFEM
      21             : {
      22             : 
      23             : /// Integrator which scales its results by a constant value
      24             : class ScaleIntegrator : public mfem::BilinearFormIntegrator
      25             : {
      26             : private:
      27             :   mfem::BilinearFormIntegrator * _integrator{nullptr};
      28             :   mfem::real_t _scale;
      29             :   bool _own_integrator;
      30             : 
      31             : public:
      32             :   ScaleIntegrator(mfem::BilinearFormIntegrator * integ)
      33             :     : _integrator{integ}, _scale{1}, _own_integrator{true}
      34             :   {
      35             :   }
      36           4 :   ScaleIntegrator(mfem::BilinearFormIntegrator * integ, mfem::real_t scale)
      37           4 :     : _integrator{integ}, _scale{scale}, _own_integrator{true}
      38             :   {
      39           4 :   }
      40        1086 :   ScaleIntegrator(mfem::BilinearFormIntegrator * integ, mfem::real_t scale, bool own)
      41        1086 :     : _integrator{integ}, _scale{scale}, _own_integrator{own}
      42             :   {
      43        1086 :   }
      44             : 
      45             :   void SetIntegrator(mfem::BilinearFormIntegrator * integ)
      46             :   {
      47             :     if (_integrator && _own_integrator)
      48             :     {
      49             :       delete _integrator;
      50             :     }
      51             : 
      52             :     _integrator = integ;
      53             :   }
      54             : 
      55             :   void SetScale(mfem::real_t scale) { _scale = scale; }
      56             : 
      57             :   void SetOwn(bool own) { _own_integrator = own; }
      58             : 
      59     1555464 :   void CheckIntegrator()
      60             :   {
      61     1555464 :     if (!_integrator)
      62           0 :       mooseError("Integrator not set");
      63     1555464 :   }
      64             : 
      65             :   virtual void SetIntRule(const mfem::IntegrationRule * ir) override;
      66             : 
      67             :   virtual void AssembleElementMatrix(const mfem::FiniteElement & el,
      68             :                                      mfem::ElementTransformation & Trans,
      69             :                                      mfem::DenseMatrix & elmat) override;
      70             :   virtual void AssembleElementMatrix2(const mfem::FiniteElement & trial_fe,
      71             :                                       const mfem::FiniteElement & test_fe,
      72             :                                       mfem::ElementTransformation & Trans,
      73             :                                       mfem::DenseMatrix & elmat) override;
      74             : 
      75             :   using mfem::BilinearFormIntegrator::AssembleFaceMatrix;
      76             :   virtual void AssembleFaceMatrix(const mfem::FiniteElement & el1,
      77             :                                   const mfem::FiniteElement & el2,
      78             :                                   mfem::FaceElementTransformations & Trans,
      79             :                                   mfem::DenseMatrix & elmat) override;
      80             : 
      81             :   using mfem::BilinearFormIntegrator::AssemblePA;
      82             :   virtual void AssemblePA(const mfem::FiniteElementSpace & fes) override;
      83             : 
      84             :   virtual void AssembleDiagonalPA(mfem::Vector & diag) override;
      85             : 
      86             :   virtual void AssemblePAInteriorFaces(const mfem::FiniteElementSpace & fes) override;
      87             : 
      88             :   virtual void AssemblePABoundaryFaces(const mfem::FiniteElementSpace & fes) override;
      89             : 
      90             :   virtual void AddMultTransposePA(const mfem::Vector & x, mfem::Vector & y) const override;
      91             : 
      92             :   virtual void AddMultPA(const mfem::Vector & x, mfem::Vector & y) const override;
      93             : 
      94             :   virtual void
      95             :   AssembleEA(const mfem::FiniteElementSpace & fes, mfem::Vector & emat, const bool add) override;
      96             : 
      97             :   virtual void AssembleEABoundary(const mfem::FiniteElementSpace & fes,
      98             :                                   mfem::Vector & emat,
      99             :                                   const bool add) override;
     100             : 
     101             :   virtual void AssembleMF(const mfem::FiniteElementSpace & fes) override;
     102             : 
     103             :   virtual void AddMultMF(const mfem::Vector & x, mfem::Vector & y) const override;
     104             : 
     105             :   virtual void AssembleDiagonalMF(mfem::Vector & diag) override;
     106             : 
     107             :   virtual ~ScaleIntegrator();
     108             : };
     109             : } // namespace Moose::MFEM
     110             : 
     111             : #endif

Generated by: LCOV version 1.14