@@ -307,12 +307,32 @@ void RegularWave::AddH5Data(std::vector<HydroData::RegularWaveInfo>& reg_h5_data
307307}
308308
309309Eigen::Vector3d RegularWave::GetVelocity (const Eigen::Vector3d& position, double time) {
310- return GetWaterVelocity (position, time, regular_wave_omega_, regular_wave_amplitude_, regular_wave_phase_,
310+ // apply wave stretching (if enabled)
311+ auto position_stretched = position;
312+ if (wave_stretching_) {
313+ auto eta = GetElevation (position, time);
314+ // position relative to mean water level
315+ auto z_pos = position.z () - mwl_;
316+ // Wheeler stretching
317+ auto z_stretched = water_depth_ * (z_pos - eta) / (water_depth_ + eta);
318+ position_stretched[2 ] = z_stretched + mwl_;
319+ }
320+ return GetWaterVelocity (position_stretched, time, regular_wave_omega_, regular_wave_amplitude_, regular_wave_phase_,
311321 wavenumber_, water_depth_, mwl_);
312322};
313323
314324Eigen::Vector3d RegularWave::GetAcceleration (const Eigen::Vector3d& position, double time) {
315- return GetWaterAcceleration (position, time, regular_wave_omega_, regular_wave_amplitude_, regular_wave_phase_,
325+ // apply wave stretching (if enabled)
326+ auto position_stretched = position;
327+ if (wave_stretching_) {
328+ auto eta = GetElevation (position, time);
329+ // position relative to mean water level
330+ auto z_pos = position.z () - mwl_;
331+ // Wheeler stretching
332+ auto z_stretched = water_depth_ * (z_pos - eta) / (water_depth_ + eta);
333+ position_stretched[2 ] = z_stretched + mwl_;
334+ }
335+ return GetWaterAcceleration (position_stretched, time, regular_wave_omega_, regular_wave_amplitude_, regular_wave_phase_,
316336 wavenumber_, water_depth_, mwl_);
317337};
318338
@@ -526,7 +546,8 @@ Eigen::Vector3d IrregularWaves::GetVelocity(const Eigen::Vector3d& position, dou
526546 // position relative to mean water level
527547 auto z_pos = position.z () - mwl_;
528548 // Wheeler stretching
529- position_stretched[2 ] = water_depth_ * (z_pos - eta) / (water_depth_ + eta);
549+ auto z_stretched = water_depth_ * (z_pos - eta) / (water_depth_ + eta);
550+ position_stretched[2 ] = z_stretched + mwl_;
530551 }
531552
532553 return GetWaterVelocityIrregular (position_stretched, time, spectrum_frequencies_, spectral_densities_,
@@ -542,7 +563,8 @@ Eigen::Vector3d IrregularWaves::GetAcceleration(const Eigen::Vector3d& position,
542563 // position relative to mean water level
543564 auto z_pos = position.z () - mwl_;
544565 // Wheeler stretching
545- position_stretched[2 ] = water_depth_ * (z_pos - eta) / (water_depth_ + eta);
566+ auto z_stretched = water_depth_ * (z_pos - eta) / (water_depth_ + eta);
567+ position_stretched[2 ] = z_stretched + mwl_;
546568 }
547569
548570 return GetWaterAccelerationIrregular (position_stretched, time, spectrum_frequencies_, spectral_densities_,
0 commit comments