Skip to content

Commit 65166bc

Browse files
AlexWKinleysanguinariojoe
authored andcommitted
Points above water get wave kin at surface
1 parent 1a3fff0 commit 65166bc

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

source/Waves.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ WaveGrid::getWaveKin(const vec3& pos,
151151
if (zeta) {
152152
*zeta = wave_elev;
153153
}
154-
if (pos.z() > wave_elev) {
155-
if (vel) {
156-
*vel = vec::Zero();
157-
}
158-
if (acc) {
159-
*acc = vec::Zero();
160-
}
161-
if (pdyn) {
162-
*pdyn = 0;
163-
}
164-
return;
165-
}
166154

167155
real stretched_z = 0.0;
168156
const real bottom = seafloor.getDepth(vec2(pos.x(), pos.y()));
@@ -171,6 +159,14 @@ WaveGrid::getWaveKin(const vec3& pos,
171159
const real avgDepth = seafloor.getAverageDepth();
172160

173161
stretched_z = (-avgDepth * (pos.z() - bottom)) / actual_depth + avgDepth;
162+
163+
// If the point is above the water surface, return the values at the water
164+
// surface. This is important for situations where a point is out of the
165+
// water but the object itself may have significant submergence (sideway
166+
// floating line, top node of buoy, etc)
167+
if (stretched_z > 0.0) {
168+
stretched_z = 0.0;
169+
}
174170
// LOGMSG << "WaveGrid::getWaveKin - stretched_z = " << stretched_z << endl;
175171

176172
auto iz = interp_factor(pz, stretched_z, fz);

source/Waves/SpectrumKin.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,22 @@ SpectrumKin::getWaveKin(vec3 pos,
5757
amplitudes * (omegas * t - kValues * distances + phases).sin();
5858
const Eigen::ArrayX<real> cos_waves =
5959
amplitudes * (omegas * t - kValues * distances + phases).cos();
60-
const real surface_height = sin_waves.sum();
6160

62-
if (pos.z() > surface_height) {
63-
if (zeta) {
64-
*zeta = surface_height;
65-
}
66-
if (vel) {
67-
*vel = vec3::Zero();
68-
}
69-
if (acc) {
70-
*acc = vec3::Zero();
71-
}
72-
return;
73-
}
61+
const real surface_height = sin_waves.sum();
7462
const real bottom = actualDepth;
7563
const real actual_depth = surface_height - bottom;
7664

77-
const real stretched_z =
65+
real stretched_z =
7866
(-avgDepth * (pos.z() - bottom)) / actual_depth + avgDepth;
67+
68+
// If the point is above the water surface, return the values at the water
69+
// surface. This is important for situations where a point is out of the
70+
// water but the object itself may have significant submergence (sideway
71+
// floating line, top node of buoy, etc)
72+
if (stretched_z > 0.0) {
73+
stretched_z = 0.0;
74+
}
75+
7976
if (zeta) {
8077
*zeta = surface_height;
8178
}

0 commit comments

Comments
 (0)