Skip to content

Commit 0ac0e92

Browse files
RyanDavies19sanguinariojoe
authored andcommitted
fix: make rod submergence calcs match what is in MDF (verified code)
1 parent 6ff56ac commit 0ac0e92

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

source/Rod.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -917,29 +917,17 @@ Rod::doRHS()
917917

918918
// just use the wave elevation computed at the location of the top node for
919919
// now
920-
vec r_top, r_bottom;
921-
real zeta_i;
922-
if (r[N][2] > r[0][2]) {
923-
r_top = r[N];
924-
r_bottom = r[0];
925-
zeta_i = zeta[N];
926-
} else {
927-
r_top = r[0];
928-
r_bottom = r[N];
929-
zeta_i = zeta[0];
930-
}
931-
932-
if ((r_bottom[2] < zeta_i) && (r_top[2] > zeta_i)) {
933-
// the water plane is crossing the rod
934-
// (should also add some limits to avoid near-horizontals at some point)
935-
h0 = (zeta_i - r_bottom[2]) / fabs(q[2]);
936-
} else if (r[0][2] < zeta_i) {
937-
// fully submerged case
938-
h0 = UnstrLen;
939-
} else {
940-
// fully unsubmerged case (ever applicable?)
941-
h0 = 0.0;
942-
}
920+
real zeta_i = zeta[N];
921+
922+
// get approximate location of waterline crossing along Rod axis (note: negative h0 indicates end A is above end B, and measures -distance from end A to waterline crossing)
923+
if ((r[0][2] < zeta_i) && (r[N][2] < zeta_i)) // fully submerged case
924+
h0 = UnstrLen;
925+
else if ((r[0][2] < zeta_i) && (r[N][2] > zeta_i)) // check if it's crossing the water plane (should also add some limits to avoid near-horizontals at some point)
926+
h0 = (zeta_i - r[0][2])/q[2]; // distance along rod centerline from end A to the waterplane
927+
else if ((r[N][2] < zeta_i) && (r[0][2] > zeta_i)) // check if it's crossing the water plane but upside down
928+
h0 = -(zeta_i - r[0][2])/q[2]; // negative distance along rod centerline from end A to the waterplane
929+
else
930+
h0 = 0.0; // fully unsubmerged case (ever applicable?)
943931

944932
Mext = vec::Zero();
945933

@@ -1165,6 +1153,7 @@ Rod::doRHS()
11651153
M[i] += VOF[i] * env->rho_w * CaEnd * V_temp * Q;
11661154
}
11671155

1156+
// end B
11681157
if ((i == N) && (z1lo < zeta_i)) {
11691158
// buoyancy force
11701159
Ftemp = VOF[i] * Area * env->rho_w * env->g * zA;

source/Rod.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Rod final : public io::IO, public SuperCFL
192192

193193
// wave things
194194
/// VOF scalar for each segment (1 = fully submerged, 0 = out of water)
195-
std::vector<moordyn::real> VOF;
195+
std::vector<moordyn::real> VOF; // TODO: This doesnt need to be a vector, can be a double reused for each node
196196
/// instantaneous axial submerged length [m]
197197
real h0;
198198

0 commit comments

Comments
 (0)