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 "NSFVUtils.h"
13 #include "NS.h"
14 
16 
19 {
21  params.addClassDescription("Represents the matrix and right hand side contributions of an "
22  "advection term for a passive scalar.");
23  params.addRequiredParam<UserObjectName>(
24  "rhie_chow_user_object",
25  "The rhie-chow user-object which is used to determine the face velocity.");
27  params.addParam<MooseFunctorName>("u_slip", "The slip-velocity in the x direction.");
28  params.addParam<MooseFunctorName>("v_slip", "The slip-velocity in the y direction.");
29  params.addParam<MooseFunctorName>("w_slip", "The slip-velocity in the z direction.");
30  return params;
31 }
32 
34  : LinearFVFluxKernel(params),
35  _mass_flux_provider(getUserObject<RhieChowMassFlux>("rhie_chow_user_object")),
36  _advected_interp_coeffs(std::make_pair<Real, Real>(0, 0)),
37  _volumetric_face_flux(0.0),
38  _u_slip(isParamValid("u_slip") ? &getFunctor<ADReal>("u_slip") : nullptr),
39  _v_slip(isParamValid("v_slip") ? &getFunctor<ADReal>("v_slip") : nullptr),
40  _w_slip(isParamValid("w_slip") ? &getFunctor<ADReal>("w_slip") : nullptr),
41  _add_slip_model(isParamValid("u_slip") ? true : false)
42 {
43  Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
44 }
45 
46 Real
48 {
50 }
51 
52 Real
54 {
56 }
57 
58 Real
60 {
61  return 0.0;
62 }
63 
64 Real
66 {
67  return 0.0;
68 }
69 
70 Real
72 {
73  const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
74  mooseAssert(adv_bc, "This should be a valid BC!");
75 
76  const auto boundary_value_matrix_contrib = adv_bc->computeBoundaryValueMatrixContribution();
77 
78  // We support internal boundaries too so we have to make sure the normal points always outward
79  const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0;
80 
81  return boundary_value_matrix_contrib * factor * _volumetric_face_flux * _current_face_area;
82 }
83 
84 Real
86 {
87  const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
88  mooseAssert(adv_bc, "This should be a valid BC!");
89 
90  // We support internal boundaries too so we have to make sure the normal points always outward
91  const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0);
92 
93  const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution();
94  return -boundary_value_rhs_contrib * factor * _volumetric_face_flux * _current_face_area;
95 }
96 
97 void
99 {
101 
102  // Caching the velocity on the face which will be reused in the advection term's matrix and right
103  // hand side contributions
105 
106  // Adjust volumetric face flux using the slip velocity
107  // TODO: add boundaries
108  if (_u_slip && face_info->neighborPtr())
109  {
110  const auto state = determineState();
111  Moose::FaceArg face_arg;
112  // TODO Add boundary treatment to be able select two-term expansion if desired
113  face_arg = Moose::FaceArg{face_info,
115  true,
116  false,
117  face_info->neighborPtr(),
118  nullptr};
119 
120  RealVectorValue velocity_slip_vel_vec;
121  if (_u_slip)
122  velocity_slip_vel_vec(0) = (*_u_slip)(face_arg, state).value();
123  if (_v_slip)
124  velocity_slip_vel_vec(1) = (*_v_slip)(face_arg, state).value();
125  if (_w_slip)
126  velocity_slip_vel_vec(2) = (*_w_slip)(face_arg, state).value();
127  _volumetric_face_flux += velocity_slip_vel_vec * face_info->normal();
128  }
129 
130  // Caching the interpolation coefficients so they will be reused for the matrix and right hand
131  // side terms
134 }
LinearFVScalarAdvection(const InputParameters &params)
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
std::pair< Real, Real > interpCoeffs(const InterpMethod m, const FaceInfo &fi, const bool one_is_elem, const T &face_flux=0.0)
Moose::StateArg determineState() const
virtual Real computeNeighborMatrixContribution() override
virtual void setupFaceData(const FaceInfo *face_info)
static InputParameters validParams()
FaceInfo::VarFaceNeighbors _current_face_type
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual void setupFaceData(const FaceInfo *face_info) override
static InputParameters validParams()
const FaceInfo * _current_face_info
const Elem * neighborPtr() const
InputParameters advectedInterpolationParameter()
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)
std::pair< Real, Real > _advected_interp_coeffs
Container for the current advected interpolation coefficients on the face to make sure we don&#39;t compu...
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 Real computeNeighborRightHandSideContribution() override
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
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
const Moose::Functor< ADReal > *const _w_slip
slip velocity in direction z
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
const Moose::Functor< ADReal > *const _u_slip
slip velocity in direction x
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)