/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_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real
13analytical_smagorinsky_profile(
14 const amrex::Real h,
15 const amrex::Real Cs,
16 const amrex::Real dx,
17 const amrex::Real rho,
18 const amrex::Real mu,
19 const amrex::Real dpdx,
20 const amrex::Real C0,
21 const amrex::Real C1)
22{
23 const amrex::Real Cs2 = Cs * Cs;
24 const amrex::Real dx2 = dx * dx;
25 const amrex::Real Cs2dx2 = Cs2 * dx2;
26 return -mu / (rho * Cs2dx2) * h +
27 Cs2dx2 / (3 * dpdx) *
28 std::pow(
29 (2.0 / Cs2dx2 * dpdx * h +
30 (mu / (rho * Cs2dx2)) * (mu / (rho * Cs2dx2)) + C1),
31 3.0 / 2.0) +
32 C0;
33}
34
35} // namespace
36
37namespace amr_wind::channel_flow {
38
42class ChannelFlow : public Physics::Register<ChannelFlow>
43{
44public:
45 static std::string identifier() { return "ChannelFlow"; }
46
47 explicit ChannelFlow(CFDSim& sim);
48
49 ~ChannelFlow() override = default;
50
51 void initialize_fields(int level, const amrex::Geometry& geom) override;
52
54 template <typename IndexSelector>
56 int level,
57 const amrex::Geometry& geom,
58 const IndexSelector& idxOp,
59 const int n_idx);
60
61 template <typename IndexSelector>
62 amrex::Real compute_error(const IndexSelector& idxOp);
63
65
66 void output_error();
67
68 void post_init_actions() override;
69
70 void post_regrid_actions() override {}
71
72 void pre_advance_work() override {}
73
74 void post_advance_work() override;
75
76private:
79
82 const amrex::AmrCore& m_mesh;
83
85
87 int m_norm_dir{1};
88
90 amrex::Real m_rho{1.0};
91
93 amrex::Real m_mu{1.0};
94
96 amrex::Real m_re_tau{1000.0};
97
99 amrex::Real m_utau{0.01};
100
102 amrex::Real m_ytau{0.001};
103
105 amrex::Real m_tke0{0.0};
106
108 amrex::Real m_sdr0{1000.0};
109
111 bool m_perturb_vel{false};
112
114 amrex::Real m_perturb_y_period{1.0};
115
117 amrex::Real m_perturb_z_period{1.0};
118
120 amrex::Real m_perturb_fac{0.1};
121
123 amrex::Real m_kappa{0.41};
124
127
128 bool m_laminar{false};
129
130 bool m_mesh_mapping{false};
131
132 amrex::Real m_mean_vel;
133
134 bool m_half{false};
135
138
140 amrex::Real m_C0{0.0};
141
143 amrex::Real m_C1{0.0};
144
146 amrex::Real m_dpdx{0.0};
147
150
152 const int m_w{18};
153
155 std::string m_output_fname{"channel_flow.log"};
156};
157} // namespace amr_wind::channel_flow
158
159#endif /* ChannelFlow_H */
Definition CFDSim.H:47
Definition FieldRepo.H:86
Definition SimTime.H:30
Definition WallFunction.H:19
Definition ChannelFlow.H:43
bool m_half
Definition ChannelFlow.H:134
ChannelFlow(CFDSim &sim)
Definition ChannelFlow.cpp:11
bool m_perturb_vel
flag for perturbations of the initial condition
Definition ChannelFlow.H:111
amrex::Real m_sdr0
initial sdr value
Definition ChannelFlow.H:108
bool m_mesh_mapping
Definition ChannelFlow.H:130
const amrex::AmrCore & m_mesh
Definition ChannelFlow.H:82
amrex::Real m_perturb_y_period
perturbation period (y-direction)
Definition ChannelFlow.H:114
amrex::Real m_perturb_fac
perturbation factor (fraction of utau)
Definition ChannelFlow.H:120
const amr_wind::SimTime & m_time
Definition ChannelFlow.H:80
const int m_w
output precision
Definition ChannelFlow.H:152
amrex::Real m_C0
Analytical Smagorinsky first coefficient.
Definition ChannelFlow.H:140
CFDSim & m_sim
CFD simulation controller instance.
Definition ChannelFlow.H:78
WallFunction m_wall_func
Definition ChannelFlow.H:84
amrex::Real m_C1
Analytical Smagorinsky second coefficient.
Definition ChannelFlow.H:143
amrex::Real m_mu
viscosity
Definition ChannelFlow.H:93
int m_norm_dir
Wall normal direction - Default y direction.
Definition ChannelFlow.H:87
void post_regrid_actions() override
Definition ChannelFlow.H:70
int m_mean_vel_dir
direction of mean velocity
Definition ChannelFlow.H:149
std::string m_turbulence_model
Turbulence model.
Definition ChannelFlow.H:126
void pre_advance_work() override
Definition ChannelFlow.H:72
amrex::Real m_rho
initial density value
Definition ChannelFlow.H:90
amrex::Real compute_error(const IndexSelector &idxOp)
Definition ChannelFlow.cpp:226
amrex::Real m_kappa
Von-Karman constant.
Definition ChannelFlow.H:123
void initialize_fields(int level, const amrex::Geometry &geom) override
Definition ChannelFlow.cpp:98
amrex::Real m_utau
u_tau
Definition ChannelFlow.H:99
amrex::Real m_perturb_z_period
perturbation period (z-direction)
Definition ChannelFlow.H:117
std::string m_output_fname
error log file
Definition ChannelFlow.H:155
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:146
bool m_analytical_smagorinsky_test
flag for analytical smagorinsky test
Definition ChannelFlow.H:137
void post_init_actions() override
Definition ChannelFlow.cpp:431
FieldRepo & m_repo
Definition ChannelFlow.H:81
void output_error()
Definition ChannelFlow.cpp:399
static std::string identifier()
Definition ChannelFlow.H:45
amrex::Real m_mean_vel
Definition ChannelFlow.H:132
amrex::Real m_ytau
y_tau
Definition ChannelFlow.H:102
bool m_laminar
Definition ChannelFlow.H:128
amrex::Real m_tke0
initial tke value
Definition ChannelFlow.H:105
amrex::Real m_re_tau
Re_tau.
Definition ChannelFlow.H:96
Definition ChannelFlow.cpp:9