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 SOU limiter is used for reproducing the second-order-upwind scheme. The limiter function 21 : * $\beta(delta_max)$ is defined as: 22 : * 23 : * \f[ 24 : * \beta(delta_max) = min(1, delta_face/delta_max) 25 : * \f] 26 : * 27 : * where: 28 : * \( delta_max \) is the maximum variation admited for the computatioanl stencil 29 : * \( delta_max \) is the variation at the face computed with SOU 30 : * 31 : * @tparam T The data type of the scalar values and the return type. 32 : */ 33 : template <typename T> 34 : class SOULimiter : public Limiter<T> 35 : { 36 : public: 37 : /** 38 : * This method overrides the pure virtual `limit` method in the base `Limiter` class. 39 : * It calculates the flux limiting ratio based on the SOU limiter formula. 40 : * 41 : * @param grad_phi_upwind Pointer to the gradient vector at the upwind location. 42 : * @param grad_phi_downwind Pointer to the gradient vector at the downwind location. 43 : * @param dCD A constant direction vector representing the direction of the cell face. 44 : * @param max_value The maximum value in the current element. 45 : * @param min_value The minimum value in the current element. 46 : * @param fi Pointer to the face information structure. 47 : * @param fi_elem_is_upwind Boolean flag indicating if the current element is upwind. 48 : * @return The computed flux limiting ratio. 49 : */ 50 523563 : T limit(const T & /* phi_upwind */, 51 : const T & /* phi_downwind */, 52 : const VectorValue<T> * grad_phi_upwind, 53 : const VectorValue<T> * /* grad_phi_downwind */, 54 : const RealVectorValue & dCD, 55 : const Real & max_value, 56 : const Real & min_value, 57 : const FaceInfo * /* fi */, 58 : const bool & /*fi_elem_is_upwind */) const override final 59 : { 60 : mooseAssert(grad_phi_upwind, "SOU limiter requires a gradient"); 61 : 62 523563 : T delta_face = std::abs((*grad_phi_upwind) * dCD); 63 523563 : T delta_max = std::abs(max_value - min_value); 64 : 65 523563 : if (delta_face > 1e-10) 66 1029546 : return std::min(1.0, delta_max / delta_face); 67 : else 68 17568 : return T(1.0); 69 523551 : } 70 : 71 0 : bool constant() const override final { return false; } 72 : 73 0 : InterpMethod interpMethod() const override final { return InterpMethod::SOU; } 74 : 75 523626 : SOULimiter() = default; 76 : }; 77 : } 78 : }