LCOV - code coverage report
Current view: top level - include/limiters - MinModLimiter.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 7 10 70.0 %
Date: 2025-07-17 01:28:37 Functions: 4 12 33.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             : #pragma once
      11             : 
      12             : #include "Limiter.h"
      13             : #include "MathFVUtils.h"
      14             : 
      15             : namespace Moose
      16             : {
      17             : namespace FV
      18             : {
      19             : /**
      20             :  * The Min-Mod limiter function $\beta(r_f)$ is defined as:
      21             :  *
      22             :  * \f[
      23             :  * \beta(r_f) = \text{max}(0, \text{min}(1, r_f))
      24             :  * \f]
      25             :  *
      26             :  * where \( r_f \) is the ratio of the upwind to downwind gradients.
      27             :  *
      28             :  * @tparam T The data type of the scalar values and the return type.
      29             :  */
      30             : template <typename T>
      31             : class MinModLimiter : public Limiter<T>
      32             : {
      33             : public:
      34             :   /**
      35             :    * This method overrides the pure virtual `limit` method in the base `Limiter` class.
      36             :    * It calculates the flux limiting ratio based on the Min-Mod limiter formula.
      37             :    *
      38             :    * @param grad_phi_upwind Pointer to the gradient vector at the upwind location.
      39             :    * @param grad_phi_downwind Pointer to the gradient vector at the downwind location.
      40             :    * @param dCD A constant direction vector representing the direction of the cell face.
      41             :    * @return The computed flux limiting ratio.
      42             :    */
      43      710213 :   T limit(const T & phi_upwind,
      44             :           const T & phi_downwind,
      45             :           const VectorValue<T> * grad_phi_upwind,
      46             :           const VectorValue<T> * grad_phi_downwind,
      47             :           const RealVectorValue & dCD,
      48             :           const Real & /* max_value */,
      49             :           const Real & /* min_value */,
      50             :           const FaceInfo * /* fi */,
      51             :           const bool & /* fi_elem_is_upwind */) const override final
      52             :   {
      53             :     mooseAssert(grad_phi_upwind, "min-mod limiter requires a gradient");
      54             : 
      55             :     // Compute gradient ratio coefficient
      56      710213 :     T r_f;
      57      710213 :     if (grad_phi_downwind) // compute full slope-reconstruction limiter
      58      710213 :       r_f = this->rf_grad(grad_phi_upwind, grad_phi_downwind, dCD);
      59             :     else // compute upwind slope reconstruction limiter
      60           0 :       r_f = Moose::FV::rF(phi_upwind, phi_downwind, *grad_phi_upwind, dCD);
      61             : 
      62             :     // Return limiter value
      63     1420426 :     return 0 * r_f + std::max(T(0), std::min(T(1), r_f));
      64      710213 :   }
      65             : 
      66           0 :   bool constant() const override final { return false; }
      67             : 
      68           0 :   InterpMethod interpMethod() const override final { return InterpMethod::MinMod; }
      69             : 
      70      710276 :   MinModLimiter() = default;
      71             : };
      72             : }
      73             : }

Generated by: LCOV version 1.14