Skip to content

Commit

Permalink
Update waves2amr for memory leak fixes (Exawind#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Nov 15, 2024
1 parent 1ed9ef4 commit fa840c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion amr-wind/ocean_waves/relaxation_zones/W2AWaves.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ struct W2AWavesData : public RelaxZonesBaseData
// FFTW plan
fftw_plan plan;
// FFTW pointers to store modes ready for ifft
fftw_complex *eta_mptr, *u_mptr, *v_mptr, *w_mptr;
fftw_complex *eta_mptr = nullptr, *u_mptr = nullptr, *v_mptr = nullptr,
*w_mptr = nullptr;
// ReadModes object
ReadModes rmodes;
#endif
Expand All @@ -69,6 +70,24 @@ struct W2AWavesData : public RelaxZonesBaseData
sp_w_vec;
// Spacing of spatial data
amrex::Real sp_dx{0.}, sp_dy{0.};

~W2AWavesData()
{
#ifdef AMR_WIND_USE_W2A
if (eta_mptr) {
delete[] eta_mptr;
}
if (u_mptr) {
delete[] u_mptr;
}
if (v_mptr) {
delete[] v_mptr;
}
if (w_mptr) {
delete[] w_mptr;
}
#endif
}
};

struct W2AWaves : public RelaxZonesType
Expand Down
2 changes: 1 addition & 1 deletion submods/Waves2AMR

0 comments on commit fa840c1

Please sign in to comment.