Skip to content

Commit 3573621

Browse files
committed
Add Wheeler stretching option for irr waves
1 parent 473936d commit 3573621

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

include/hydroc/wave_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ struct IrregularWaveParams {
275275
double peak_enhancement_factor_ = 1.0;
276276
bool is_normalized_ = false;
277277
int seed_ = 1;
278+
bool wave_stretching_ = true;
278279
};
279280

280281
class IrregularWaves : public WaveBase {

src/wave_types.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ Eigen::Vector3d GetWaterVelocity(const Eigen::Vector3d& position,
6363
double water_depth) {
6464
// assuming wave along global X axis position
6565
auto x_pos = position.x();
66-
// assume water level at z = 0.0
67-
auto z_pos = position.z();
66+
// assume mean water level at z = 0.0
67+
double mwl = 0.0;
68+
auto z_pos = position.z() - mwl;
6869

6970
// get water velocity
7071
auto water_velocity = Eigen::Vector3d(0.0, 0.0, 0.0);
@@ -377,8 +378,20 @@ void IrregularWaves::AddH5Data(std::vector<HydroData::IrregularWaveInfo>& irreg_
377378
}
378379

379380
Eigen::Vector3d IrregularWaves::GetVelocity(const Eigen::Vector3d& position, double time) {
380-
return GetWaterVelocityIrregular(position, time, spectrum_frequencies_, spectral_densities_, spectral_widths_,
381-
wave_phases_, wavenumbers_, sim_data_.water_depth);
381+
// apply wave stretching (if enabled)
382+
auto position_stretched = position;
383+
if (params_.wave_stretching_) {
384+
auto eta = GetEtaIrregular(position, time, spectrum_frequencies_, spectral_densities_, spectral_widths_,
385+
wave_phases_, wavenumbers_);
386+
// assuming mean water level at 0.0
387+
double mwl = 0.0;
388+
auto z_pos = position.z() - mwl;
389+
// Wheeler stretching
390+
position_stretched[2] = sim_data_.water_depth * (z_pos - eta) / (sim_data_.water_depth + eta);
391+
}
392+
393+
return GetWaterVelocityIrregular(position_stretched, time, spectrum_frequencies_, spectral_densities_,
394+
spectral_widths_, wave_phases_, wavenumbers_, sim_data_.water_depth);
382395
};
383396

384397
double IrregularWaves::GetElevation(const Eigen::Vector3d& position, double time) {

0 commit comments

Comments
 (0)