https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearFVMomentumFriction.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{
21 "Computes Darcy and/or Forchheimer resistance in a Navier-Stokes momentum equation.");
22 params.addParam<MooseFunctorName>("Darcy_name", "Name of the Darcy coefficients property.");
23 params.addParam<MooseFunctorName>("Forchheimer_name",
24 "Name of the Forchheimer coefficients property.");
25 params.addParam<MooseFunctorName>(NS::mu, "The dynamic viscosity required by Darcy resistance.");
26 params.addParam<MooseFunctorName>(NS::density, "The density required by Forchheimer resistance.");
27 params.addParam<MooseFunctorName>(NS::porosity, "1", "The porosity.");
28 params.addParam<MooseFunctorName>("u", "The x-component of superficial velocity.");
29 params.addParam<MooseFunctorName>("v", "The y-component of superficial velocity.");
30 params.addParam<MooseFunctorName>("w", "The z-component of superficial velocity.");
31
32 MooseEnum momentum_component("x=0 y=1 z=2");
34 "momentum_component",
35 momentum_component,
36 "The component of the momentum equation that this kernel applies to.");
37
38 return params;
39}
40
43 _index(getParam<MooseEnum>("momentum_component")),
44 _D(isParamValid("Darcy_name") ? &getFunctor<RealVectorValue>("Darcy_name") : nullptr),
45 _F(isParamValid("Forchheimer_name") ? &getFunctor<RealVectorValue>("Forchheimer_name")
46 : nullptr),
47 _mu(isParamValid(NS::mu) ? &getFunctor<Real>(NS::mu) : nullptr),
48 _rho(isParamValid(NS::density) ? &getFunctor<Real>(NS::density) : nullptr),
49 _porosity(getFunctor<Real>(NS::porosity)),
50 _dim(_subproblem.mesh().dimension()),
51 _u(isParamValid("u") ? &getFunctor<Real>("u") : nullptr),
52 _v(isParamValid("v") ? &getFunctor<Real>("v") : nullptr),
53 _w(isParamValid("w") ? &getFunctor<Real>("w") : nullptr)
54{
55 if (!_D && !_F)
56 paramError("Darcy_name", "Provide Darcy_name, Forchheimer_name, or both.");
57 if (_D && !_mu)
58 paramError(NS::mu, "The mu parameter is required when Darcy_name is provided.");
59 if (_F && !_rho)
60 paramError(NS::density, "The rho parameter is required when Forchheimer_name is provided.");
61 if (_F && !_u)
62 paramError("u", "The u parameter is required when Forchheimer_name is provided.");
63 if (_F && _dim >= 2 && !_v)
64 paramError("v", "The v parameter is required for Forchheimer resistance in 2D or 3D.");
65 if (_F && _dim >= 3 && !_w)
66 paramError("w", "The w parameter is required for Forchheimer resistance in 3D.");
67}
68
69Real
71{
72 const auto elem_arg = makeElemArg(_current_elem_info->elem());
73 const auto state = determineState();
74 return computeFrictionCoefficient(elem_arg, state) * _current_elem_volume;
75}
76
77Real
82
83Real
85 const Moose::StateArg & state) const
86{
87 Real coefficient = _D ? (*_mu)(elem_arg, state) * (*_D)(elem_arg, state)(_index) : 0.0;
88
89 if (_F)
90 {
91 const Real porosity = _porosity(elem_arg, state);
92 if (porosity <= 0.0)
93 mooseError("porosity must be positive when using Forchheimer friction.");
94
95 const Real u = (*_u)(elem_arg, state);
96 const Real v = _v ? (*_v)(elem_arg, state) : 0.0;
97 const Real w = _w ? (*_w)(elem_arg, state) : 0.0;
98 const Real speed = NS::computeSpeed(RealVectorValue(u, v, w)) / porosity;
99 coefficient += 0.5 * (*_rho)(elem_arg, state) * (*_F)(elem_arg, state)(_index)*speed;
100 }
101
102 return coefficient;
103}
const double mu
const double v
registerMooseObject("NavierStokesApp", LinearFVMomentumFriction)
const Elem * elem() const
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
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)
const ElemInfo * _current_elem_info
static InputParameters validParams()
Imposes Darcy and/or Forchheimer resistance on the momentum equation.
const Moose::Functor< RealVectorValue > *const _D
Darcy coefficient.
Real computeFrictionCoefficient(const Moose::ElemArg &elem_arg, const Moose::StateArg &state) const
LinearFVMomentumFriction(const InputParameters &params)
const Moose::Functor< Real > *const _mu
Dynamic viscosity.
const Moose::Functor< Real > *const _v
const Moose::Functor< RealVectorValue > *const _F
Forchheimer coefficient.
const Moose::Functor< Real > *const _w
const Moose::Functor< Real > & _porosity
Porosity.
static InputParameters validParams()
const unsigned int _dim
Mesh dimension.
const Moose::Functor< Real > *const _rho
Density.
const unsigned int _index
Index x|y|z of the momentum equation component.
Real computeRightHandSideContribution() override
const Moose::Functor< Real > *const _u
Velocity components used to evaluate the Forchheimer speed.
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
Moose::StateArg determineState() const
MeshBase & mesh
static const std::string density
Definition NS.h:34
static const std::string mu
Definition NS.h:127
static const std::string porosity
Definition NS.h:108
T computeSpeed(const libMesh::VectorValue< T > &velocity)
Compute the speed (velocity norm) given the supplied velocity.