Skip to content

Commit 39af822

Browse files
committed
Add stretching to reg wave + for mwl=/=0
1 parent 8b1a21b commit 39af822

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

include/hydroc/wave_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class RegularWave : public WaveBase {
165165
double regular_wave_amplitude_;
166166
double regular_wave_omega_;
167167
double regular_wave_phase_ = 0.0;
168+
bool wave_stretching_ = true;
168169

169170
/**
170171
* @brief Initializes other member variables for timestep calculations later.

src/wave_types.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,32 @@ void RegularWave::AddH5Data(std::vector<HydroData::RegularWaveInfo>& reg_h5_data
307307
}
308308

309309
Eigen::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

314324
Eigen::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

Comments
 (0)