/home/runner/work/amr-wind/amr-wind/amr-wind/physics/ChannelFlow.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/ChannelFlow.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
ChannelFlow.H
Go to the documentation of this file.
1#ifndef ChannelFlow_H
2#define ChannelFlow_H
3
6#include "amr-wind/CFDSim.H"
9#include <AMReX_REAL.H>
10
11namespace {
12AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real analytical_smagorinsky_profile(
13 const amrex::Real h,
14 const amrex::Real Cs,
15 const amrex::Real dx,
16 const amrex::Real rho,
17 const amrex::Real mu,
18 const amrex::Real dpdx,
19 const amrex::Real C0,
20 const amrex::Real C1)
21{
22 const amrex::Real Cs2 = Cs * Cs;
23 const amrex::Real dx2 = dx * dx;
24 const amrex::Real Cs2dx2 = Cs2 * dx2;
25 return -mu / (rho * Cs2dx2) * h +
26 Cs2dx2 / (3 * dpdx) *
27 std::pow(
28 (2.0 / Cs2dx2 * dpdx * h +
29 (mu / (rho * Cs2dx2)) * (mu / (rho * Cs2dx2)) + C1),
30 3.0 / 2.0) +
31 C0;
32}
33
34} // namespace
35
36namespace amr_wind::channel_flow {
37
41class ChannelFlow : public Physics::Register<ChannelFlow>
42{
43public:
44 static std::string identifier() { return "ChannelFlow"; }
45
46 explicit ChannelFlow(CFDSim& sim);
47
48 ~ChannelFlow() override = default;
49
50 void initialize_fields(int level, const amrex::Geometry& geom) override;
51
53 template <typename IndexSelector>
55 int level,
56 const amrex::Geometry& geom,
57 const IndexSelector& idxOp,
58 const int n_idx);
59
60 template <typename IndexSelector>
61 amrex::Real compute_error(const IndexSelector& idxOp);
62
64
65 void output_error();
66
67 void post_init_actions() override;
68
69 void post_regrid_actions() override {}
70
71 void pre_advance_work() override {}
72
73 void post_advance_work() override;
74
75private:
78
81 const amrex::AmrCore& m_mesh;
82
84
86 int m_norm_dir{1};
87
89 amrex::Real m_rho{1.0};
90
92 amrex::Real m_mu{1.0};
93
95 amrex::Real m_re_tau{1000.0};
96
98 amrex::Real m_utau{0.01};
99
101 amrex::Real m_ytau{0.001};
102
104 amrex::Real m_tke0{0.0};
105
107 amrex::Real m_sdr0{1000.0};
108
110 bool m_perturb_vel{false};
111
113 amrex::Real m_perturb_y_period{1.0};
114
116 amrex::Real m_perturb_z_period{1.0};
117
119 amrex::Real m_perturb_fac{0.1};
120
122 amrex::Real m_kappa{0.41};
123
126
127 bool m_laminar{false};
128
129 bool m_mesh_mapping{false};
130
131 amrex::Real m_mean_vel;
132
133 bool m_half{false};
134
137
139 amrex::Real m_C0{0.0};
140
142 amrex::Real m_C1{0.0};
143
145 amrex::Real m_dpdx{0.0};
146
149
151 const int m_w{18};
152
154 std::string m_output_fname{"channel_flow.log"};
155};
156} // namespace amr_wind::channel_flow
157
158#endif /* ChannelFlow_H */
Definition CFDSim.H:47
Definition FieldRepo.H:86
Definition SimTime.H:30
Definition WallFunction.H:20
Definition ChannelFlow.H:42
bool m_half
Definition ChannelFlow.H:133
ChannelFlow(CFDSim &sim)
Definition ChannelFlow.cpp:11
bool m_perturb_vel
flag for perturbations of the initial condition
Definition ChannelFlow.H:110
amrex::Real m_sdr0
initial sdr value
Definition ChannelFlow.H:107
bool m_mesh_mapping
Definition ChannelFlow.H:129
const amrex::AmrCore & m_mesh
Definition ChannelFlow.H:81
amrex::Real m_perturb_y_period
perturbation period (y-direction)
Definition ChannelFlow.H:113
amrex::Real m_perturb_fac
perturbation factor (fraction of utau)
Definition ChannelFlow.H:119
const amr_wind::SimTime & m_time
Definition ChannelFlow.H:79
const int m_w
output precision
Definition ChannelFlow.H:151
amrex::Real m_C0
Analytical Smagorinsky first coefficient.
Definition ChannelFlow.H:139
CFDSim & m_sim
CFD simulation controller instance.
Definition ChannelFlow.H:77
WallFunction m_wall_func
Definition ChannelFlow.H:83
amrex::Real m_C1
Analytical Smagorinsky second coefficient.
Definition ChannelFlow.H:142
amrex::Real m_mu
viscosity
Definition ChannelFlow.H:92
int m_norm_dir
Wall normal direction - Default y direction.
Definition ChannelFlow.H:86
void post_regrid_actions() override
Definition ChannelFlow.H:69
int m_mean_vel_dir
direction of mean velocity
Definition ChannelFlow.H:148
std::string m_turbulence_model
Turbulence model.
Definition ChannelFlow.H:125
void pre_advance_work() override
Definition ChannelFlow.H:71
amrex::Real m_rho
initial density value
Definition ChannelFlow.H:89
amrex::Real compute_error(const IndexSelector &idxOp)
Definition ChannelFlow.cpp:226
amrex::Real m_kappa
Von-Karman constant.
Definition ChannelFlow.H:122
void initialize_fields(int level, const amrex::Geometry &geom) override
Definition ChannelFlow.cpp:98
amrex::Real m_utau
u_tau
Definition ChannelFlow.H:98
amrex::Real m_perturb_z_period
perturbation period (z-direction)
Definition ChannelFlow.H:116
std::string m_output_fname
error log file
Definition ChannelFlow.H:154
amrex::Real compute_analytical_smagorinsky_error()
Definition ChannelFlow.cpp:334
void post_advance_work() override
Definition ChannelFlow.cpp:456
amrex::Real m_dpdx
Body forcing (x direction)
Definition ChannelFlow.H:145
bool m_analytical_smagorinsky_test
flag for analytical smagorinsky test
Definition ChannelFlow.H:136
void post_init_actions() override
Definition ChannelFlow.cpp:431
FieldRepo & m_repo
Definition ChannelFlow.H:80
void output_error()
Definition ChannelFlow.cpp:399
static std::string identifier()
Definition ChannelFlow.H:44
amrex::Real m_mean_vel
Definition ChannelFlow.H:131
amrex::Real m_ytau
y_tau
Definition ChannelFlow.H:101
bool m_laminar
Definition ChannelFlow.H:127
amrex::Real m_tke0
initial tke value
Definition ChannelFlow.H:104
amrex::Real m_re_tau
Re_tau.
Definition ChannelFlow.H:95
Definition ChannelFlow.cpp:9