Skip to content

Commit c77e1b0

Browse files
committed
Add mean water level (mwl) as wave param
1 parent 3573621 commit c77e1b0

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

include/hydroc/wave_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class WaveBase {
6969
virtual double GetElevation(const Eigen::Vector3d& position, double time) = 0;
7070

7171
virtual Eigen::Vector3d GetVelocity(const Eigen::Vector3d& position, double time) = 0;
72+
73+
/// @brief Mean water level
74+
double mwl_ = 0.0;
7275
};
7376

7477
/**

src/wave_types.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ Eigen::Vector3d GetWaterVelocity(const Eigen::Vector3d& position,
6060
double amplitude,
6161
double phase,
6262
double wavenumber,
63-
double water_depth) {
63+
double water_depth,
64+
double mwl) {
6465
// assuming wave along global X axis position
6566
auto x_pos = position.x();
66-
// assume mean water level at z = 0.0
67-
double mwl = 0.0;
67+
// position relative to mean water level
6868
auto z_pos = position.z() - mwl;
6969

7070
// get water velocity
@@ -92,13 +92,14 @@ Eigen::Vector3d GetWaterVelocityIrregular(const Eigen::Vector3d& position,
9292
const Eigen::VectorXd& spectral_widths,
9393
const Eigen::VectorXd& wave_phases,
9494
const Eigen::VectorXd& wavenumbers,
95-
double water_depth) {
95+
double water_depth,
96+
double mwl) {
9697
auto water_velocity = Eigen::Vector3d(0.0, 0.0, 0.0);
9798
for (size_t i = 0; i < freqs_hz.size(); ++i) {
9899
auto amplitude = std::sqrt(2 * spectral_densities[i] * spectral_widths[i]);
99100
auto omega = 2 * M_PI * freqs_hz[i];
100101
water_velocity +=
101-
GetWaterVelocity(position, time, omega, amplitude, wave_phases[i], wavenumbers[i], water_depth);
102+
GetWaterVelocity(position, time, omega, amplitude, wave_phases[i], wavenumbers[i], water_depth, mwl);
102103
}
103104
return water_velocity;
104105
}
@@ -173,7 +174,7 @@ void RegularWave::AddH5Data(std::vector<HydroData::RegularWaveInfo>& reg_h5_data
173174

174175
Eigen::Vector3d RegularWave::GetVelocity(const Eigen::Vector3d& position, double time) {
175176
return GetWaterVelocity(position, time, regular_wave_omega_, regular_wave_amplitude_, regular_wave_phase_,
176-
wavenumber_, sim_data_.water_depth);
177+
wavenumber_, sim_data_.water_depth, mwl_);
177178
};
178179

179180
double RegularWave::GetElevation(const Eigen::Vector3d& position, double time) {
@@ -383,15 +384,14 @@ Eigen::Vector3d IrregularWaves::GetVelocity(const Eigen::Vector3d& position, dou
383384
if (params_.wave_stretching_) {
384385
auto eta = GetEtaIrregular(position, time, spectrum_frequencies_, spectral_densities_, spectral_widths_,
385386
wave_phases_, wavenumbers_);
386-
// assuming mean water level at 0.0
387-
double mwl = 0.0;
388-
auto z_pos = position.z() - mwl;
387+
// position relative to mean water level
388+
auto z_pos = position.z() - mwl_;
389389
// Wheeler stretching
390390
position_stretched[2] = sim_data_.water_depth * (z_pos - eta) / (sim_data_.water_depth + eta);
391391
}
392392

393393
return GetWaterVelocityIrregular(position_stretched, time, spectrum_frequencies_, spectral_densities_,
394-
spectral_widths_, wave_phases_, wavenumbers_, sim_data_.water_depth);
394+
spectral_widths_, wave_phases_, wavenumbers_, sim_data_.water_depth, mwl_);
395395
};
396396

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

0 commit comments

Comments
 (0)