https://mooseframework.inl.gov
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  {
59  if (_dim > 1)
60  velocity(1) = (*_v_var)(r, t);
61  if (_dim > 2)
62  velocity(2) = (*_w_var)(r, t);
63  const auto speed = NS::computeSpeed(velocity);
64 
65  const auto Re_particle =
66  _particle_diameter(r, t) * speed * _rho_mixture(r, t) / _mu_mixture(r, t);
67 
68  if (Re_particle <= 1000)
69  {
70  if (MetaPhysicL::raw_value(Re_particle) < 0)
71  mooseException("Cannot take a non-integer power of a negative number");
72  return 1.0 + 0.15 * std::pow(Re_particle, 0.687);
73  }
74  else
75  return 0.0183 * Re_particle;
76  };
77  const auto & f_func = addFunctorProperty<ADReal>(getParam<MooseFunctorName>("drag_coef_name"), f);
78 
79  // Define the vector friction coefficient
80  const auto f_vec = [&f_func](const auto & r, const auto & t) -> ADRealVectorValue
81  {
82  const auto f_value = f_func(r, t);
83  return ADRealVectorValue(f_value, f_value, f_value);
84  };
85  addFunctorProperty<ADRealVectorValue>(getParam<MooseFunctorName>("drag_coef_name") + "_vec",
86  f_vec);
87 }
static const std::string speed
Definition: NS.h:143
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
NSFVDispersePhaseDragFunctorMaterial(const InputParameters &parameters)
MeshBase & mesh
static const std::string density
Definition: NS.h:33
auto raw_value(const Eigen::Map< T > &in)
const Moose::Functor< ADReal > & _mu_mixture
Mixture density.
const Moose::Functor< ADReal > * _w_var
z-velocity
This is the material class used to compute phase-averaged drag properties of mixtures.
DualNumber< Real, DNDerivativeType, true > ADReal
const Moose::Functor< ADReal > & _u_var
x-velocity
void addRequiredParam(const std::string &name, const std::string &doc_string)
const Moose::Functor< ADReal > & _rho_mixture
Continuous phase density.
registerMooseObject("NavierStokesApp", NSFVDispersePhaseDragFunctorMaterial)
Real f(Real x)
Test function for Brents method.
static const std::string mu
Definition: NS.h:123
void paramError(const std::string &param, Args... args) const
const unsigned int _dim
the dimension of the simulation
const Moose::Functor< ADReal > & _particle_diameter
Particle diameter in the dispersed phase.
void addClassDescription(const std::string &doc_string)
static const std::string velocity
Definition: NS.h:45
const Moose::Functor< ADReal > * _v_var
y-velocity
ADReal computeSpeed(const ADRealVectorValue &velocity)
Compute the speed (velocity norm) given the supplied velocity.
MooseUnits pow(const MooseUnits &, int)