https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSFV2PMomentumDriftFlux.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
12#include "NS.h"
13#include "SystemBase.h"
14#include "RelationshipManager.h"
15#include "Factory.h"
16
18
21{
22 auto params = INSFVFluxKernel::validParams();
23 params.addClassDescription("Implements the drift momentum flux source.");
24 params.addRequiredParam<MooseFunctorName>("u_slip", "The slip velocity in the x direction.");
25 params.addParam<MooseFunctorName>("v_slip", "The slip velocity in the y direction.");
26 params.addParam<MooseFunctorName>("w_slip", "The slip velocity in the z direction.");
27 params.addRequiredParam<MooseFunctorName>("rho_d", "Dispersed phase density.");
28 params.addParam<MooseFunctorName>("fd", 0.0, "Fraction dispersed phase.");
29
30 params.renameParam("fd", "fraction_dispersed", "");
31
32 MooseEnum coeff_interp_method("average harmonic", "harmonic");
33 params.addParam<MooseEnum>("density_interp_method",
34 coeff_interp_method,
35 "Switch that can select face interpolation method for the density.");
36
37 return params;
38}
39
41 : INSFVFluxKernel(params),
42 _dim(_subproblem.mesh().dimension()),
43 _rho_d(getFunctor<ADReal>("rho_d")),
44 _f_d(getFunctor<ADReal>("fd")),
45 _u_slip(getFunctor<ADReal>("u_slip")),
46 _v_slip(isParamValid("v_slip") ? &getFunctor<ADReal>("v_slip") : nullptr),
47 _w_slip(isParamValid("w_slip") ? &getFunctor<ADReal>("w_slip") : nullptr),
48 _density_interp_method(
49 Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("density_interp_method")))
50{
51 if (_dim >= 2 && !_v_slip)
52 mooseError("In two or more dimensions, the v_slip velocity must be supplied using the 'v_slip' "
53 "parameter");
54 if (_dim >= 3 && !_w_slip)
56 "In three dimensions, the w_slip velocity must be supplied using the 'w_slip' parameter");
57
58 // Phase fraction could be a nonlinear variable
59 const auto & fraction_name = getParam<MooseFunctorName>("fraction_dispersed");
60 if (isParamValid("fraction_dispersed") && _fe_problem.hasVariable(fraction_name))
62}
63
66{
68 const auto state = determineState();
69
70 Moose::FaceArg face_arg;
72 face_arg = singleSidedFaceArg();
73 else
74 face_arg = makeCDFace(*_face_info);
75
76 ADRealVectorValue u_slip_vel_vec;
77 if (_dim == 1)
78 u_slip_vel_vec = ADRealVectorValue(_u_slip(face_arg, state), 0.0, 0.0);
79 else if (_dim == 2)
80 u_slip_vel_vec = ADRealVectorValue(_u_slip(face_arg, state), (*_v_slip)(face_arg, state), 0.0);
81 else
82 u_slip_vel_vec = ADRealVectorValue(
83 _u_slip(face_arg, state), (*_v_slip)(face_arg, state), (*_w_slip)(face_arg, state));
84
85 const auto uslipdotn = _normal * u_slip_vel_vec;
86
87 ADReal face_rho_fd;
89 face_rho_fd = _rho_d(makeCDFace(*_face_info), state) * _f_d(makeCDFace(*_face_info), state);
90 else
92 face_rho_fd,
93 _rho_d(elemArg(), state) * _f_d(elemArg(), state),
94 _rho_d(neighborArg(), state) * _f_d(neighborArg(), state),
96 true);
97
98 if (populate_a_coeffs)
99 {
100 if (_face_type == FaceInfo::VarFaceNeighbors::ELEM ||
101 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
102 {
103 const auto dof_number = _face_info->elem().dof_number(_sys.number(), _var.number(), 0);
104 if (_index == 0)
105 _ae = (uslipdotn * _u_slip(elemArg(), state)).derivatives()[dof_number];
106 else if (_index == 1)
107 _ae = (uslipdotn * (*_v_slip)(elemArg(), state)).derivatives()[dof_number];
108 else
109 _ae = (uslipdotn * (*_w_slip)(elemArg(), state)).derivatives()[dof_number];
110 _ae *= -face_rho_fd;
111 }
112 if (_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR ||
113 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
114 {
115 const auto dof_number = _face_info->neighbor().dof_number(_sys.number(), _var.number(), 0);
116 if (_index == 0)
117 _an = (uslipdotn * _u_slip(neighborArg(), state)).derivatives()[dof_number];
118 else if (_index == 1)
119 _an = (uslipdotn * (*_v_slip)(neighborArg(), state)).derivatives()[dof_number];
120 else
121 _an = (uslipdotn * (*_w_slip)(neighborArg(), state)).derivatives()[dof_number];
122 _an *= face_rho_fd;
123 }
124 }
125
126 return -face_rho_fd * uslipdotn * u_slip_vel_vec(_index);
127}
128
129void
131{
132 if (skipForBoundary(fi))
133 return;
134
135 _face_info = &fi;
136 _normal = fi.normal();
137 _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
138
140
141 if (_face_type == FaceInfo::VarFaceNeighbors::ELEM ||
142 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
143 _rc_uo.addToA(&fi.elem(), _index, _ae * (fi.faceArea() * fi.faceCoord()));
144 if (_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR ||
145 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
146 _rc_uo.addToA(fi.neighborPtr(), _index, _an * (fi.faceArea() * fi.faceCoord()));
147}
148
149ADReal
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", WCNSFV2PMomentumDriftFlux)
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
virtual bool hasVariable(const std::string &var_name) const override
Moose::ElemArg neighborArg(bool correct_skewness=false) const
Moose::ElemArg elemArg(bool correct_skewness=false) const
RealVectorValue _normal
virtual bool skipForBoundary(const FaceInfo &fi) const
bool onBoundary(const FaceInfo &fi) const
MooseVariableFV< Real > & _var
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
const FaceInfo * _face_info
FaceInfo::VarFaceNeighbors _face_type
Moose::FaceArg makeCDFace(const FaceInfo &fi, const bool correct_skewness=false) const
const Point & normal() const
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
const Elem & elem() const
const Elem * neighborPtr() const
Real faceArea() const
Real & faceCoord()
const Elem & neighbor() const
A flux kernel that momentum residual objects that add non-advection flux terms, or more specifically ...
static InputParameters validParams()
void addResidualAndJacobian(const ADReal &residual)
Process into either the system residual or Jacobian.
const unsigned int _index
index x|y|z
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms.
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
SystemBase & sys()
unsigned int number() const
void addMooseVariableDependency(MooseVariableFieldBase *var)
THREAD_ID _tid
SystemBase & _sys
FEProblemBase & _fe_problem
virtual void addToA(const libMesh::Elem *elem, unsigned int component, const ADReal &value)=0
API for momentum residual objects that have on-diagonals for velocity call.
unsigned int number() const
Moose::StateArg determineState() const
Adds drift flux kernel coming for two-phase mixture model.
const Moose::Functor< ADReal > *const _v_slip
slip velocity in direction y
ADReal _an
The a coefficient for the neighbor.
const Moose::FV::InterpMethod _density_interp_method
The face interpolation method for the density.
const Moose::Functor< ADReal > & _u_slip
slip velocity in direction x
const Moose::Functor< ADReal > *const _w_slip
slip velocity in direction z
virtual ADReal computeStrongResidual(const bool populate_a_coeffs)
Routine to compute this object's strong residual (e.g.
virtual ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
WCNSFV2PMomentumDriftFlux(const InputParameters &params)
static InputParameters validParams()
const Moose::Functor< ADReal > & _f_d
Dispersed phase fraction.
const unsigned int _dim
The dimension of the simulation.
const Moose::Functor< ADReal > & _rho_d
Dispersed phase density.
ADReal _ae
The a coefficient for the element.
void gatherRCData(const FaceInfo &fi) override final
Should be a non-empty implementation if the residual object is a FVFluxKernel and introduces residual...
MeshBase & mesh
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)