/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
18 int n0{0};
19 int n1{0};
20 // Spatial resolution in each direction
21 amrex::Real dx0{0.};
22 amrex::Real dx1{0.};
23 // Length to dimensionalize nondim data
24 amrex::Real dimL{0.};
25 // Timestep size of reference data
26 amrex::Real dt_modes{0.0};
27
28 // Time (in HOS sim) to begin reading from
29 // (this corresponds to t = 0 in AMR-Wind sim, functions as offset)
30 amrex::Real t_winit{-1.0};
31 // Timestep (in HOS sim) of latest imported wave data
32 int ntime{0};
33 // Timestep (in HOS sim) of first imported wave data
34 int n_winit{0};
35 // Timestep (in HOS sim) of last available wave data
36 int n_wstop{0};
37 // Timestep offset (in HOS sim) for resetting to earlier data
38 int n_offset{0};
39
40 // Time (in AMR-Wind sim) when ow arrays were last changed
41 // (this is from the last timestep, goes with time-interpolated data)
42 amrex::Real t_last{-1.0};
43 // Time (in AMR-Wind sim) of latest imported wave data
44 amrex::Real t{0.0};
45
46 // Vectors to store modes
47 std::vector<std::complex<double>> mX, mY, mZ, mFS;
48
49// Struct variables that have special types
50#ifdef AMR_WIND_USE_W2A
51 // FFTW plan
52 fftw_plan plan;
53 // FFTW pointers to store modes ready for ifft
54 fftw_complex *eta_mptr = nullptr, *u_mptr = nullptr, *v_mptr = nullptr,
55 *w_mptr = nullptr;
56 // ReadModes object
57 ReadModes rmodes;
58#endif
59
60 // Height vector (where velocity is sampled) stuff
61 amrex::Vector<amrex::Real> hvec;
62 // Index vector (where hvec overlaps with local boxes)
63 amrex::Vector<int> indvec;
64 // Flag indicating interpolation should take place on this processor
65 bool do_interp{true};
66 // Flag indicating regrid has occurred since the last resizing of vecs
67 bool resize_flag{false};
68 // Vectors for spatial data from transformed modes
69 amrex::Gpu::DeviceVector<amrex::Real> sp_eta_vec, sp_u_vec, sp_v_vec,
71 // Spacing of spatial data
72 amrex::Real sp_dx{0.}, sp_dy{0.};
73
75 {
76#ifdef AMR_WIND_USE_W2A
77 if (eta_mptr) {
78 delete[] eta_mptr;
79 }
80 if (u_mptr) {
81 delete[] u_mptr;
82 }
83 if (v_mptr) {
84 delete[] v_mptr;
85 }
86 if (w_mptr) {
87 delete[] w_mptr;
88 }
89 fftw_destroy_plan(plan);
90#endif
91 }
92};
93
94struct W2AWaves : public RelaxZonesType
95{
99
100 static std::string identifier() { return "W2AWaves"; }
101};
102
103} // namespace amr_wind::ocean_waves
104
105#endif /* W2AWAVES_H */
Definition OceanWavesTypes.H:59
Definition OceanWaves.cpp:11
Definition OceanWavesTypes.H:35
Definition RelaxationZones.H:16
Definition RelaxationZones.H:43
Definition W2AWaves.H:14
amrex::Real dimL
Definition W2AWaves.H:24
amrex::Real dt_modes
Definition W2AWaves.H:26
amrex::Gpu::DeviceVector< amrex::Real > sp_v_vec
Definition W2AWaves.H:69
std::vector< std::complex< double > > mFS
Definition W2AWaves.H:47
amrex::Vector< int > indvec
Definition W2AWaves.H:63
int n1
Definition W2AWaves.H:19
amrex::Gpu::DeviceVector< amrex::Real > sp_u_vec
Definition W2AWaves.H:69
int n_winit
Definition W2AWaves.H:34
amrex::Vector< amrex::Real > hvec
Definition W2AWaves.H:61
int n_offset
Definition W2AWaves.H:38
amrex::Real dx0
Definition W2AWaves.H:21
int ntime
Definition W2AWaves.H:32
~W2AWavesData()
Definition W2AWaves.H:74
std::vector< std::complex< double > > mX
Definition W2AWaves.H:47
amrex::Real t_last
Definition W2AWaves.H:42
amrex::Real sp_dy
Definition W2AWaves.H:72
amrex::Gpu::DeviceVector< amrex::Real > sp_w_vec
Definition W2AWaves.H:70
int n0
Definition W2AWaves.H:18
std::vector< std::complex< double > > mY
Definition W2AWaves.H:47
amrex::Real dx1
Definition W2AWaves.H:22
amrex::Real t_winit
Definition W2AWaves.H:30
amrex::Real sp_dx
Definition W2AWaves.H:72
int n_wstop
Definition W2AWaves.H:36
std::string modes_file
Definition W2AWaves.H:16
std::vector< std::complex< double > > mZ
Definition W2AWaves.H:47
amrex::Gpu::DeviceVector< amrex::Real > sp_eta_vec
Definition W2AWaves.H:69
bool do_interp
Definition W2AWaves.H:65
bool resize_flag
Definition W2AWaves.H:67
amrex::Real t
Definition W2AWaves.H:44
Definition W2AWaves.H:95
static std::string identifier()
Definition W2AWaves.H:100