https://mooseframework.inl.gov
FVAdvectedMinmodWeightBased.C
Go to the documentation of this file.
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 
11 
12 #include "MathFVUtils.h"
13 
14 #include <algorithm>
15 #include <limits>
16 
18 
21 {
23  params.addClassDescription(
24  "Minmod interpolation for advected quantities implemented as limited blending weights "
25  "(no MUSCL reconstruction, no deferred correction).");
26  params.addParam<bool>(
27  "limit_to_linear",
28  true,
29  "Whether to limit the scheme to be no more downwind-biased than linear interpolation.");
30  params.addRangeCheckedParam<Real>(
31  "blending_factor",
32  1.0,
33  "blending_factor>=0 & blending_factor<=1",
34  "Scales the high-order blending strength; 0 gives pure upwind, 1 gives the full limited "
35  "blending. Values < 1 can improve linear solver robustness for fully implicit assembly.");
36  return params;
37 }
38 
40  : FVInterpolationMethod(params),
41  _limit_to_linear(getParam<bool>("limit_to_linear")),
42  _blending_factor(getParam<Real>("blending_factor"))
43 {
44 }
45 
48  Real elem_value,
49  Real neighbor_value,
50  const VectorValue<Real> * elem_grad,
51  const VectorValue<Real> * neighbor_grad,
52  Real mass_flux) const
53 {
54  mooseAssert(elem_grad && neighbor_grad,
55  "Minmod advected interpolation requires both element and neighbor gradients.");
56 
57  const bool upwind_is_elem = mass_flux >= 0.0;
58 
59  const Real phi_upwind = upwind_is_elem ? elem_value : neighbor_value;
60  const Real phi_downwind = upwind_is_elem ? neighbor_value : elem_value;
61 
62  const VectorValue<Real> grad_upwind = upwind_is_elem ? *elem_grad : *neighbor_grad;
63  const Point upwind_to_downwind = upwind_is_elem ? face.dCN() : Point(-face.dCN());
64 
65  const auto r_f = Moose::FV::rF(phi_upwind, phi_downwind, grad_upwind, upwind_to_downwind);
66  const Real beta = std::max(Real(0.0), std::min(Real(1.0), r_f));
67 
68  // Geometric weight associated with the upwind cell for this face.
69  const Real w_f = upwind_is_elem ? face.gC() : (1.0 - face.gC());
70 
71  // Use a Greenshields-style blending:
72  // phi_f = (1-g)*phi_upwind + g*phi_downwind, where g = beta*(1-w_f)
73  const Real g_unclamped = _blending_factor * beta * (1.0 - w_f);
74  const Real g_clamped = std::min(std::max(g_unclamped, 0.0), 1.0 - w_f);
75  // Clamp to [0, 1-w_f] so the weights do not become more downwind-biased than linear.
76  const Real g = _limit_to_linear ? g_clamped : g_unclamped;
77 
78  const Real w_upwind = 1.0 - g;
79  const Real w_downwind = g;
80 
81  // Map (upwind, downwind) weights back to (elem, neighbor) ordering.
82  const Real w_elem = upwind_is_elem ? w_upwind : w_downwind;
83  const Real w_neighbor = upwind_is_elem ? w_downwind : w_upwind;
84 
86  result.weights_matrix = std::make_pair(w_elem, w_neighbor);
87 
88  return result;
89 }
90 
91 Real
93  Real elem_value,
94  Real neighbor_value,
95  const VectorValue<Real> * elem_grad,
96  const VectorValue<Real> * neighbor_grad,
97  Real mass_flux) const
98 {
99  const auto result =
100  advectedInterpolate(face, elem_value, neighbor_value, elem_grad, neighbor_grad, mass_flux);
101  return result.weights_matrix.first * elem_value + result.weights_matrix.second * neighbor_value;
102 }
const bool _limit_to_linear
Whether to clamp the blending to be no more downwind-biased than linear.
Real advectedInterpolateValue(const FaceInfo &face, Real elem_value, Real neighbor_value, const VectorValue< Real > *elem_grad, const VectorValue< Real > *neighbor_grad, Real mass_flux) const override
Compute the advected face value.
registerMooseObject("MooseApp", FVAdvectedMinmodWeightBased)
Scalar rF(const Scalar &phiC, const Scalar &phiD, const Vector &gradC, const RealVectorValue &dCD)
From Moukalled 12.30.
Definition: MathFVUtils.h:448
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Registered base class for linear FV interpolation objects.
const Real _blending_factor
Scales the high-order blending strength (0 = upwind, 1 = full limited blending).
auto max(const L &left, const R &right)
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:37
Minmod interpolation for advected quantities that blends between upwind and the higher-order limited ...
Real gC() const
Return the geometric weighting factor.
Definition: FaceInfo.h:136
AdvectedSystemContribution advectedInterpolate(const FaceInfo &face, Real elem_value, Real neighbor_value, const VectorValue< Real > *elem_grad, const VectorValue< Real > *neighbor_grad, Real mass_flux) const override
Compute the matrix weights for the advected face value.
static InputParameters validParams()
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Matrix/RHS contribution for an advected face interpolation.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
auto min(const L &left, const R &right)
FVAdvectedMinmodWeightBased(const InputParameters &params)
const Point & dCN() const
Definition: FaceInfo.h:142