https://mooseframework.inl.gov
LinearFVScalarAdvection.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 #include "MooseLinearVariableFV.h"
12 #include "NS.h"
13 
15 
18 {
20  params.addClassDescription("Represents the matrix and right hand side contributions of an "
21  "advection term for a passive scalar.");
22  params.addRequiredParam<UserObjectName>(
23  "rhie_chow_user_object",
24  "The rhie-chow user-object which is used to determine the face velocity.");
25  params.addRequiredParam<InterpolationMethodName>(
26  "advected_interp_method_name",
27  "Name of the FVInterpolationMethod to use for the advected quantity.");
28  params.addParam<MooseFunctorName>("u_slip", "The slip-velocity in the x direction.");
29  params.addParam<MooseFunctorName>("v_slip", "The slip-velocity in the y direction.");
30  params.addParam<MooseFunctorName>("w_slip", "The slip-velocity in the z direction.");
31  return params;
32 }
33 
35  : LinearFVFluxKernel(params),
37  _mass_flux_provider(getUserObject<RhieChowMassFlux>("rhie_chow_user_object")),
38  _adv_interp_method(getFVAdvectedInterpolationMethod(
39  getParam<InterpolationMethodName>("advected_interp_method_name"))),
40  _volumetric_face_flux(0.0),
41  _u_slip(isParamValid("u_slip") ? &getFunctor<ADReal>("u_slip") : nullptr),
42  _v_slip(isParamValid("v_slip") ? &getFunctor<ADReal>("v_slip") : nullptr),
43  _w_slip(isParamValid("w_slip") ? &getFunctor<ADReal>("w_slip") : nullptr),
44  _add_slip_model(isParamValid("u_slip") ? true : false)
45 {
48 }
49 
50 Real
52 {
53  const auto & coeffs = _adv_interp_result.weights_matrix;
54  return coeffs.first * _volumetric_face_flux * _current_face_area;
55 }
56 
57 Real
59 {
60  const auto & coeffs = _adv_interp_result.weights_matrix;
61  return coeffs.second * _volumetric_face_flux * _current_face_area;
62 }
63 
64 Real
66 {
68 }
69 
70 Real
72 {
74 }
75 
76 Real
78 {
79  const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
80  mooseAssert(adv_bc, "This should be a valid BC!");
81 
82  const auto boundary_value_matrix_contrib = adv_bc->computeBoundaryValueMatrixContribution();
83 
84  // We support internal boundaries too so we have to make sure the normal points always outward
85  const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0;
86 
87  return boundary_value_matrix_contrib * factor * _volumetric_face_flux * _current_face_area;
88 }
89 
90 Real
92 {
93  const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
94  mooseAssert(adv_bc, "This should be a valid BC!");
95 
96  // We support internal boundaries too so we have to make sure the normal points always outward
97  const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0);
98 
99  const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution();
100  return -boundary_value_rhs_contrib * factor * _volumetric_face_flux * _current_face_area;
101 }
102 
103 void
105 {
107 
108  // Caching the velocity on the face which will be reused in the advection term's matrix and right
109  // hand side contributions
111 
112  // Adjust volumetric face flux using the slip velocity
113  // TODO: add boundaries
114  if (_u_slip && face_info->neighborPtr())
115  {
116  const auto state = determineState();
117  Moose::FaceArg face_arg;
118  // TODO Add boundary treatment to be able select two-term expansion if desired
119  face_arg = Moose::FaceArg{face_info,
121  true,
122  false,
123  face_info->neighborPtr(),
124  nullptr};
125 
126  RealVectorValue velocity_slip_vel_vec;
127  if (_u_slip)
128  velocity_slip_vel_vec(0) = (*_u_slip)(face_arg, state).value();
129  if (_v_slip)
130  velocity_slip_vel_vec(1) = (*_v_slip)(face_arg, state).value();
131  if (_w_slip)
132  velocity_slip_vel_vec(2) = (*_w_slip)(face_arg, state).value();
133  _volumetric_face_flux += velocity_slip_vel_vec * face_info->normal();
134  }
135 
136  // Only internal faces need advected interpolation results; boundary contributions are handled
137  // through the linear FV boundary conditions.
139  return;
140 
141  const auto state = determineState();
142  const auto & elem_info = *_current_face_info->elemInfo();
143  const auto & neighbor_info = *_current_face_info->neighborInfo();
144 
145  const Real elem_value = _var.getElemValue(elem_info, state);
146  const Real neighbor_value = _var.getElemValue(neighbor_info, state);
148  {
149  const auto limiter_type = _adv_interp_method.gradientLimiter();
150  _elem_grad_storage = _var.gradSln(elem_info, state, limiter_type);
151  _neighbor_grad_storage = _var.gradSln(neighbor_info, state, limiter_type);
152  }
153 
155  elem_value,
156  neighbor_value,
160 }
LinearFVScalarAdvection(const InputParameters &params)
const FVAdvectedInterpolationMethod & _adv_interp_method
The interpolation method to use for the advected quantity.
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
VectorValue< Real > _elem_grad_storage
Reusable gradient storage used when advected interpolation requires gradients.
Moose::StateArg determineState() const
const ElemInfo * neighborInfo() const
virtual Real computeNeighborMatrixContribution() override
MooseLinearVariableFV< Real > & _var
virtual void setupFaceData(const FaceInfo *face_info)
const ElemInfo * elemInfo() const
virtual Moose::FV::GradientLimiterType gradientLimiter() const
static InputParameters validParams()
FaceInfo::VarFaceNeighbors _current_face_type
void addRequiredParam(const std::string &name, const std::string &doc_string)
VectorValue< Real > gradSln(const ElemInfo &elem_info, const StateArg &state) const
virtual void setupFaceData(const FaceInfo *face_info) override
static InputParameters validParams()
const FaceInfo * _current_face_info
const Elem * neighborPtr() const
virtual 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=0
virtual Real computeElemRightHandSideContribution() override
Real getVolumetricFaceFlux(const FaceInfo &fi) const
Get the volumetric face flux (used in advection terms)
const RhieChowMassFlux & _mass_flux_provider
The Rhie-Chow user object that provides us with the face velocity.
virtual const OutputTools< Real >::VariableValue & value()
const Point & normal() const
virtual Real computeElemMatrixContribution() override
registerMooseObject("NavierStokesApp", LinearFVScalarAdvection)
Real _volumetric_face_flux
Container for the velocity on the face which will be reused in the advection term&#39;s matrix and right ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool needsGradients() const
virtual Real computeNeighborRightHandSideContribution() override
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
VectorValue< Real > _neighbor_grad_storage
Real getElemValue(const ElemInfo &elem_info, const StateArg &state) const
void addClassDescription(const std::string &doc_string)
An advection kernel that implements the advection term for the passive scalar transport equation...
const Moose::Functor< ADReal > *const _v_slip
slip velocity in direction y
virtual Real computeBoundaryMatrixContribution(const LinearFVBoundaryCondition &bc) override
FVAdvectedInterpolationMethod::AdvectedSystemContribution _adv_interp_result
Cached weights/correction for the current face (refreshed in setupFaceData)
const Moose::Functor< ADReal > *const _w_slip
slip velocity in direction z
const Moose::Functor< ADReal > *const _u_slip
slip velocity in direction x