Skip to content

Commit effe63c

Browse files
authored
HOS-NWT capability (#1536)
* compiling with these changes, Waves2AMR commit a033db8 * fix rmodes initialization * differentiate between dimensions for fft and for interpolations, goes with Waves2AMR commit 8a55cd1 * adapting to Waves2AMR ed0aba8, something is off with the 3d case * update Waves2AMR submodule * correct dimensions of additional mode pointers * correct offset arguments * correct readmodes type * correct dx * add vertical shift to ow_w2a case * NWT cases for 2D and 3D data * update Waves2AMR module * update Waves2AMR module again * formatting * skip .dat files for spellcheck * Update test/test_files/ow_w2a_nwt_3d/ow_w2a_nwt_3d.inp * keep y offset for 3d case, remove from 2d case * document offset arguments
1 parent a497bd2 commit effe63c

File tree

16 files changed

+602
-104
lines changed

16 files changed

+602
-104
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[codespell]
2-
skip = .git,*.ipynb,*.bib,*.ps,*.patch,spack-build-*,*/build,*/submods,plt*,chk*,__pycache__,.ccls,.ccls-cache,*.pdf,DU21_A17.txt,inspect_abl_io.html
2+
skip = .git,*.ipynb,*.bib,*.ps,*.patch,spack-build-*,*/build,*/submods,plt*,chk*,__pycache__,.ccls,.ccls-cache,*.pdf,DU21_A17.txt,inspect_abl_io.html,*.dat
33
ignore-words = .codespell-ignore-words

amr-wind/ocean_waves/relaxation_zones/W2AWaves.H

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ struct W2AWavesData : public RelaxZonesBaseData
1414
{
1515
// Prefix for HOS files
1616
std::string modes_file{"modes_HOS_SWENSE.dat"};
17-
// Number of modes in each direction
17+
// Number of modes in each direction (related to FFT)
1818
int n0{0};
1919
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};
2024
// Spatial resolution in each direction
2125
amrex::Real dx0{0.};
2226
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.};
2330
// Length to dimensionalize nondim data
2431
amrex::Real dimL{0.};
2532
// Timestep size of reference data
@@ -43,50 +50,80 @@ struct W2AWavesData : public RelaxZonesBaseData
4350
// Time (in AMR-Wind sim) of latest imported wave data
4451
amrex::Real t{0.0};
4552

46-
// Vectors to store modes
47-
std::vector<std::complex<double>> mX, mY, mZ, mFS;
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;
4856

4957
// Struct variables that have special types
5058
#ifdef AMR_WIND_USE_W2A
51-
// FFTW plan
52-
fftw_plan plan;
59+
// FFTW plan vector
60+
std::vector<fftw_plan> plan_vector;
5361
// 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;
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;
68+
// ReadModes objects
69+
ReadModes<std::complex<double>> c_rmodes;
70+
ReadModes<double> r_rmodes;
5871
#endif
5972

6073
// Height vector (where velocity is sampled) stuff
6174
amrex::Vector<amrex::Real> hvec;
6275
// Index vector (where hvec overlaps with local boxes)
6376
amrex::Vector<int> indvec;
77+
// Flag indicating whether the source simulation used HOS-Ocean or HOS-NWT
78+
bool is_ocean{true};
6479
// Flag indicating interpolation should take place on this processor
6580
bool do_interp{true};
6681
// Flag indicating regrid has occurred since the last resizing of vecs
6782
bool resize_flag{false};
6883
// Vectors for spatial data from transformed modes
6984
amrex::Gpu::DeviceVector<amrex::Real> sp_eta_vec, sp_u_vec, sp_v_vec,
7085
sp_w_vec;
71-
// Spacing of spatial data
72-
amrex::Real sp_dx{0.}, sp_dy{0.};
7386

7487
~W2AWavesData()
7588
{
7689
#ifdef AMR_WIND_USE_W2A
77-
if (eta_mptr) {
78-
delete[] eta_mptr;
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;
79116
}
80-
if (u_mptr) {
81-
delete[] u_mptr;
117+
if (av_mptr) {
118+
delete[] av_mptr;
82119
}
83-
if (v_mptr) {
84-
delete[] v_mptr;
120+
if (aw_mptr) {
121+
delete[] aw_mptr;
85122
}
86-
if (w_mptr) {
87-
delete[] w_mptr;
123+
for (int n = 0; n < (int)plan_vector.size(); ++n) {
124+
fftw_destroy_plan(plan_vector[n]);
88125
}
89-
fftw_destroy_plan(plan);
126+
plan_vector.clear();
90127
#endif
91128
}
92129
};

0 commit comments

Comments
 (0)