https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearWCNSFV2PMomentumDriftFlux.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 "NS.h"
12#include "RhieChowMassFlux.h"
15
17
19LinearWCNSFV2PMomentumDriftFlux ::validParams()
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
49LinearWCNSFV2PMomentumDriftFlux ::LinearWCNSFV2PMomentumDriftFlux(const InputParameters & params)
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)
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
73void
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 // The boundary is determined by this kernel's blocks, which may be fewer than the velocity
82 // variable's, so the face is sided by this kernel's blocks rather than by the variable.
83 if (on_boundary)
84 {
85 const bool elem_is_inside = hasBlocks(_current_face_info->elemPtr()->subdomain_id());
86 face_arg = {_current_face_info,
87 Moose::FV::LimiterType::CentralDifference,
88 elem_is_inside,
89 false,
91 nullptr};
92 }
93 else
94 face_arg = makeCDFace(*_current_face_info);
95
96 RealVectorValue u_slip_vel_vec;
97 if (_dim == 1)
98 u_slip_vel_vec = RealVectorValue(_u_slip(face_arg, state), 0.0, 0.0);
99 else if (_dim == 2)
100 u_slip_vel_vec = RealVectorValue(_u_slip(face_arg, state), (*_v_slip)(face_arg, state), 0.0);
101 else
102 u_slip_vel_vec = RealVectorValue(
103 _u_slip(face_arg, state), (*_v_slip)(face_arg, state), (*_w_slip)(face_arg, state));
104
105 const auto uslipdotn = normal * u_slip_vel_vec;
106
107 Real face_rho_fd;
108 if (on_boundary)
109 face_rho_fd = _rho_d(face_arg, state) * _f_d(face_arg, state);
110 else
111 {
112 const auto elem_arg = makeElemArg(_current_face_info->elemPtr());
113 const auto neigh_arg = makeElemArg(_current_face_info->neighborPtr());
114
116 face_rho_fd,
117 _rho_d(elem_arg, state) * _f_d(elem_arg, state),
118 _rho_d(neigh_arg, state) * _f_d(neigh_arg, state),
120 true);
121 }
122
123 _face_flux = -face_rho_fd * uslipdotn * u_slip_vel_vec(_index);
124}
125
126Real
128{
129 const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
130 if (std::abs(u_old) > 1e-6)
132 else
133 return 0.;
134}
135
136Real
138{
139 const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
140 if (std::abs(u_old) > 1e-6)
141 return _velocity_interp_coeffs.second * _face_flux / u_old * _current_face_area;
142 else
143 // place term on RHS if u_old is too close to 0
144 return 0.;
145}
146
147Real
149{
150 // Get old velocity
151 const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
152 const auto u = _var(makeCDFace(*_current_face_info), Moose::currentState()).value();
153 if (std::abs(u_old) > 1e-6)
154 return _velocity_interp_coeffs.first * _face_flux * (u / u_old - 1) * _current_face_area;
155 else
157}
158
159Real
161{
162 // Get old velocity
163 const auto u_old = _var(makeCDFace(*_current_face_info), Moose::previousNonlinearState()).value();
164 const auto u = _var(makeCDFace(*_current_face_info), Moose::currentState()).value();
165 if (std::abs(u_old) > 1e-6)
166 return _velocity_interp_coeffs.second * _face_flux * (u / u_old - 1) * _current_face_area;
167 else
169}
170
171Real
173 const LinearFVBoundaryCondition & /*bc*/)
174{
175 // Lagging the whole term for now
176 // TODO: make sure this only gets called once, and not once per BC
178}
179
180void
182{
184
185 // Caching the mass flux on the face which will be reused in the advection term's matrix and right
186 // hand side contributions
187 computeFlux();
188
189 // Caching the interpolation coefficients so they will be reused for the matrix and right hand
190 // side terms
194 true,
196}
registerMooseObject("NavierStokesApp", LinearWCNSFV2PMomentumDriftFlux)
bool hasBlocks(const SubdomainName &name) const
Moose::FaceArg makeCDFace(const FaceInfo &fi, const bool correct_skewness=false) const
const Point & normal() const
const Elem * neighborPtr() const
const Elem * elemPtr() const
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
virtual void setupFaceData(const FaceInfo *face_info)
const FaceInfo * _current_face_info
static InputParameters validParams()
MooseLinearVariableFV< Real > & _var
Adds drift flux kernel coming for two-phase mixture model for the linear finite volume discretization...
const unsigned int _index
The index of the momentum component.
const Moose::Functor< Real > & _u_slip
slip velocity in direction x
const Moose::Functor< Real > *const _v_slip
slip velocity in direction y
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
virtual Real computeElemRightHandSideContribution() override
const RhieChowMassFlux & _mass_flux_provider
The Rhie-Chow user object that provides us with the face velocity.
virtual void setupFaceData(const FaceInfo *face_info) override
Set the current FaceInfo object.
const Moose::Functor< Real > & _f_d
Dispersed phase fraction.
const Moose::FV::InterpMethod _density_interp_method
The face interpolation method for the density.
const Moose::Functor< Real > & _rho_d
Dispersed phase density.
const Moose::Functor< Real > *const _w_slip
slip velocity in direction z
const unsigned int _dim
The dimension of the simulation.
virtual Real computeNeighborRightHandSideContribution() override
std::pair< Real, Real > _velocity_interp_coeffs
Advected coefficients.
void mooseError(Args &&... args) const
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
Real getMassFlux(const FaceInfo &fi) const
Get the face velocity times density (used in advection terms)
Moose::StateArg determineState() const
MeshBase & mesh
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
std::pair< Real, Real > interpCoeffs(const InterpMethod m, const FaceInfo &fi, const bool one_is_elem, const T &face_flux=0.0)
bool onBoundary(const SubdomainRestrictable &obj, const FaceInfo &fi)
StateArg previousNonlinearState()
StateArg currentState()