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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/SyntheticTurbulence.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
SyntheticTurbulence.H
Go to the documentation of this file.
1#ifndef SyntheticTurbulence_H
2#define SyntheticTurbulence_H
3
4#include <string>
5#include <cmath>
6#include <memory>
7
11#include "amr-wind/CFDSim.H"
12
13namespace amr_wind {
14
15namespace synth_turb {
16
18{
19 AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real
20 operator()(double /* height */) const
21 {
22 return m_ref_vel;
23 }
24
25 const double m_ref_vel;
26};
27
29{
30public:
31 explicit MeanProfile(double ref_vel, int shear_dir = 2)
32 : m_op{ref_vel}, m_ref_vel(ref_vel), m_shear_dir(shear_dir)
33 {}
34
35 virtual ~MeanProfile() = default;
36
37 inline amrex::Real reference_velocity() const { return m_ref_vel; }
38
39 inline int shear_dir() const { return m_shear_dir; }
40
41 MeanVelOp device_instance() const { return m_op; }
42
43private:
45
46 const double m_ref_vel;
47 const int m_shear_dir;
48};
49
50} // namespace synth_turb
51
53{
54 // Dimensions of the box
56
57 // Length of the boxes in each direction
59
61
62 // Reference point for the turbulence box. Reference is the mid-point of the
63 // turbulence grid at the plane where it is injected into the CFD flow
64 // field.
66
67 // Transformation matrix to convert from global coordinate system to local
68 // coordinate system
70
71 // Perturbation velocities (2, ny, nz)
72 amrex::Vector<double> uvel;
73 amrex::Vector<double> vvel;
74 amrex::Vector<double> wvel;
75
76 amrex::Gpu::DeviceVector<double> uvel_d;
77 amrex::Gpu::DeviceVector<double> vvel_d;
78 amrex::Gpu::DeviceVector<double> wvel_d;
79
80 // Indices of the two planes stored in the data arrays
81 int ileft;
82 int iright;
83};
84
86{
87 // Dimensions of the box
89
90 // Length of the boxes in each direction
92
94
95 // Reference point for the turbulence box. Reference is the mid-point of the
96 // turbulence grid at the plane where it is injected into the CFD flow
97 // field.
99
100 // Transformation matrix to convert from global coordinate system to local
101 // coordinate system
103
104 double* uvel;
105 double* vvel;
106 double* wvel;
107
108 // Indices of the two planes stored in the data arrays
109 int ileft;
111
113 : box_dims(hdata.box_dims)
114 , box_len(hdata.box_len)
115 , dx(hdata.dx)
116 , origin(hdata.origin)
117 , tr_mat(hdata.tr_mat)
118 , uvel(hdata.uvel_d.data())
119 , vvel(hdata.vvel_d.data())
120 , wvel(hdata.wvel_d.data())
121 , ileft(hdata.ileft)
122 , iright(hdata.iright)
123 {}
124};
125
130{
131 int il, ir, jl, jr, kl, kr;
132 amrex::Real xl, xr, yl, yr, zl, zr;
133};
134
147class SyntheticTurbulence : public Physics::Register<SyntheticTurbulence>
148{
149public:
150 static std::string identifier() { return "SyntheticTurbulence"; }
151
152 explicit SyntheticTurbulence(const CFDSim& sim);
153
157
158 ~SyntheticTurbulence() override = default;
159
160 void initialize_fields(int level, const amrex::Geometry& geom) override;
161
162 void post_init_actions() override {}
163
164 void post_regrid_actions() override {}
165
166 void pre_advance_work() override;
167
168 void post_advance_work() override {}
169
170 void initialize();
171
172 void update();
173
174 template <typename T>
175 void update_impl(
176 const SynthTurbDeviceData& /*turb_grid*/,
177 const InterpWeights& /*weights*/,
178 const T& /*velfunc*/);
179
180private:
183 const amrex::AmrCore& m_mesh;
187
188 // Turbulence file name
189 std::string m_turb_filename;
190
191 // Turbulence box data
193
194 std::unique_ptr<synth_turb::MeanProfile> m_wind_profile;
195
196 std::string m_mean_wind_type{"ConstValue"};
197 amrex::Real m_epsilon;
198 amrex::Real m_gauss_scaling;
199
200 amrex::Real m_time_offset{0.0};
201 // Duration of the synthetic turbulence injection. Unused if < 0
202 amrex::Real m_duration{-1};
203
204 bool m_is_init{true};
205};
206
207} // namespace amr_wind
208
209#endif /* SyntheticTurbulence_H */
Definition CFDSim.H:47
Definition Field.H:116
Definition FieldRepo.H:86
Definition SimTime.H:30
Definition SyntheticTurbulence.H:148
static std::string identifier()
Definition SyntheticTurbulence.H:150
~SyntheticTurbulence() override=default
SyntheticTurbulence(const SyntheticTurbulence &)=delete
std::string m_turb_filename
Definition SyntheticTurbulence.H:189
void pre_advance_work() override
Definition SyntheticTurbulence.cpp:484
amrex::Real m_time_offset
Definition SyntheticTurbulence.H:200
void post_advance_work() override
Definition SyntheticTurbulence.H:168
void update_impl(const SynthTurbDeviceData &, const InterpWeights &, const T &)
Definition SyntheticTurbulence.cpp:554
bool m_is_init
Definition SyntheticTurbulence.H:204
SyntheticTurbulence & operator=(const SyntheticTurbulence &)=delete
const amr_wind::SimTime & m_time
Definition SyntheticTurbulence.H:181
Field & m_density
Definition SyntheticTurbulence.H:185
Field & m_velocity
Definition SyntheticTurbulence.H:184
void post_regrid_actions() override
Definition SyntheticTurbulence.H:164
void initialize()
Definition SyntheticTurbulence.cpp:493
void initialize_fields(int level, const amrex::Geometry &geom) override
Definition SyntheticTurbulence.cpp:480
std::unique_ptr< synth_turb::MeanProfile > m_wind_profile
Definition SyntheticTurbulence.H:194
amrex::Real m_gauss_scaling
Definition SyntheticTurbulence.H:198
Field & m_turb_force
Definition SyntheticTurbulence.H:186
amrex::Real m_epsilon
Definition SyntheticTurbulence.H:197
const FieldRepo & m_repo
Definition SyntheticTurbulence.H:182
std::string m_mean_wind_type
Definition SyntheticTurbulence.H:196
SynthTurbData m_turb_grid
Definition SyntheticTurbulence.H:192
void post_init_actions() override
Definition SyntheticTurbulence.H:162
void update()
Definition SyntheticTurbulence.cpp:507
amrex::Real m_duration
Definition SyntheticTurbulence.H:202
const amrex::AmrCore & m_mesh
Definition SyntheticTurbulence.H:183
Definition SyntheticTurbulence.H:29
const int m_shear_dir
Definition SyntheticTurbulence.H:47
MeanProfile(double ref_vel, int shear_dir=2)
Definition SyntheticTurbulence.H:31
amrex::Real reference_velocity() const
Definition SyntheticTurbulence.H:37
MeanVelOp m_op
Definition SyntheticTurbulence.H:44
int shear_dir() const
Definition SyntheticTurbulence.H:39
const double m_ref_vel
Definition SyntheticTurbulence.H:46
MeanVelOp device_instance() const
Definition SyntheticTurbulence.H:41
Definition BCInterface.cpp:7
Definition SyntheticTurbulence.H:130
int kr
Definition SyntheticTurbulence.H:131
amrex::Real yl
Definition SyntheticTurbulence.H:132
amrex::Real xl
Definition SyntheticTurbulence.H:132
amrex::Real xr
Definition SyntheticTurbulence.H:132
amrex::Real yr
Definition SyntheticTurbulence.H:132
amrex::Real zr
Definition SyntheticTurbulence.H:132
int ir
Definition SyntheticTurbulence.H:131
int jl
Definition SyntheticTurbulence.H:131
int jr
Definition SyntheticTurbulence.H:131
int il
Definition SyntheticTurbulence.H:131
amrex::Real zl
Definition SyntheticTurbulence.H:132
int kl
Definition SyntheticTurbulence.H:131
Definition SyntheticTurbulence.H:53
vs::Vector box_len
Definition SyntheticTurbulence.H:58
vs::Tensor tr_mat
Definition SyntheticTurbulence.H:69
vs::Vector dx
Definition SyntheticTurbulence.H:60
amrex::Vector< double > uvel
Definition SyntheticTurbulence.H:72
int ileft
Definition SyntheticTurbulence.H:81
vs::VectorT< int > box_dims
Definition SyntheticTurbulence.H:55
amrex::Gpu::DeviceVector< double > vvel_d
Definition SyntheticTurbulence.H:77
int iright
Definition SyntheticTurbulence.H:82
amrex::Gpu::DeviceVector< double > wvel_d
Definition SyntheticTurbulence.H:78
amrex::Vector< double > vvel
Definition SyntheticTurbulence.H:73
amrex::Gpu::DeviceVector< double > uvel_d
Definition SyntheticTurbulence.H:76
amrex::Vector< double > wvel
Definition SyntheticTurbulence.H:74
vs::Vector origin
Definition SyntheticTurbulence.H:65
Definition SyntheticTurbulence.H:86
int iright
Definition SyntheticTurbulence.H:110
vs::VectorT< int > box_dims
Definition SyntheticTurbulence.H:88
double * vvel
Definition SyntheticTurbulence.H:105
vs::Vector box_len
Definition SyntheticTurbulence.H:91
double * wvel
Definition SyntheticTurbulence.H:106
vs::Vector origin
Definition SyntheticTurbulence.H:98
SynthTurbDeviceData(SynthTurbData &hdata)
Definition SyntheticTurbulence.H:112
double * uvel
Definition SyntheticTurbulence.H:104
vs::Tensor tr_mat
Definition SyntheticTurbulence.H:102
int ileft
Definition SyntheticTurbulence.H:109
vs::Vector dx
Definition SyntheticTurbulence.H:93
Definition SyntheticTurbulence.H:18
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real operator()(double) const
Definition SyntheticTurbulence.H:20
const double m_ref_vel
Definition SyntheticTurbulence.H:25
Definition tensor.H:14
Definition vector.H:13