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 QUICK (Quadratic Upstream Interpolation for Convective Kinematics) limiter 21 : * function is derived from the following equations: 22 : * 23 : * 1. Calculation of the gradient ratio coefficient \( r_f \): 24 : * \f[ 25 : * r_f = \begin{cases} 26 : * \text{if grad\_phi\_downwind is not null, use } \text{rf\_grad}(\nabla \phi_{\text{upwind}}, 27 : * \nabla \phi_{\text{downwind}}, \mathbf{dCD}) \\ \text{otherwise, use } 28 : * \text{rF}(\phi_{\text{upwind}}, \phi_{\text{downwind}}, \nabla \phi_{\text{upwind}}, 29 : * \mathbf{dCD}) \end{cases} \f] 30 : * 31 : * 2. QUICK limiter formula ensuring TVD compliance: 32 : * \f[ 33 : * \beta(r_f) = \min\left(\beta, \max\left(\min\left(\min\left(\frac{1 + 3.0 r_f}{4.0}, 2.0 34 : * r_f\right), 2.0\right), 0.0\right)\right) \f] where \(\beta = 1.0\). 35 : * 36 : * @tparam T The data type of the scalar values and the return type. 37 : */ 38 : template <typename T> 39 : class QUICKLimiter : public Limiter<T> 40 : { 41 : public: 42 : /** 43 : * This method overrides the pure virtual `limit` method in the base `Limiter` class. 44 : * It calculates the flux limiting ratio based on the QUICK limiter formula. 45 : * 46 : * @param phi_upwind Scalar value at the upwind location. 47 : * @param phi_downwind Scalar value at the downwind location. 48 : * @param grad_phi_upwind Pointer to the gradient vector at the upwind location. 49 : * @param grad_phi_downwind Pointer to the gradient vector at the downwind location. 50 : * @param dCD A constant direction vector representing the direction of the cell face. 51 : * @return The computed flux limiting ratio. 52 : */ 53 705320 : T limit(const T & phi_upwind, 54 : const T & phi_downwind, 55 : const VectorValue<T> * grad_phi_upwind, 56 : const VectorValue<T> * grad_phi_downwind, 57 : const RealVectorValue & dCD, 58 : const Real & /* max_value */, 59 : const Real & /* min_value */, 60 : const FaceInfo * /* fi */, 61 : const bool & /* fi_elem_is_upwind */) const override final 62 : { 63 : mooseAssert(grad_phi_upwind, "QUICK limiter requires a gradient"); 64 : 65 : // Compute gradient ratio coefficient 66 705320 : T limiter; 67 705320 : if (grad_phi_downwind) // compute full slope-reconstruction limiter for weakly-compressible flow 68 : { 69 705320 : const auto & r_f = this->rf_grad(grad_phi_upwind, grad_phi_downwind, dCD); 70 705320 : const auto & beta = T(1.0); // Ensures TVD compliance 71 2115960 : limiter = 72 1410640 : 0 * r_f + 73 0 : std::min(beta, 74 1410640 : std::max(std::min(std::min((1 + 3.0 * r_f) / 4.0, 2.0 * r_f), T(2.0)), T(0.0))); 75 705320 : } 76 : else // compute upwind slope reconstruction limiter for compressible flow 77 : { 78 0 : const auto & r_f = Moose::FV::rF(phi_upwind, phi_downwind, *grad_phi_upwind, dCD); 79 0 : limiter = (3.0 * r_f) / 4.0; 80 0 : } 81 : 82 : // Return limiter value 83 705320 : return limiter; 84 0 : } 85 : 86 0 : bool constant() const override final { return false; } 87 : 88 0 : InterpMethod interpMethod() const override final { return InterpMethod::QUICK; } 89 : 90 705320 : QUICKLimiter() = default; 91 : }; 92 : } 93 : }