https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSFVDispersePhaseDragFunctorMaterial.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 "NavierStokesMethods.h"
13
15
18{
20 params.addClassDescription("Computes drag coefficient for dispersed phase.");
21 params.addParam<MooseFunctorName>("drag_coef_name",
22 "Darcy_coefficient",
23 "Name of the scalar friction coefficient defined. The vector "
24 "coefficient is suffixed with _vec");
25 params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
26 params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
27 params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
28 params.addRequiredParam<MooseFunctorName>(NS::density, "Continuous phase density.");
29 params.addRequiredParam<MooseFunctorName>(NS::mu, "Mixture Density");
30 params.addParam<MooseFunctorName>(
31 "particle_diameter", 1.0, "Diameter of particles in the dispersed phase.");
32 return params;
33}
34
36 const InputParameters & parameters)
37 : FunctorMaterial(parameters),
38 _dim(_subproblem.mesh().dimension()),
39 _u_var(getFunctor<ADReal>("u")),
40 _v_var(parameters.isParamValid("v") ? &(getFunctor<ADReal>("v")) : nullptr),
41 _w_var(parameters.isParamValid("w") ? &(getFunctor<ADReal>("w")) : nullptr),
42 _rho_mixture(getFunctor<ADReal>(NS::density)),
43 _mu_mixture(getFunctor<ADReal>(NS::mu)),
44 _particle_diameter(getFunctor<ADReal>("particle_diameter"))
45{
46 if (_dim >= 2 && !_v_var)
47 paramError("v",
48 "In two or more dimensions, the v velocity must be supplied and it must be an "
49 "INSFVVelocityVariable.");
50
51 if (_dim >= 3 && !_w_var)
52 paramError("w",
53 "In three-dimensions, the w velocity must be supplied and it must be an "
54 "INSFVVelocityVariable.");
55
56 const auto f = [this](const auto & r, const auto & t) -> ADReal
57 {
58 using std::pow;
59
60 ADRealVectorValue velocity(_u_var(r, t));
61 if (_dim > 1)
62 velocity(1) = (*_v_var)(r, t);
63 if (_dim > 2)
64 velocity(2) = (*_w_var)(r, t);
65 const auto speed = NS::computeSpeed<ADReal>(velocity);
66
67 const auto Re_particle =
68 _particle_diameter(r, t) * speed * _rho_mixture(r, t) / _mu_mixture(r, t);
69
70 if (Re_particle <= 1000)
71 {
72 if (MetaPhysicL::raw_value(Re_particle) < 0)
73 mooseException("Cannot take a non-integer power of a negative number");
74 return 1.0 + 0.15 * pow(Re_particle, 0.687);
75 }
76 else
77 return 0.0183 * Re_particle;
78 };
79 const auto & f_func = addFunctorProperty<ADReal>(getParam<MooseFunctorName>("drag_coef_name"), f);
80
81 // Define the vector friction coefficient
82 const auto f_vec = [&f_func](const auto & r, const auto & t) -> ADRealVectorValue
83 {
84 const auto f_value = f_func(r, t);
85 return ADRealVectorValue(f_value, f_value, f_value);
86 };
87 addFunctorProperty<ADRealVectorValue>(getParam<MooseFunctorName>("drag_coef_name") + "_vec",
88 f_vec);
89}
DualNumber< Real, DNDerivativeType, true > ADReal
Real f(Real x)
Test function for Brents method.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double mu
registerMooseObject("NavierStokesApp", NSFVDispersePhaseDragFunctorMaterial)
static InputParameters validParams()
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)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
This is the material class used to compute phase-averaged drag properties of mixtures.
const Moose::Functor< ADReal > & _mu_mixture
Mixture density.
const Moose::Functor< ADReal > & _rho_mixture
Continuous phase density.
const Moose::Functor< ADReal > * _v_var
y-velocity
const Moose::Functor< ADReal > * _w_var
z-velocity
const Moose::Functor< ADReal > & _u_var
x-velocity
const unsigned int _dim
the dimension of the simulation
NSFVDispersePhaseDragFunctorMaterial(const InputParameters &parameters)
const Moose::Functor< ADReal > & _particle_diameter
Particle diameter in the dispersed phase.
MeshBase & mesh
auto raw_value(const Eigen::Map< T > &in)
static const std::string density
Definition NS.h:34
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
static const std::string mu
Definition NS.h:127