https://mooseframework.inl.gov
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 
20 namespace NS
21 {
28 int delta(unsigned int i, unsigned int j);
29 
35 int computeSign(const Real & a);
36 
44 unsigned 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 
86  const Real & cp,
87  const Real & k,
88  const Real & dmu,
89  const Real & dcp,
90  const Real & dk);
91 
102 template <typename T>
103 T findUStar(const T & mu, const T & rho, const T & u, Real dist);
104 
114 template <typename T>
115 T findyPlus(const T & mu, const T & rho, const T & u, Real dist);
116 
117 using MooseUtils::isZero;
118 
122 template <typename T>
124 
128 template <typename T>
130  const Moose::Functor<T> * v,
131  const Moose::Functor<T> * w,
132  const Moose::ElemArg & elem_arg,
133  const Moose::StateArg & state,
135  const unsigned int rz_radial_coord = 0);
136 
141 void getWallBoundedElements(const std::vector<BoundaryName> & wall_boundary_name,
142  const FEProblemBase & fe_problem,
143  const SubProblem & subproblem,
144  const std::set<SubdomainID> & block_ids,
145  std::unordered_set<const Elem *> & wall_bounded);
146 
151 void getWallDistance(const std::vector<BoundaryName> & wall_boundary_name,
152  const FEProblemBase & fe_problem,
153  const SubProblem & subproblem,
154  const std::set<SubdomainID> & block_ids,
155  std::map<const Elem *, std::vector<Real>> & dist_map);
156 
161 void getElementFaceArgs(const std::vector<BoundaryName> & wall_boundary_name,
162  const FEProblemBase & fe_problem,
163  const SubProblem & subproblem,
164  const std::set<SubdomainID> & block_ids,
165  std::map<const Elem *, std::vector<const FaceInfo *>> & face_info_map);
166 
170 template <typename T, typename VectorType, typename PointType>
171 T
172 divergence(const TensorValue<T> & gradient,
173  const VectorType & value,
174  const PointType & point,
175  const Moose::CoordinateSystemType & coord_sys,
176  const unsigned int rz_radial_coord)
177 {
178  mooseAssert((coord_sys == Moose::COORD_XYZ) || (coord_sys == Moose::COORD_RZ),
179  "This function only supports calculations of divergence in Cartesian and "
180  "axisymmetric coordinate systems");
181  auto div = gradient.tr();
182  if (coord_sys == Moose::COORD_RZ)
183  // u_r / r
184  div += value(rz_radial_coord) / point(rz_radial_coord);
185  return div;
186 }
187 
196 template <typename T1, typename T2, typename T3>
197 auto
198 wallHeatTransferCoefficient(const T1 & Nu, const T2 & k, const T3 & D_h)
199 {
200  return Nu * k / D_h;
201 }
202 
203 // Prevent implicit instantiation in other translation units where these classes are used
204 extern template Real
205 findUStar<Real>(const Real & mu, const Real & rho, const Real & u, const Real dist);
206 extern template ADReal
207 findUStar<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real dist);
208 
209 extern template Real findyPlus<Real>(const Real & mu, const Real & rho, const Real & u, Real dist);
210 extern template ADReal
211 findyPlus<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, Real dist);
212 
215 
216 extern template Real
218  const Moose::Functor<Real> * v,
219  const Moose::Functor<Real> * w,
220  const Moose::ElemArg & elem_arg,
221  const Moose::StateArg & state,
222  const Moose::CoordinateSystemType coord_sys,
223  const unsigned int rz_radial_coord);
224 extern template ADReal
226  const Moose::Functor<ADReal> * v,
227  const Moose::Functor<ADReal> * w,
228  const Moose::ElemArg & elem_arg,
229  const Moose::StateArg & state,
230  const Moose::CoordinateSystemType coord_sys,
231  const unsigned int rz_radial_coord);
232 }
int computeSign(const Real &a)
Sign function, returns $+1$ if $a$ is positive and $-1$ if $a$ is negative.
const double T
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.
T computeSpeed(const libMesh::VectorValue< T > &velocity)
Compute the speed (velocity norm) given the supplied velocity.
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{ C_p}{k}$, with respect to an arbitrary variale $$...
int delta(unsigned int i, unsigned int j)
Delta function, which returns zero if $i j$ and unity if $i=j$.
template Real findUStar< Real >(const Real &mu, const Real &rho, const Real &u, const Real dist)
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...
DualNumber< Real, DNDerivativeType, false > ADReal
template Real findyPlus< Real >(const Real &mu, const Real &rho, const Real &u, Real dist)
static const std::string cp
Definition: NS.h:125
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static const std::string mu
Definition: NS.h:127
const double rho
const double Re
template ADReal findUStar< ADReal >(const ADReal &mu, const ADReal &rho, const ADReal &u, const Real dist)
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 { Vd}{}$, with respect to an arbitrary variable $...
auto wallHeatTransferCoefficient(const T1 &Nu, const T2 &k, const T3 &D_h)
Compute wall heat transfer coefficient.
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...
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...
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)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:85
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
CoordinateSystemType
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)
const Real p
template ADReal findyPlus< ADReal >(const ADReal &mu, const ADReal &rho, const ADReal &u, Real dist)
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-...
static const std::string velocity
Definition: NS.h:46
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
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...
template Real computeSpeed< Real >(const libMesh::VectorValue< Real > &velocity)
T findUStar(const T &mu, const T &rho, const T &u, Real dist)
Finds the friction velocity using standard velocity wall functions formulation.
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.
static const std::string k
Definition: NS.h:134