LCOV - code coverage report
Current view: top level - include/mfem/functions - MFEMQuadratureFunctionCoefficientBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 13 13 100.0 %
Date: 2026-07-23 16:15:30 Functions: 5 6 83.3 %
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 "MooseEnum.h"
      15             : #include <string>
      16             : 
      17             : namespace mfem
      18             : {
      19             : class QuadratureFunction;
      20             : class ElementTransformation;
      21             : class IntegrationPoint;
      22             : }
      23             : 
      24             : /**
      25             :  * Shared lazy-update state for quadrature function coefficients. Holds the update policy and a
      26             :  * dirty flag marking whether the stored quadrature point values are stale and must be
      27             :  * re-projected from the source coefficient before use. Provides a common polymorphic type so
      28             :  * that scalar and vector quadrature function coefficients can be invalidated uniformly.
      29             :  */
      30             : class MFEMQuadratureFunctionCoefficientBase
      31             : {
      32             : public:
      33             :   /**
      34             :    *  Policy controlling when the stored values are re-projected from the source coefficient.
      35             :    *  NONE - the source never changes after initialization; project exactly once.
      36             :    *  TIME - the source changes with time only; re-project when the time is set.
      37             :    *  NONLINEAR - the source may additionally depend on solution variables; also re-project
      38             :    *  whenever trial variables are updated (i.e. on each nonlinear iteration).
      39             :    */
      40       47520 :   CreateMooseEnumClass(UpdatePolicy, NONE, TIME, NONLINEAR);
      41             : 
      42          34 :   MFEMQuadratureFunctionCoefficientBase(UpdatePolicy update_policy, const std::string & name)
      43          34 :     : _update_policy(update_policy), _name(name), _dirty(true)
      44             :   {
      45          34 :   }
      46             : 
      47          32 :   virtual ~MFEMQuadratureFunctionCoefficientBase() = default;
      48             : 
      49             :   /// Mark the stored values as stale following a change of solution variables, forcing the
      50             :   /// source to be re-projected on next use.
      51         632 :   void MarkSolutionChanged()
      52             :   {
      53         632 :     if (_update_policy == UpdatePolicy::NONLINEAR)
      54         619 :       _dirty = true;
      55         632 :   }
      56             : 
      57             : protected:
      58             :   /// Mark the stored values as stale following a change of time.
      59         300 :   void MarkTimeChanged()
      60             :   {
      61         300 :     if (_update_policy != UpdatePolicy::NONE)
      62         300 :       _dirty = true;
      63         300 :   }
      64             : 
      65             :   /// Verify that the integration point @a ip supplied by a consuming integrator belongs to the
      66             :   /// same quadrature rule the values in @a qf are stored on. Errors, naming the quadrature order
      67             :   /// the coefficient should use, if the rules do not match. The stored values are indexed by
      68             :   /// quadrature point, so a mismatched rule would silently read values from the wrong points.
      69             :   void CheckIntegrationRule(const mfem::QuadratureFunction & qf,
      70             :                             mfem::ElementTransformation & T,
      71             :                             const mfem::IntegrationPoint & ip) const;
      72             : 
      73             :   /// When the stored values are re-projected from the source coefficient.
      74             :   const UpdatePolicy _update_policy;
      75             :   /// Name of the owning MOOSE object, used in error messages.
      76             :   const std::string _name;
      77             :   /// Whether the stored values are stale and must be re-projected before use.
      78             :   bool _dirty;
      79             : };
      80             : 
      81             : #endif

Generated by: LCOV version 1.14