https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSFV2PSlipVelocityFunctorMaterial.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
13#include "Function.h"
14#include "NS.h"
15#include "FVKernel.h"
16
18
21{
23 params.addClassDescription("Computes the slip velocity for two-phase mixture model.");
24 params.addRequiredCoupledVar("u", "The velocity in the x direction.");
25 params.addCoupledVar("v", "The velocity in the y direction.");
26 params.addCoupledVar("w", "The velocity in the z direction.");
27 params.addRequiredParam<MooseFunctorName>(NS::density, "Continuous phase density.");
28 params.addRequiredParam<MooseFunctorName>("rho_d", "Dispersed phase density.");
29 params.addRequiredParam<MooseFunctorName>(NS::mu, "Mixture Density");
30 params.addParam<RealVectorValue>(
31 "gravity", RealVectorValue(0, 0, 0), "Gravity acceleration vector");
32 params.addParam<Real>("force_value", 0.0, "Coefficient to multiply by the body force term");
33 params.addParam<FunctionName>("force_function", "0", "A function that describes the body force");
34 params.addParam<PostprocessorName>(
35 "force_postprocessor", 0, "A postprocessor whose value is multiplied by the body force");
36 params.addParam<RealVectorValue>(
37 "force_direction", RealVectorValue(1, 0, 0), "Gravitational acceleration vector");
38 params.addParam<MooseFunctorName>(
39 "linear_coef_name", 0.44, "Linear friction coefficient name as a material property");
40 params.addParam<MooseFunctorName>(
41 "particle_diameter", 1.0, "Diameter of particles in the dispersed phase.");
42 params.addParam<MooseFunctorName>("fd", 0.0, "Fraction dispersed phase.");
43 MooseEnum momentum_component("x=0 y=1 z=2");
45 "momentum_component",
46 momentum_component,
47 "The component of the momentum equation that this kernel applies to.");
48 params.addRequiredParam<MooseFunctorName>("slip_velocity_name", "the name of the slip velocity");
49 params.addParam<unsigned short>("ghost_layers",
50 3,
51 "The number of layers of elements to ghost. With Rhie-Chow and "
52 "the velocity gradient calculation below, we need 3");
54 "ElementSideNeighborLayers",
55 Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC |
56 Moose::RelationshipManagerType::COUPLING,
57 [](const InputParameters & obj_params, InputParameters & rm_params)
58 {
59 rm_params.set<unsigned short>("layers") = obj_params.get<unsigned short>("ghost_layers");
60 });
61 return params;
62}
63
65 const InputParameters & params)
66 : FunctorMaterial(params),
67 _dim(_subproblem.mesh().dimension()),
68 _u_var(dynamic_cast<MooseVariableField<Real> *>(getFieldVar("u", 0))),
69 _v_var(params.isParamValid("v") ? dynamic_cast<MooseVariableField<Real> *>(getFieldVar("v", 0))
70 : nullptr),
71 _w_var(params.isParamValid("w") ? dynamic_cast<MooseVariableField<Real> *>(getFieldVar("w", 0))
72 : nullptr),
73 _rho_mixture(getFunctor<ADReal>(NS::density)),
74 _rho_d(getFunctor<ADReal>("rho_d")),
75 _mu_mixture(getFunctor<ADReal>(NS::mu)),
76 _gravity(getParam<RealVectorValue>("gravity")),
77 _force_scale(getParam<Real>("force_value")),
78 _force_function(getFunction("force_function")),
79 _force_postprocessor(getPostprocessorValue("force_postprocessor")),
80 _force_direction(getParam<RealVectorValue>("force_direction")),
81 _linear_friction(getFunctor<ADReal>("linear_coef_name")),
82 _particle_diameter(getFunctor<ADReal>("particle_diameter")),
83 _index(getParam<MooseEnum>("momentum_component"))
84{
85 if (!dynamic_cast<const INSFVVelocityVariable *>(_u_var) &&
86 !dynamic_cast<const MooseLinearVariableFV<Real> *>(_u_var))
87 paramError("u",
88 "the u velocity must be an INSFVVelocityVariable or a MooseLinearVariableFVReal");
89
90 if (_dim >= 2 && (!dynamic_cast<const INSFVVelocityVariable *>(_v_var) &&
91 !dynamic_cast<const MooseLinearVariableFV<Real> *>(_v_var)))
92 paramError("v",
93 "In two or more dimensions, the v velocity must be supplied and it must be an "
94 "INSFVVelocityVariable or a MooseLinearVariableFVReal.");
95
96 if (_dim >= 3 && (!dynamic_cast<const INSFVVelocityVariable *>(_w_var) &&
97 !dynamic_cast<const MooseLinearVariableFV<Real> *>(_w_var)))
98 paramError("w",
99 "In three-dimensions, the w velocity must be supplied and it must be an "
100 "INSFVVelocityVariable or a MooseLinearVariableFVReal.");
101
102 // Slip velocity advection term requires gradients
103 // TODO: this could be set less often, keeping it false until the two phase mixture system is
104 // solved
105 if (auto u = dynamic_cast<MooseLinearVariableFV<Real> *>(_u_var))
106 u->computeCellGradients();
107 if (auto v = dynamic_cast<MooseLinearVariableFV<Real> *>(_v_var))
108 v->computeCellGradients();
109 if (auto w = dynamic_cast<MooseLinearVariableFV<Real> *>(_w_var))
110 w->computeCellGradients();
111
112 addFunctorProperty<ADReal>(
113 getParam<MooseFunctorName>("slip_velocity_name"),
114 [this](const auto & r, const auto & t)
115 {
116 constexpr Real offset = 1e-15;
117
118 const bool is_transient = _subproblem.isTransient();
119 ADRealVectorValue term_advection(0, 0, 0);
120 ADRealVectorValue term_transient(0, 0, 0);
121 const ADRealVectorValue term_force(
124
125 // Adding transient term
126 // TODO: add time derivative term to lienar FV variable
127 if (is_transient && !dynamic_cast<MooseLinearVariableFV<Real> *>(_u_var))
128 {
129 term_transient(0) += _u_var->dot(r, t);
130 if (_dim > 1)
131 term_transient(1) += _v_var->dot(r, t);
132 if (_dim > 2)
133 term_transient(2) += _w_var->dot(r, t);
134 }
135
136 // Adding advection term
137 const auto u_velocity = (*_u_var)(r, t);
138 const auto u_grad = _u_var->gradient(r, t);
139 term_advection(0) += u_velocity * u_grad(0);
140 if (_dim > 1)
141 {
142 const auto v_velocity = (*_v_var)(r, t);
143 const auto v_grad = _v_var->gradient(r, t);
144 term_advection(0) += v_velocity * u_grad(1);
145 term_advection(1) += u_velocity * v_grad(0) + v_velocity * v_grad(1);
146 if (_dim > 2)
147 {
148 const auto w_velocity = (*_w_var)(r, t);
149 const auto w_grad = _w_var->gradient(r, t);
150 term_advection(0) += w_velocity * u_grad(2);
151 term_advection(1) += w_velocity * v_grad(2);
152 term_advection(2) +=
153 u_velocity * w_grad(0) + v_velocity * w_grad(1) + w_velocity * w_grad(2);
154 }
155 }
156
157 const ADReal density_scaling = (_rho_d(r, t) - _rho_mixture(r, t)) / _rho_d(r, t);
158 const ADReal flux_residual =
159 density_scaling * (-term_transient - term_advection + _gravity + term_force)(_index);
160
161 const ADReal relaxation_time =
162 _rho_d(r, t) * Utility::pow<2>(_particle_diameter(r, t)) / (18.0 * _mu_mixture(r, t));
163
164 const ADReal linear_friction_factor = _linear_friction(r, t) + offset;
165
166 return relaxation_time / linear_friction_factor * flux_residual;
167 });
168}
DualNumber< Real, DNDerivativeType, true > ADReal
const double mu
const double v
registerMooseObject("NavierStokesApp", WCNSFV2PSlipVelocityFunctorMaterial)
virtual Real value(Real t, const Point &p) const
static InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void addCoupledVar(const std::string &name, const std::string &doc_string)
SubProblem & _subproblem
const Elem *const & _current_elem
void paramError(const std::string &param, Args... args) const
DotType dot(const ElemArg &elem, const StateArg &state) const
GradientType gradient(const ElemArg &elem, const StateArg &state) const
virtual bool isTransient() const=0
Computes the value of slip velocity for the two phase mixture model.
const Moose::Functor< ADReal > & _rho_d
Dispersed Phase Density.
unsigned int _index
index of the velocity component x|y|z
MooseVariableField< Real > *const _v_var
y-velocity
WCNSFV2PSlipVelocityFunctorMaterial(const InputParameters &parameters)
const Moose::Functor< ADReal > & _particle_diameter
Particle diameter in the dispersed phase.
const Moose::Functor< ADReal > & _rho_mixture
Continuous phase density.
const Function & _force_function
Force optional function value.
const PostprocessorValue & _force_postprocessor
Optional Force Postprocessor value.
MooseVariableField< Real > *const _u_var
x-velocity
RealVectorValue _force_direction
Force direction vector.
const Moose::Functor< ADReal > & _mu_mixture
Mixture density.
const unsigned int _dim
the dimension of the simulation
MooseVariableField< Real > *const _w_var
z-velocity
const Moose::Functor< ADReal > & _linear_friction
The linear friction factor, for laminar flow.
MeshBase & mesh
static const std::string density
Definition NS.h:34
static const std::string mu
Definition NS.h:127