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 : #include "FVAdvectedVenkatakrishnanDeferredCorrection.h" 11 : 12 : registerMooseObject("MooseApp", FVAdvectedVenkatakrishnanDeferredCorrection); 13 : 14 : InputParameters 15 3763 : FVAdvectedVenkatakrishnanDeferredCorrection::validParams() 16 : { 17 3763 : InputParameters params = FVInterpolationMethod::validParams(); 18 7526 : params.addClassDescription( 19 : "MUSCL reconstruction with Venkatakrishnan-limited cell gradients using deferred " 20 : "correction."); 21 15052 : params.addRangeCheckedParam<Real>( 22 : "deferred_correction_factor", 23 7526 : 1.0, 24 : "deferred_correction_factor>=0 & deferred_correction_factor<=1", 25 : "Scales the deferred correction strength; 0 gives pure upwind (no deferred correction), 1 " 26 : "gives full deferred correction. Values < 1 can improve fixed point robustness."); 27 3763 : return params; 28 0 : } 29 : 30 351 : FVAdvectedVenkatakrishnanDeferredCorrection::FVAdvectedVenkatakrishnanDeferredCorrection( 31 351 : const InputParameters & params) 32 : : FVInterpolationMethod(params), 33 702 : _deferred_correction_factor(getParam<Real>("deferred_correction_factor")) 34 : { 35 351 : } 36 : 37 : FVAdvectedInterpolationMethod::AdvectedSystemContribution 38 14008269 : FVAdvectedVenkatakrishnanDeferredCorrection::advectedInterpolate( 39 : const FaceInfo & face, 40 : const Real elem_value, 41 : const Real neighbor_value, 42 : const VectorValue<Real> * const elem_grad, 43 : const VectorValue<Real> * const neighbor_grad, 44 : const Real mass_flux) const 45 : { 46 : mooseAssert(elem_grad && neighbor_grad, 47 : "Venkatakrishnan deferred correction requires both element and neighbor gradients."); 48 : 49 14008269 : const bool upwind_is_elem = mass_flux >= 0.0; 50 14008269 : const Real phi_upwind = upwind_is_elem ? elem_value : neighbor_value; 51 14008269 : const VectorValue<Real> * grad_upwind = upwind_is_elem ? elem_grad : neighbor_grad; 52 : 53 : // Reconstruct a higher-order face value from the upwind cell using the (limited) cell gradient. 54 14008269 : const Point & upwind_centroid = upwind_is_elem ? face.elemCentroid() : face.neighborCentroid(); 55 : // For the Venkatakrishnan MUSCL scheme we reconstruct to the actual face centroid. 56 14008269 : const Point face_delta = face.faceCentroid() - upwind_centroid; 57 : 58 14008269 : const Real phi_high = phi_upwind + (*grad_upwind * face_delta); 59 : 60 14008269 : AdvectedSystemContribution result; 61 : // Matrix contribution: pure upwind. 62 14008269 : result.weights_matrix = upwind_is_elem ? std::make_pair(1.0, 0.0) : std::make_pair(0.0, 1.0); 63 : 64 14008269 : const Real phi_matrix = 65 14008269 : result.weights_matrix.first * elem_value + result.weights_matrix.second * neighbor_value; 66 : // Deferred correction: add the difference between low-order and high-order reconstructions 67 : // explicitly on the RHS (scaled for robustness). 68 14008269 : result.rhs_face_value = _deferred_correction_factor * (phi_matrix - phi_high); 69 : 70 28016538 : return result; 71 : }