/home/runner/work/amr-wind/amr-wind/amr-wind/ocean_waves/relaxation_zones/W2AWaves.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/ocean_waves/relaxation_zones/W2AWaves.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
W2AWaves.H
Go to the documentation of this file.
1#ifndef W2AWAVES_H
2#define W2AWAVES_H
3
5#include <vector>
6#include <complex>
7#ifdef AMR_WIND_USE_W2A
8#include "Waves2AMR.h"
9#endif
10
11namespace amr_wind::ocean_waves {
12
14{
15 // Prefix for HOS files
16 std::string modes_file{"modes_HOS_SWENSE.dat"};
17 // Number of modes in each direction (related to FFT)
18 int n0{0};
19 int n1{0};
20 int n2{0};
21 // Number of points in each direction (spatial output)
22 int n0_sp{0};
23 int n1_sp{0};
24 // Spatial resolution in each direction
25 amrex::Real dx0{0.};
26 amrex::Real dx1{0.};
27 // Offsets for spatial data (between AMR-Wind domain and HOS domain)
28 amrex::Real xlo0{0.};
29 amrex::Real xlo1{0.};
30 // Length to dimensionalize nondim data
31 amrex::Real dimL{0.};
32 // Timestep size of reference data
33 amrex::Real dt_modes{0.0};
34
35 // Time (in HOS sim) to begin reading from
36 // (this corresponds to t = 0 in AMR-Wind sim, functions as offset)
37 amrex::Real t_winit{-1.0};
38 // Timestep (in HOS sim) of latest imported wave data
39 int ntime{0};
40 // Timestep (in HOS sim) of first imported wave data
41 int n_winit{0};
42 // Timestep (in HOS sim) of last available wave data
43 int n_wstop{0};
44 // Timestep offset (in HOS sim) for resetting to earlier data
45 int n_offset{0};
46
47 // Time (in AMR-Wind sim) when ow arrays were last changed
48 // (this is from the last timestep, goes with time-interpolated data)
49 amrex::Real t_last{-1.0};
50 // Time (in AMR-Wind sim) of latest imported wave data
51 amrex::Real t{0.0};
52
53 // Vectors to store complex or real modes
54 std::vector<std::complex<double>> c_mX, c_mY, c_mZ, c_mFS;
55 std::vector<double> r_mX, r_mY, r_mZ, r_mFS, r_mAdd;
56
57// Struct variables that have special types
58#ifdef AMR_WIND_USE_W2A
59 // FFTW plan vector
60 std::vector<fftw_plan> plan_vector;
61 // FFTW pointers to store modes ready for ifft
62 fftw_complex *c_eta_mptr = nullptr, *c_u_mptr = nullptr,
63 *c_v_mptr = nullptr, *c_w_mptr = nullptr;
64 // FFTW pointers to store modes ready for ifft
65 double *r_eta_mptr = nullptr, *r_u_mptr = nullptr, *r_v_mptr = nullptr,
66 *r_w_mptr = nullptr, *au_mptr = nullptr, *av_mptr = nullptr,
67 *aw_mptr = nullptr, *plan_out = nullptr;
68 // ReadModes objects
69 ReadModes<std::complex<double>> c_rmodes;
70 ReadModes<double> r_rmodes;
71#endif
72
73 // Height vector (where velocity is sampled) stuff
74 amrex::Vector<amrex::Real> hvec;
75 // Index vector (where hvec overlaps with local boxes)
76 amrex::Vector<int> indvec;
77 // Flag indicating whether the source simulation used HOS-Ocean or HOS-NWT
78 bool is_ocean{true};
79 // Flag indicating interpolation should take place on this processor
80 bool do_interp{true};
81 // Flag indicating regrid has occurred since the last resizing of vecs
82 bool resize_flag{false};
83 // Vectors for spatial data from transformed modes
84 amrex::Gpu::DeviceVector<amrex::Real> sp_eta_vec, sp_u_vec, sp_v_vec,
86
88 {
89#ifdef AMR_WIND_USE_W2A
90 if (c_eta_mptr) {
91 delete[] c_eta_mptr;
92 }
93 if (c_u_mptr) {
94 delete[] c_u_mptr;
95 }
96 if (c_v_mptr) {
97 delete[] c_v_mptr;
98 }
99 if (c_w_mptr) {
100 delete[] c_w_mptr;
101 }
102 if (r_eta_mptr) {
103 delete[] r_eta_mptr;
104 }
105 if (r_u_mptr) {
106 delete[] r_u_mptr;
107 }
108 if (r_v_mptr) {
109 delete[] r_v_mptr;
110 }
111 if (r_w_mptr) {
112 delete[] r_w_mptr;
113 }
114 if (au_mptr) {
115 delete[] au_mptr;
116 }
117 if (av_mptr) {
118 delete[] av_mptr;
119 }
120 if (aw_mptr) {
121 delete[] aw_mptr;
122 }
123 if (plan_out) {
124 delete[] plan_out;
125 }
126 for (int n = 0; n < (int)plan_vector.size(); ++n) {
127 fftw_destroy_plan(plan_vector[n]);
128 }
129 plan_vector.clear();
130#endif
131 }
132};
133
135{
139
140 static std::string identifier() { return "W2AWaves"; }
141};
142
143} // namespace amr_wind::ocean_waves
144
145#endif /* W2AWAVES_H */
Definition OceanWavesTypes.H:59
Definition OceanWaves.cpp:11
Definition OceanWavesTypes.H:35
Definition RelaxationZones.H:16
Definition RelaxationZones.H:46
Definition W2AWaves.H:14
amrex::Real xlo1
Definition W2AWaves.H:29
std::vector< std::complex< double > > c_mY
Definition W2AWaves.H:54
amrex::Real dimL
Definition W2AWaves.H:31
amrex::Real dt_modes
Definition W2AWaves.H:33
amrex::Gpu::DeviceVector< amrex::Real > sp_v_vec
Definition W2AWaves.H:84
std::vector< double > r_mAdd
Definition W2AWaves.H:55
amrex::Vector< int > indvec
Definition W2AWaves.H:76
std::vector< double > r_mX
Definition W2AWaves.H:55
int n1
Definition W2AWaves.H:19
amrex::Gpu::DeviceVector< amrex::Real > sp_u_vec
Definition W2AWaves.H:84
int n_winit
Definition W2AWaves.H:41
amrex::Vector< amrex::Real > hvec
Definition W2AWaves.H:74
int n_offset
Definition W2AWaves.H:45
amrex::Real dx0
Definition W2AWaves.H:25
int ntime
Definition W2AWaves.H:39
~W2AWavesData()
Definition W2AWaves.H:87
int n1_sp
Definition W2AWaves.H:23
amrex::Real t_last
Definition W2AWaves.H:49
amrex::Real xlo0
Definition W2AWaves.H:28
amrex::Gpu::DeviceVector< amrex::Real > sp_w_vec
Definition W2AWaves.H:85
int n0
Definition W2AWaves.H:18
int n0_sp
Definition W2AWaves.H:22
amrex::Real dx1
Definition W2AWaves.H:26
amrex::Real t_winit
Definition W2AWaves.H:37
int n2
Definition W2AWaves.H:20
std::vector< std::complex< double > > c_mZ
Definition W2AWaves.H:54
int n_wstop
Definition W2AWaves.H:43
std::vector< std::complex< double > > c_mFS
Definition W2AWaves.H:54
std::vector< double > r_mZ
Definition W2AWaves.H:55
std::vector< std::complex< double > > c_mX
Definition W2AWaves.H:54
std::string modes_file
Definition W2AWaves.H:16
bool is_ocean
Definition W2AWaves.H:78
std::vector< double > r_mFS
Definition W2AWaves.H:55
amrex::Gpu::DeviceVector< amrex::Real > sp_eta_vec
Definition W2AWaves.H:84
bool do_interp
Definition W2AWaves.H:80
std::vector< double > r_mY
Definition W2AWaves.H:55
bool resize_flag
Definition W2AWaves.H:82
amrex::Real t
Definition W2AWaves.H:51
Definition W2AWaves.H:135
static std::string identifier()
Definition W2AWaves.H:140
OceanWavesDataHolder< W2AWaves > DataType
Definition W2AWaves.H:138
OceanWavesInfo InfoType
Definition W2AWaves.H:136
W2AWavesData MetaType
Definition W2AWaves.H:137