https://mooseframework.inl.gov
LinearWCNSFV2PMomentumDriftFlux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "NS.h"
12 #include "RhieChowMassFlux.h"
15 
17 
20 {
21  auto params = LinearFVFluxKernel::validParams();
22  params.addClassDescription("Implements the drift momentum flux source.");
23  params.addRequiredParam<UserObjectName>(
24  "rhie_chow_user_object",
25  "The rhie-chow user-object which is used to determine the face velocity.");
26  params.addRequiredParam<MooseFunctorName>("u_slip", "The slip velocity in the x direction.");
27  params.addParam<MooseFunctorName>("v_slip", "The slip velocity in the y direction.");
28  params.addParam<MooseFunctorName>("w_slip", "The slip velocity in the z direction.");
29  params.addRequiredParam<MooseFunctorName>("rho_d", "Dispersed phase density.");
30  params.addParam<MooseFunctorName>("fd", 0.0, "Fraction dispersed phase.");
31  params.renameParam("fd", "fraction_dispersed", "");
32 
33  params.addParam<bool>(
34  "force_boundary_execution", true, "This kernel should execute on boundaries by default");
35  MooseEnum momentum_component("x=0 y=1 z=2");
36  params.addRequiredParam<MooseEnum>(
37  "momentum_component",
38  momentum_component,
39  "The component of the momentum equation that this kernel applies to.");
40 
41  MooseEnum coeff_interp_method("average harmonic", "harmonic");
42  params.addParam<MooseEnum>("density_interp_method",
43  coeff_interp_method,
44  "Switch that can select face interpolation method for the density.");
45 
46  return params;
47 }
48 
50  : LinearFVFluxKernel(params),
51  _dim(_subproblem.mesh().dimension()),
52  _mass_flux_provider(getUserObject<RhieChowMassFlux>("rhie_chow_user_object")),
53  _rho_d(getFunctor<Real>("rho_d")),
54  _f_d(getFunctor<Real>("fd")),
55  _u_slip(getFunctor<Real>("u_slip")),
56  _v_slip(isParamValid("v_slip") ? &getFunctor<Real>("v_slip") : nullptr),
57  _w_slip(isParamValid("w_slip") ? &getFunctor<Real>("w_slip") : nullptr),
58  _index(getParam<MooseEnum>("momentum_component")),
59  _density_interp_method(
60  Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("density_interp_method")))
61 {
62  if (_dim >= 2 && !_v_slip)
63  mooseError("In two or more dimensions, the v_slip velocity must be supplied using the 'v_slip' "
64  "parameter");
65  if (_dim >= 3 && !_w_slip)
66  mooseError(
67  "In three dimensions, the w_slip velocity must be supplied using the 'w_slip' parameter");
68 
69  // Note that since this is used in a segregated solver at this time, we don't need to declare
70  // that this kernel may depend on a phase fraction variable
71 }
72 
73 void
75 {
76  const auto & normal = _current_face_info->normal();
77  const auto state = determineState();
78  const bool on_boundary = Moose::FV::onBoundary(*this, *_current_face_info);
79 
80  Moose::FaceArg face_arg;
81  if (on_boundary)
83  else
84  face_arg = makeCDFace(*_current_face_info);
85 
86  RealVectorValue u_slip_vel_vec;
87  if (_dim == 1)
88  u_slip_vel_vec = RealVectorValue(_u_slip(face_arg, state), 0.0, 0.0);
89  else if (_dim == 2)
90  u_slip_vel_vec = RealVectorValue(_u_slip(face_arg, state), (*_v_slip)(face_arg, state), 0.0);
91  else
92  u_slip_vel_vec = RealVectorValue(
93  _u_slip(face_arg, state), (*_v_slip)(face_arg, state), (*_w_slip)(face_arg, state));
94 
95  const auto uslipdotn = normal * u_slip_vel_vec;
96 
97  Real face_rho_fd;
98  if (on_boundary)
99  face_rho_fd = _rho_d(face_arg, state) * _f_d(face_arg, state);
100  else
101  {
102  const auto elem_arg = makeElemArg(_current_face_info->elemPtr());
103  const auto neigh_arg = makeElemArg(_current_face_info->neighborPtr());
104 
106  face_rho_fd,
107  _rho_d(elem_arg, state) * _f_d(elem_arg, state),
108  _rho_d(neigh_arg, state) * _f_d(neigh_arg, state),
110  true);
111  }
112 
113  _face_flux = -face_rho_fd * uslipdotn * u_slip_vel_vec(_index);
114 }
115 
116 Real
118 {
119  const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
120  if (std::abs(u_old) > 1e-6)
121  return _velocity_interp_coeffs.first * _face_flux / u_old * _current_face_area;
122  else
123  return 0.;
124 }
125 
126 Real
128 {
129  const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
130  if (std::abs(u_old) > 1e-6)
131  return _velocity_interp_coeffs.second * _face_flux / u_old * _current_face_area;
132  else
133  // place term on RHS if u_old is too close to 0
134  return 0.;
135 }
136 
137 Real
139 {
140  // Get old velocity
141  const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
142  const auto u = _var(makeCDFace(*_current_face_info), Moose::currentState()).value();
143  if (std::abs(u_old) > 1e-6)
144  return _velocity_interp_coeffs.first * _face_flux * (u / u_old - 1) * _current_face_area;
145  else
146  return -_face_flux * _current_face_area;
147 }
148 
149 Real
151 {
152  // Get old velocity
153  const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
154  const auto u = _var(makeCDFace(*_current_face_info), Moose::currentState()).value();
155  if (std::abs(u_old) > 1e-6)
156  return _velocity_interp_coeffs.second * _face_flux * (u / u_old - 1) * _current_face_area;
157  else
158  return -_face_flux * _current_face_area;
159 }
160 
161 Real
163  const LinearFVBoundaryCondition & /*bc*/)
164 {
165  // Lagging the whole term for now
166  // TODO: make sure this only gets called once, and not once per BC
167  return -_face_flux * _current_face_area;
168 }
169 
170 void
172 {
174 
175  // Caching the mass flux on the face which will be reused in the advection term's matrix and right
176  // hand side contributions
177  computeFlux();
178 
179  // Caching the interpolation coefficients so they will be reused for the matrix and right hand
180  // side terms
184  true,
186 }
const Moose::Functor< Real > & _rho_d
Dispersed phase density.
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
virtual void setupFaceData(const FaceInfo *face_info) override
Set the current FaceInfo object.
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
const unsigned int _index
The index of the momentum component.
virtual Real computeNeighborMatrixContribution() override
std::pair< Real, Real > interpCoeffs(const InterpMethod m, const FaceInfo &fi, const bool one_is_elem, const T &face_flux=0.0)
Real getMassFlux(const FaceInfo &fi) const
Get the face velocity times density (used in advection terms)
const Moose::Functor< Real > & _u_slip
slip velocity in direction x
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false) const
Adds drift flux kernel coming for two-phase mixture model for the linear finite volume discretization...
Moose::StateArg determineState() const
MooseLinearVariableFV< Real > & _var
MeshBase & mesh
virtual void setupFaceData(const FaceInfo *face_info)
const Moose::Functor< Real > *const _v_slip
slip velocity in direction y
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
static InputParameters validParams()
const RhieChowMassFlux & _mass_flux_provider
The Rhie-Chow user object that provides us with the face velocity.
const Moose::Functor< Real > & _f_d
Dispersed phase fraction.
const FaceInfo * _current_face_info
const Elem * neighborPtr() const
std::pair< Real, Real > _velocity_interp_coeffs
Advected coefficients.
LinearWCNSFV2PMomentumDriftFlux(const InputParameters &params)
const Point & normal() const
virtual Real computeNeighborRightHandSideContribution() override
virtual Real computeElemRightHandSideContribution() override
const Elem * elemPtr() const
const Moose::FV::InterpMethod _density_interp_method
The face interpolation method for the density.
bool onBoundary(const SubdomainRestrictable &obj, const FaceInfo &fi)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
const Moose::Functor< Real > *const _w_slip
slip velocity in direction z
InterpMethod selectInterpolationMethod(const std::string &interp_method)
const unsigned int _dim
The dimension of the simulation.
Moose::FaceArg makeCDFace(const FaceInfo &fi, const bool correct_skewness=false) const
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
StateArg previousNonlinearState()
StateArg currentState()
registerMooseObject("NavierStokesApp", LinearWCNSFV2PMomentumDriftFlux)