/home/runner/work/amr-wind/amr-wind/amr-wind/turbulence/LES/AMD.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/turbulence/LES/AMD.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
AMD.H
Go to the documentation of this file.
1#ifndef AMD_H
2#define AMD_H
3
4#include <AMReX_GpuContainers.H>
5#include <string>
12
13namespace amr_wind::turbulence {
17template <typename Transport>
18class AMD : public TurbModelBase<Transport>
19{
20public:
21 static std::string identifier() { return "AMD-" + Transport::identifier(); }
22
23 explicit AMD(CFDSim& sim);
24
26 std::string model_name() const override { return "AMD"; }
27
30 const FieldState fstate, const DiffusionType /*unused*/) override;
31
32 template <typename IndexSelector>
34 const FieldState fstate, const IndexSelector& idxOp);
35
37 void update_alphaeff(Field& alphaeff) override;
38
41
43 void parse_model_coeffs() override;
44
46 void post_advance_work() override {};
47
48private:
51 amrex::Real m_C{0.333333333333333};
52
54 amrex::Real m_ref_theta{300.0};
55
58
59 const Field& m_vel;
61 const Field& m_rho;
63 amrex::Vector<amrex::Real> m_gravity{0.0, 0.0, -9.81};
64};
65
66AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real amd_muvel(
67 int i,
68 int j,
69 int k,
70 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dx, // Grid spacing
71 const amrex::Real beta, // Thermal expansion coefficient
72 const amrex::Real C, // Poincare const
73 const amrex::Array4<amrex::Real const>& gradVel,
74 const amrex::Array4<amrex::Real const>& gradT,
75 const amrex::Real* gradTbar_coord_begin,
76 const amrex::Real* gradTbar_coord_end,
77 const amrex::Real* gradTbar,
78 const int normal_dir,
79 const amrex::Real nlo) noexcept
80{
81 amrex::Real num_shear = 0;
82 amrex::Real num_buoy = 0;
83 amrex::Real denom = 0;
84 const int n_ind = amr_wind::direction_selector(i, j, k, normal_dir);
85 const amrex::Real h = nlo + (n_ind + 0.5) * dx[normal_dir];
86 const amrex::Real gradTbar_h = amr_wind::interp::linear(
87 gradTbar_coord_begin, gradTbar_coord_end, gradTbar, h);
88 for (int ii = 0; ii < AMREX_SPACEDIM; ++ii) {
89 // This should operate only on the wall normal velocity
90 num_buoy +=
91 gradVel(i, j, k, normal_dir * AMREX_SPACEDIM + ii) *
92 (gradT(i, j, k, ii) - ((ii == normal_dir) ? gradTbar_h : 0.0)) *
93 dx[ii] * dx[ii];
94
95 for (int jj = 0; jj < AMREX_SPACEDIM; ++jj) {
96 const amrex::Real diuj = gradVel(i, j, k, ii * AMREX_SPACEDIM + jj);
97 const amrex::Real djui = gradVel(i, j, k, jj * AMREX_SPACEDIM + ii);
98 denom += diuj * diuj;
99 const amrex::Real sij = 0.5 * (diuj + djui);
100 for (int kk = 0; kk < AMREX_SPACEDIM; ++kk) {
101 const amrex::Real dkui =
102 gradVel(i, j, k, ii * AMREX_SPACEDIM + kk);
103 const amrex::Real dkuj =
104 gradVel(i, j, k, jj * AMREX_SPACEDIM + kk);
105 num_shear += dkui * dkuj * dx[kk] * dx[kk] * sij;
106 }
107 }
108 }
109 denom = std::max(1e-15, denom);
110 num_shear *= -C;
111 num_buoy *= C * beta;
112 return std::max(1e-15, (num_shear + num_buoy) / denom);
113}
114
115AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real amd_thermal_diff(
116 int i,
117 int j,
118 int k,
119 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dx, // Grid spacing
120 const amrex::Real C, // Poincare const
121 const amrex::Array4<amrex::Real const>& gradVel,
122 const amrex::Array4<amrex::Real const>& gradT) noexcept
123{
124 amrex::Real num = 0;
125 amrex::Real denom = 0;
126 for (int ii = 0; ii < AMREX_SPACEDIM; ++ii) {
127 const amrex::Real diT = gradT(i, j, k, ii);
128 denom += diT * diT;
129 for (int kk = 0; kk < AMREX_SPACEDIM; ++kk) {
130 const amrex::Real dkui = gradVel(i, j, k, ii * AMREX_SPACEDIM + kk);
131 const amrex::Real dkT = gradT(i, j, k, kk);
132 num += dkui * diT * dkT * dx[kk] * dx[kk];
133 }
134 }
135
136 denom = std::max(1e-15, denom);
137 num *= -C;
138 return std::max(1e-15, num / denom);
139}
140
141} // namespace amr_wind::turbulence
142
143#endif /* AMD_H */
Definition CFDSim.H:47
Definition Field.H:116
Definition AMD.H:19
amrex::Vector< amrex::Real > m_gravity
Definition AMD.H:63
void update_turbulent_viscosity(const FieldState fstate, const IndexSelector &idxOp)
void update_turbulent_viscosity(const FieldState fstate, const DiffusionType) override
Update the turbulent viscosity field.
Definition AMD.cpp:48
const Field & m_temperature
Definition AMD.H:60
amrex::Real m_ref_theta
Reference temperature (Kelvin)
Definition AMD.H:54
AMD(CFDSim &sim)
Definition AMD.cpp:19
FieldPlaneAveraging m_pa_temp
Definition AMD.H:62
std::string model_name() const override
Model name for debugging purposes.
Definition AMD.H:26
void parse_model_coeffs() override
Parse turbulence model coefficients for this model.
Definition AMD.cpp:40
amrex::Real m_C
Definition AMD.H:51
void update_alphaeff(Field &alphaeff) override
Update the effective thermal diffusivity field.
Definition AMD.cpp:125
TurbulenceModel::CoeffsDictType model_coeffs() const override
Return model coefficients dictionary.
Definition AMD.cpp:161
static std::string identifier()
Definition AMD.H:21
const Field & m_rho
Definition AMD.H:61
const Field & m_vel
Definition AMD.H:59
int m_normal_dir
Wall-normal direction axis.
Definition AMD.H:57
void post_advance_work() override
No post advance work for this model.
Definition AMD.H:46
Definition TurbModelBase.H:96
Field & alphaeff() override
Return the effective thermal diffusivity field.
Definition TurbModel.H:53
std::unordered_map< std::string, amrex::Real > CoeffsDictType
Default identifier used by factor methods.
Definition TurbulenceModel.H:35
FieldState
Definition FieldDescTypes.H:14
DiffusionType
Definition incflo_enums.H:4
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::iterator_traits< C2 >::value_type linear(const C1 xbegin, const C1 xend, const C2 yinp, const typename std::iterator_traits< C1 >::value_type &xout, const int ncomp=1, const int comp=0)
Definition linear_interpolation.H:126
Definition CFDSim.H:23
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real amd_thermal_diff(int i, int j, int k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx, const amrex::Real C, const amrex::Array4< amrex::Real const > &gradVel, const amrex::Array4< amrex::Real const > &gradT) noexcept
Definition AMD.H:115
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real amd_muvel(int i, int j, int k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx, const amrex::Real beta, const amrex::Real C, const amrex::Array4< amrex::Real const > &gradVel, const amrex::Array4< amrex::Real const > &gradT, const amrex::Real *gradTbar_coord_begin, const amrex::Real *gradTbar_coord_end, const amrex::Real *gradTbar, const int normal_dir, const amrex::Real nlo) noexcept
Definition AMD.H:66
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int direction_selector(const int i, const int j, const int k, const int dir)
Definition DirectionSelector.H:111
Second-order finite volume discretization stencil coefficients.