https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NavierStokesMethods.h
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
10#pragma once
11
12#include <vector>
13#include "Moose.h"
14#include "MooseUtils.h"
15#include "ADReal.h"
16#include "metaphysicl/raw_type.h"
17#include "FEProblemBase.h"
18#include "SubProblem.h"
19
20namespace NS
21{
28int delta(unsigned int i, unsigned int j);
29
35int computeSign(const Real & a);
36
44unsigned int getIndex(const Real & p, const std::vector<Real> & bounds);
45
67 const Real & Re, const Real & rho, const Real & mu, const Real & drho, const Real & dmu);
68
85Real prandtlPropertyDerivative(const Real & mu,
86 const Real & cp,
87 const Real & k,
88 const Real & dmu,
89 const Real & dcp,
90 const Real & dk);
91
102template <typename T>
103T findUStar(const T & mu, const T & rho, const T & u, Real dist);
104
113template <typename T>
114T findYplusThermal(const T & Pr, const T & Pr_t);
115
125template <typename T>
126T findyPlus(const T & mu, const T & rho, const T & u, Real dist);
127
128using MooseUtils::isZero;
129
133template <typename T>
135
139template <typename T>
141 const Moose::Functor<T> * v,
142 const Moose::Functor<T> * w,
143 const Moose::ElemArg & elem_arg,
144 const Moose::StateArg & state,
146 const unsigned int rz_radial_coord = 0);
147
152void getWallBoundedElements(const std::vector<BoundaryName> & wall_boundary_name,
153 const FEProblemBase & fe_problem,
154 const SubProblem & subproblem,
155 const std::set<SubdomainID> & block_ids,
156 std::unordered_set<const Elem *> & wall_bounded);
157
162void getWallDistance(const std::vector<BoundaryName> & wall_boundary_name,
163 const FEProblemBase & fe_problem,
164 const SubProblem & subproblem,
165 const std::set<SubdomainID> & block_ids,
166 std::map<const Elem *, std::vector<Real>> & dist_map);
167
172void getElementFaceArgs(const std::vector<BoundaryName> & wall_boundary_name,
173 const FEProblemBase & fe_problem,
174 const SubProblem & subproblem,
175 const std::set<SubdomainID> & block_ids,
176 std::map<const Elem *, std::vector<const FaceInfo *>> & face_info_map);
177
181template <typename T, typename VectorType, typename PointType>
182T
183divergence(const TensorValue<T> & gradient,
184 const VectorType & value,
185 const PointType & point,
186 const Moose::CoordinateSystemType & coord_sys,
187 const unsigned int rz_radial_coord)
188{
189 mooseAssert((coord_sys == Moose::COORD_XYZ) || (coord_sys == Moose::COORD_RZ),
190 "This function only supports calculations of divergence in Cartesian and "
191 "axisymmetric coordinate systems");
192 auto div = gradient.tr();
193 if (coord_sys == Moose::COORD_RZ)
194 // u_r / r
195 div += value(rz_radial_coord) / point(rz_radial_coord);
196 return div;
197}
198
207template <typename T1, typename T2, typename T3>
208auto
209wallHeatTransferCoefficient(const T1 & Nu, const T2 & k, const T3 & D_h)
210{
211 return Nu * k / D_h;
212}
213
214// Prevent implicit instantiation in other translation units where these classes are used
215extern template Real
216findUStar<Real>(const Real & mu, const Real & rho, const Real & u, const Real dist);
217extern template ADReal
218findUStar<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real dist);
219
220extern template Real findyPlus<Real>(const Real & mu, const Real & rho, const Real & u, Real dist);
221extern template ADReal
222findyPlus<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, Real dist);
223
226
227extern template Real
229 const Moose::Functor<Real> * v,
230 const Moose::Functor<Real> * w,
231 const Moose::ElemArg & elem_arg,
232 const Moose::StateArg & state,
233 const Moose::CoordinateSystemType coord_sys,
234 const unsigned int rz_radial_coord);
235extern template ADReal
238 const Moose::Functor<ADReal> * w,
239 const Moose::ElemArg & elem_arg,
240 const Moose::StateArg & state,
241 const Moose::CoordinateSystemType coord_sys,
242 const unsigned int rz_radial_coord);
243}
DualNumber< Real, DNDerivativeType, true > ADReal
const Real p
const double Re
const double rho
const double T
CoordinateSystemType
void getWallBoundedElements(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::unordered_set< const Elem * > &wall_bounded)
Map marking wall bounded elements The map passed in wall_bounded_map gets cleared and re-populated.
T findyPlus(const T &mu, const T &rho, const T &u, Real dist)
Finds the non-dimensional wall distance normalized with the friction velocity Implements a fixed-poin...
void getWallDistance(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::map< const Elem *, std::vector< Real > > &dist_map)
Map storing wall ditance for near-wall marked elements The map passed in dist_map gets cleared and re...
int computeSign(const Real &a)
Sign function, returns $+1$ if $a$ is positive and $-1$ if $a$ is negative.
template ADReal findyPlus< ADReal >(const ADReal &mu, const ADReal &rho, const ADReal &u, Real dist)
T computeShearStrainRateNormSquared(const Moose::Functor< T > &u, const Moose::Functor< T > *v, const Moose::Functor< T > *w, const Moose::ElemArg &elem_arg, const Moose::StateArg &state, const Moose::CoordinateSystemType coord_sys=Moose::COORD_XYZ, const unsigned int rz_radial_coord=0)
Utility function to compute the shear strain rate.
template Real computeSpeed< Real >(const libMesh::VectorValue< Real > &velocity)
static const std::string cp
Definition NS.h:125
T divergence(const TensorValue< T > &gradient, const VectorType &value, const PointType &point, const Moose::CoordinateSystemType &coord_sys, const unsigned int rz_radial_coord)
Compute the divergence of a vector given its matrix of derivatives.
Real reynoldsPropertyDerivative(const Real &Re, const Real &rho, const Real &mu, const Real &drho, const Real &dmu)
Computes the derivative of the Reynolds number, $Re\equiv \frac{\rho Vd}{\mu}$, with respect to an ar...
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
static const std::string mu
Definition NS.h:127
static const std::string v
Definition NS.h:85
auto wallHeatTransferCoefficient(const T1 &Nu, const T2 &k, const T3 &D_h)
Compute wall heat transfer coefficient.
static const std::string k
Definition NS.h:134
T findUStar(const T &mu, const T &rho, const T &u, Real dist)
Finds the friction velocity using standard velocity wall functions formulation.
template ADReal computeShearStrainRateNormSquared< ADReal >(const Moose::Functor< ADReal > &u, const Moose::Functor< ADReal > *v, const Moose::Functor< ADReal > *w, const Moose::ElemArg &elem_arg, const Moose::StateArg &state, const Moose::CoordinateSystemType coord_sys, const unsigned int rz_radial_coord)
Real prandtlPropertyDerivative(const Real &mu, const Real &cp, const Real &k, const Real &dmu, const Real &dcp, const Real &dk)
Computes the derivative of the Prandtl number, $Pr\equiv\frac{\mu C_p}{k}$, with respect to an arbitr...
T findYplusThermal(const T &Pr, const T &Pr_t)
Finds the thermal non-dimensional wall distance at which the laminar and logarithmic temperature wall...
unsigned int getIndex(const Real &p, const std::vector< Real > &bounds)
Determines the index $i$ in a sorted array such that the input point is within the $i$-th and $i+1$-t...
template ADReal findUStar< ADReal >(const ADReal &mu, const ADReal &rho, const ADReal &u, const Real dist)
T computeSpeed(const libMesh::VectorValue< T > &velocity)
Compute the speed (velocity norm) given the supplied velocity.
template Real findyPlus< Real >(const Real &mu, const Real &rho, const Real &u, Real dist)
int delta(unsigned int i, unsigned int j)
Delta function, which returns zero if $i\ne j$ and unity if $i=j$.
template Real computeShearStrainRateNormSquared< Real >(const Moose::Functor< Real > &u, const Moose::Functor< Real > *v, const Moose::Functor< Real > *w, const Moose::ElemArg &elem_arg, const Moose::StateArg &state, const Moose::CoordinateSystemType coord_sys, const unsigned int rz_radial_coord)
template Real findUStar< Real >(const Real &mu, const Real &rho, const Real &u, const Real dist)
static const std::string velocity
Definition NS.h:46
void getElementFaceArgs(const std::vector< BoundaryName > &wall_boundary_name, const FEProblemBase &fe_problem, const SubProblem &subproblem, const std::set< SubdomainID > &block_ids, std::map< const Elem *, std::vector< const FaceInfo * > > &face_info_map)
Map storing face arguments to wall bounded faces The map passed in face_info_map gets cleared and re-...