From b5683e269bbdcca7ddb0423b32c801d73f1e9b0f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sun, 15 Nov 2026 02:16:57 +0900 Subject: [PATCH 1/2] fix: continuous Gauss-point loads of a finite-EI line at the free surface The statics of a finite-EI line through the free surface could fail at isolated currents. Each Gauss point's hydrodynamic load switched on and off at the waterline, so the residual jumped and an equilibrium with a point at the surface had no root. A light lazy-wave cable (OD 31 mm, 0.919 kg/m, EI 0.217 N m^2, its top 0.75 m above the surface) in a cross current solved at 0.399 and 0.401 m/s and failed every static route at 0.400 m/s: the load stepping stopped at a drag fraction of 0.997, and Newton with the live drag stagnated at the same residual from every start. 99, 101 and 120 elements solved; at 0.400 m/s the third Gauss point of the element through the surface sat at z = 0 (-0.16 mm at 0.399 m/s, +0.13 mm at 0.401 m/s). The drag, added mass, wave Froude-Krylov load and VIV lift of a Gauss point now carry the immersed fraction of its section, linear across one diameter about the surface (CD_HermiteCable_Immersion), with its derivative in the Jacobians. A point deeper than D/2 has the fraction 1 exactly, so fully submerged elements are unchanged to the bit; the EI = 0 path already used a continuous wetted fraction. The VIV lift element takes the diameter as an optional argument (without it, the old switch). Gates: - test_hermite_drag_dynamics E: an element through the surface: the position Jacobian matches central FD (1.6e-10), the load changes by at most 3.3e-4 of its size per 0.1 mm as the element moves through the surface (a switch jumped by a Gauss weight, 5/18 or 8/18), and a fully submerged element is unchanged to the bit; - test_static_surface_crossing: the cable above at 21 currents, 0.390-0.410 m/s: every speed solves, the deflection and top tension grow monotonically, and 0.400 m/s lies between its neighbours (the deck fails on dev at 0.400 m/s only). The full suite passes unchanged under both BLAS kernels. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 11 ++ CMakeLists.txt | 4 + doc/theory.rst | 21 +++- src/CableDyn_HermiteCableDynamic.f90 | 126 ++++++++++++++----- tests/test_hermite_drag_dynamics.f90 | 56 ++++++++- tests/test_static_surface_crossing.f90 | 165 +++++++++++++++++++++++++ 6 files changed, 346 insertions(+), 37 deletions(-) create mode 100644 tests/test_static_surface_crossing.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2d0000..56bd6994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,17 @@ All notable changes to CableDyn are recorded in this file. The format follows 1.00 Hz, largest r.m.s. strain 7.3 % above the measured largest, station mean 3.6 % above; converged in mesh and time step to 0.2 %. +### Fixed + +- The statics of a finite-EI line through the free surface could fail at isolated currents: + each Gauss point's hydrodynamic load switched on and off at the surface, so the residual + jumped and an equilibrium with a point at the waterline had no root (a light lazy-wave cable, + OD 31 mm, in a cross current solved at 0.399 and 0.401 m/s and failed every static route at + 0.400 m/s, the load stepping stopping at a drag fraction of 0.997). The drag, added mass, wave + Froude-Krylov load and VIV lift of a Gauss point now carry the immersed fraction of its + section, linear across one diameter about the surface, with its derivative in the Jacobians. + Fully submerged points are unchanged to the bit; the full test suite passes unchanged. + ## [0.4.2] - 2026-11-09 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index 24c5931a..4ed467ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1329,6 +1329,10 @@ add_executable(test_viv_wake_deck tests/test_viv_wake_deck.f90) target_link_libraries(test_viv_wake_deck PRIVATE cabledyn_core) add_test(NAME viv_wake_deck COMMAND test_viv_wake_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(viv_wake_deck PROPERTIES LABELS "fortran;integration;dynamic;viv" TIMEOUT 1200) +add_executable(test_static_surface_crossing tests/test_static_surface_crossing.f90) +target_link_libraries(test_static_surface_crossing PRIVATE cabledyn_core) +add_test(NAME static_surface_crossing COMMAND test_static_surface_crossing WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(static_surface_crossing PROPERTIES LABELS "fortran;integration;static" TIMEOUT 600) # VIV amplitude estimate (Thorsen et al. 2016, Eq. 8 and 9) and the amplitude tables. add_executable(test_viv_amplitude_kernel tests/test_viv_amplitude_kernel.f90) diff --git a/doc/theory.rst b/doc/theory.rst index 0ad2c0a6..731be7dd 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1451,11 +1451,22 @@ On the ``EI = 0`` path, an element crossing the free surface uses its wetted fra Drag, added mass, and fluid inertia act on the wetted part (drag with the wet-weighted relative velocity), and a recovery load :math:`-(1 - f)\,\tfrac{1}{2}\rho A g L_0` on each end node removes the buoyancy of the dry part; the derivatives of :math:`f` with respect to the nodal heights are -included in the tangent. On the Hermite path the hydrodynamic loads are integrated over the -deformed element length at three Gauss points, and a Gauss point above the local surface -carries no load. This is exact for fully submerged elements, the regime of lazy-wave cables and -moorings, and approximates the wetted length of a surface-piercing element by the Gauss -sampling. The Hermite buoyancy recovery is exact: the waterline crossings of the cubic +included in the tangent. On the Hermite path the hydrodynamic loads (drag, added mass, the wave +Froude-Krylov load and the VIV lift) are integrated over the deformed element length at the +Gauss points, each weighted by the immersed fraction of its section, linear across one diameter: + +.. math:: + + w = \min\left(1, \max\left(0, \tfrac12 + \frac{\eta - z_g}{D}\right)\right), + +with :math:`z_g` the height of the Gauss point and :math:`\eta` the local surface. A point +deeper than :math:`D/2` has :math:`w = 1` exactly, so fully submerged elements, the regime of +lazy-wave cables and moorings, are integrated as before to the bit; across the surface the load +of a point is continuous in its height (with :math:`\partial w/\partial z_g = -1/D` in the +tangent). A wet/dry switch per point made it jump, and a static equilibrium with a Gauss point at +the surface then had no root: a 31 mm cable through the surface in a 0.400 m/s cross current +failed every static route while 0.399 and 0.401 m/s solved. The Hermite buoyancy recovery is +exact: the waterline crossings of the cubic centreline height are located on each element, and the load :math:`\rho g A` is integrated in closed form against the Hermite shape functions over the dry intervals, diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 75463237..872e1e20 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -1971,16 +1971,17 @@ SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, knx = model%vil_k(e)*[COS(model%vil_phi_eval(e)), COS(model%vil_phi_eval(e + 1))] IF (PRESENT(djq)) THEN CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg, & - kx_node=knx) + kx_node=knx, diam=model%diam(e)) ELSE CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, ErrStat=ErrStat, & - ErrMsg=ErrMsg, kx_node=knx) + ErrMsg=ErrMsg, kx_node=knx, diam=model%diam(e)) END IF ELSE IF (PRESENT(djq)) THEN - CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg) + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg, & + diam=model%diam(e)) ELSE CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, ErrStat=ErrStat, & - ErrMsg=ErrMsg) + ErrMsg=ErrMsg, diam=model%diam(e)) END IF END SUBROUTINE viv_element_lift @@ -8349,7 +8350,7 @@ SUBROUTINE added_mass_force(qe, ae, l0, waterline_z, rho, diam, can, cat, f, Err CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER, PARAMETER :: NGP = 4 REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp - REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), rp(3), acc(3), speed, tangent(3), fa(3), area + REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), rp(3), acc(3), speed, tangent(3), fa(3), area, wf, dwf INTEGER :: g, sh, c ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -8366,14 +8367,15 @@ SUBROUTINE added_mass_force(qe, ae, l0, waterline_z, rho, diam, can, cat, f, Err rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) acc(c) = H(1)*ae(c) + H(2)*ae(3 + c) + H(3)*ae(6 + c) + H(4)*ae(9 + c) END DO - IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no added mass + CALL CD_HermiteCable_Immersion(waterline_z - rpos(3), diam, wf, dwf) + IF (.NOT. (wf > CD_ZERO)) CYCLE ! dry Gauss point: no added mass speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) IF (speed <= 1.0e-12_wp) THEN ErrStat = CD_HCDYN_NOCONVERGE ErrMsg = 'added-mass force: degenerate centreline (|dr/dxi| ~ 0)'; RETURN END IF tangent = rp/speed - fa = gw(g)*speed*rho*area*(can*acc + (cat - can)*DOT_PRODUCT(tangent, acc)*tangent) + fa = (gw(g)*wf)*speed*rho*area*(can*acc + (cat - can)*DOT_PRODUCT(tangent, acc)*tangent) DO sh = 1, 4 f(3*(sh - 1) + 1:3*sh) = f(3*(sh - 1) + 1:3*sh) + H(sh)*fa END DO @@ -11671,6 +11673,30 @@ SUBROUTINE fail(msg) END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Axial_Damping_Element + PURE SUBROUTINE CD_HermiteCable_Immersion(depth, diam, wf, dwf) + !! Immersed fraction wf of a cable section whose centre lies depth below the free surface + !! (negative above it), linear across one diameter: 0 from D/2 above the surface, 1 from D/2 + !! below, 1/2 at the surface, and its derivative dwf = d wf/d z with respect to the height of + !! the centre (-1/D in the band, 0 outside). A fully submerged point has wf exactly 1; across + !! the surface the hydrodynamic load of a Gauss point is continuous in the position, where a + !! wet/dry switch made it jump (a static equilibrium with a Gauss point at the surface then had + !! no root and the solve stalled). + REAL(wp), INTENT(IN) :: depth, diam + REAL(wp), INTENT(OUT) :: wf, dwf + REAL(wp) :: x + x = 0.5_wp + depth/diam + IF (x >= CD_ONE) THEN + wf = CD_ONE + dwf = CD_ZERO + ELSE IF (x <= CD_ZERO) THEN + wf = CD_ZERO + dwf = CD_ZERO + ELSE + wf = x + dwf = -CD_ONE/diam + END IF + END SUBROUTINE CD_HermiteCable_Immersion + SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, diam, cdn, cdt, & fdrag, djq, djv, ErrStat, ErrMsg, & wv_h, wv_om, wv_k, wv_depth, wv_dir, wv_t, & @@ -11684,13 +11710,13 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia !! rel-velocity / tangent Jacobians come from the analytical Morison primitive, so djq/djv are !! exact (FD-verified) and vanish smoothly at zero relative velocity (fixed-point safe). !! - !! Submergence is evaluated per Gauss point (a point with r_z above waterline_z contributes no - !! drag). For a FULLY submerged element -- the production regime for a lazy-wave power cable or a - !! mooring, which hangs entirely below the free surface -- every Gauss point is wet and the - !! integral is exact. For an element that STRADDLES the waterline this is a bounded Gauss-sampling - !! approximation (the wetted length is quantised to the abscissae and the crossing-point - !! derivative is dropped); surface-piercing elements do not get an exact wet-portion - !! integration, which fully-submerged cables do not need. + !! Submergence is evaluated per Gauss point as the immersed fraction of its section, linear + !! across one diameter about the surface (CD_HermiteCable_Immersion), with its derivative in + !! djq. For a FULLY submerged element -- the production regime for a lazy-wave power cable or a + !! mooring, which hangs entirely below the free surface -- every fraction is exactly 1 and the + !! integral is exact. For an element that STRADDLES the waterline the load stays continuous in + !! the position (a wet/dry switch per point made it jump, and a static equilibrium with a point + !! at the surface had no root); the wetted length is still sampled at the abscissae. !! OPTIONAL WAVES: supplying a wave family adds the wave velocity at each wet Gauss point !! (Wheeler-stretched, z measured from waterline_z) to the fluid velocity the drag sees. !! Exactly one family with the shared wv_depth/wv_dir/wv_t: the scalar REGULAR trio @@ -11723,7 +11749,7 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4) REAL(wp) :: rpos(3), vvel(3), rp(3), speed, tangent(3), urel(3), fpl(3), Jrel(3, 3), Jtan(3, 3) - REAL(wp) :: jq3(3, 3), scale, eta_w, uw(3), aw(3), uamb(3) + REAL(wp) :: jq3(3, 3), scale, eta_w, uw(3), aw(3), uamb(3), wf, dwf, gww LOGICAL :: has_wv, has_shared, has_trio, has_cmp, any_wv_arg, want_jac, split INTEGER :: g, s, c, sp, cp, a, b, es ! the message of a per-Gauss-point CableDyn_Hydro kinematics or Morison call (at most 154 @@ -11817,10 +11843,11 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Drag_Element: '//TRIM(em2); RETURN END IF - IF (rpos(3) - waterline_z > eta_w) CYCLE ! above the instantaneous surface: dry + CALL CD_HermiteCable_Immersion(waterline_z + eta_w - rpos(3), diam, wf, dwf) ELSE - IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no drag, no Jacobian + CALL CD_HermiteCable_Immersion(waterline_z - rpos(3), diam, wf, dwf) END IF + IF (.NOT. (wf > CD_ZERO)) CYCLE ! dry Gauss point: no drag, no Jacobian speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) ! |dr/dxi| = deformed arc length per unit xi IF (speed <= 1.0e-12_wp) THEN ErrStat = CD_HCDYN_NOCONVERGE @@ -11854,7 +11881,10 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Drag_Element: '//TRIM(em2); RETURN END IF - scale = gw(g)*speed ! ds = |dr/dxi| dxi (deformed cable length) + ! ds = |dr/dxi| dxi (deformed cable length), times the immersed fraction of the section + ! (exactly 1 at a fully submerged point, so its products are unchanged) + gww = gw(g)*wf + scale = gww*speed DO s = 1, 4 DO c = 1, 3 a = 3*(s - 1) + c @@ -11879,9 +11909,17 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia b = 3*(sp - 1) + cp ! velocity: d urel/d ve(b) = -H(sp), scaled by the deformed length measure djv(a, b) = djv(a, b) - scale*H(s)*H(sp)*Jrel(c, cp) - djq(a, b) = djq(a, b) + gw(g)*H(s)*dH(sp)*jq3(c, cp) + djq(a, b) = djq(a, b) + gww*H(s)*dH(sp)*jq3(c, cp) END DO END DO + ! the immersed fraction moves with the height of the point (in the surface band only): + ! d wf/d qe(b) = dwf H(sp) for the vertical DOFs, dwf = d wf/d z + IF (dwf /= CD_ZERO) THEN + DO sp = 1, 4 + b = 3*sp + djq(a, b) = djq(a, b) + gw(g)*speed*H(s)*fpl(c)*dwf*H(sp) + END DO + END IF END DO END DO END DO @@ -11898,7 +11936,7 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia END SUBROUTINE CD_HermiteCable_Drag_Element SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_node, flift, djq, djv, & - ErrStat, ErrMsg, kx_node) + ErrStat, ErrMsg, kx_node, diam) !! Consistent Gauss-integrated cross-flow VIV lift on one cubic-Hermite element: the load !! integral N^T f ds of the per-length lift f = k(xi) U (t x v_r) (CD_VIV_Lift_Per_Length), !! with k = 1/2 rho D Cl cos(phi) interpolated linearly between the element's end nodes @@ -11912,10 +11950,14 @@ SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_no INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: kx_node(2) + !! diam (optional): the section diameter; with it a Gauss point carries the immersed fraction of + !! its section (CD_HermiteCable_Immersion) across the free surface, without it a point above + !! waterline_z carries no load + REAL(wp), INTENT(IN), OPTIONAL :: diam INTEGER, PARAMETER :: NGP = 3 REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), vvel(3), rp(3), speed, tangent(3), fpl(3) - REAL(wp) :: jrel(3, 3), jtan(3, 3), scale, kg, fx(3), jrx(3, 3), jtx(3, 3) + REAL(wp) :: jrel(3, 3), jtan(3, 3), scale, kg, fx(3), jrx(3, 3), jtx(3, 3), wf, dwf, gww LOGICAL :: want_jac, ok INTEGER :: g, s, c, sp, cp, a, b @@ -11934,7 +11976,13 @@ SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_no vvel(c) = H(1)*ve(c) + H(2)*ve(3 + c) + H(3)*ve(6 + c) + H(4)*ve(9 + c) rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) END DO - IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no lift + IF (PRESENT(diam)) THEN + CALL CD_HermiteCable_Immersion(waterline_z - rpos(3), diam, wf, dwf) + ELSE + wf = MERGE(CD_ZERO, CD_ONE, rpos(3) > waterline_z) + dwf = CD_ZERO + END IF + IF (.NOT. (wf > CD_ZERO)) CYCLE ! dry Gauss point: no lift kg = (CD_ONE - gp(g))*k_node(1) + gp(g)*k_node(2) IF (want_jac) THEN CALL CD_VIV_Lift_Per_Length(fluid - vvel, rp, kg, fpl, ok, jrel, jtan) @@ -11958,7 +12006,8 @@ SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_no END IF speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) tangent = rp/speed - scale = gw(g)*speed + gww = gw(g)*wf + scale = gww*speed DO s = 1, 4 DO c = 1, 3 a = 3*(s - 1) + c @@ -11973,9 +12022,15 @@ SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_no DO cp = 1, 3 b = 3*(sp - 1) + cp djv(a, b) = djv(a, b) - scale*H(s)*H(sp)*jrel(c, cp) - djq(a, b) = djq(a, b) + gw(g)*H(s)*dH(sp)*(speed*jtan(c, cp) + fpl(c)*tangent(cp)) + djq(a, b) = djq(a, b) + gww*H(s)*dH(sp)*(speed*jtan(c, cp) + fpl(c)*tangent(cp)) END DO END DO + IF (dwf /= CD_ZERO) THEN ! the immersed fraction moves with the height of the point + DO sp = 1, 4 + b = 3*sp + djq(a, b) = djq(a, b) + gw(g)*speed*H(s)*fpl(c)*dwf*H(sp) + END DO + END IF END DO END DO END DO @@ -12001,7 +12056,7 @@ SUBROUTINE CD_HermiteCable_AddedMass_Element(qe, l0, waterline_z, rho, diam, can INTEGER, PARAMETER :: NGP = 4 REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4) - REAL(wp) :: rpos(3), rp(3), speed, tangent(3), ma3(3, 3), area, scale + REAL(wp) :: rpos(3), rp(3), speed, tangent(3), ma3(3, 3), area, scale, wf, dwf INTEGER :: g, s, c, sp, cp, a, b ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -12029,7 +12084,8 @@ SUBROUTINE CD_HermiteCable_AddedMass_Element(qe, l0, waterline_z, rho, diam, can rpos(c) = H(1)*qe(c) + H(2)*qe(3 + c) + H(3)*qe(6 + c) + H(4)*qe(9 + c) rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) END DO - IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no added mass + CALL CD_HermiteCable_Immersion(waterline_z - rpos(3), diam, wf, dwf) + IF (.NOT. (wf > CD_ZERO)) CYCLE ! dry Gauss point: no added mass speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) IF (speed <= 1.0e-12_wp) THEN ErrStat = CD_HCDYN_NOCONVERGE @@ -12043,7 +12099,8 @@ SUBROUTINE CD_HermiteCable_AddedMass_Element(qe, l0, waterline_z, rho, diam, can END DO ma3(cp, cp) = ma3(cp, cp) + rho*area*can END DO - scale = gw(g)*speed ! ds = |dr/dxi| dxi (deformed cable length) + ! ds = |dr/dxi| dxi (deformed cable length), times the immersed fraction of the section + scale = (gw(g)*wf)*speed DO s = 1, 4 DO c = 1, 3 a = 3*(s - 1) + c @@ -12107,7 +12164,7 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4) REAL(wp) :: rpos(3), rp(3), speed, tangent(3), eta_w, uw(3), aw(3), area, alpha - REAL(wp) :: fpl(3), Jtan(3, 3), proj(3, 3), projk(3), dalpha, jq3(3, 3) + REAL(wp) :: fpl(3), Jtan(3, 3), proj(3, 3), projk(3), dalpha, jq3(3, 3), wf, dwf LOGICAL :: has_trio, has_cmp, has_held, want_jac INTEGER :: g, s, c, sp, cp, a, b, k, es ! the message of a per-Gauss-point CableDyn_Hydro kinematics call (at most 154 characters): a @@ -12218,7 +12275,8 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_FK_Element: '//TRIM(em2); RETURN END IF - IF (rpos(3) - waterline_z > eta_w) CYCLE ! above the instantaneous surface: dry + CALL CD_HermiteCable_Immersion(waterline_z + eta_w - rpos(3), diam, wf, dwf) + IF (.NOT. (wf > CD_ZERO)) CYCLE ! above the instantaneous surface: dry speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) IF (speed <= 1.0e-12_wp) THEN ErrStat = CD_HCDYN_NOCONVERGE @@ -12246,7 +12304,7 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, DO s = 1, 4 DO c = 1, 3 a = 3*(s - 1) + c - ffk(a) = ffk(a) + gw(g)*speed*H(s)*fpl(c) + ffk(a) = ffk(a) + (gw(g)*wf)*speed*H(s)*fpl(c) END DO END DO IF (.NOT. want_jac) CYCLE @@ -12263,9 +12321,15 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, DO sp = 1, 4 DO cp = 1, 3 b = 3*(sp - 1) + cp - fjq(a, b) = fjq(a, b) + gw(g)*H(s)*dH(sp)*jq3(c, cp) + fjq(a, b) = fjq(a, b) + (gw(g)*wf)*H(s)*dH(sp)*jq3(c, cp) END DO END DO + IF (dwf /= CD_ZERO) THEN ! the immersed fraction moves with the height of the point + DO sp = 1, 4 + b = 3*sp + fjq(a, b) = fjq(a, b) + gw(g)*speed*H(s)*fpl(c)*dwf*H(sp) + END DO + END IF END DO END DO END DO diff --git a/tests/test_hermite_drag_dynamics.f90 b/tests/test_hermite_drag_dynamics.f90 index 04e7c880..afc039e0 100644 --- a/tests/test_hermite_drag_dynamics.f90 +++ b/tests/test_hermite_drag_dynamics.f90 @@ -14,7 +14,12 @@ PROGRAM test_hermite_drag_dynamics !! the same run with drag off conserves it: drag is dissipative and correctly wired, !! C IMPLICIT-TANGENT CORRECTNESS -- a drag-active step under prescribed motion converges in a !! few Newton iterations; a wrong velocity Jacobian would degrade or break that convergence, - !! D fail-closed on a bad drag configuration. + !! D fail-closed on a bad drag configuration; + !! E SURFACE BAND -- an element through the free surface carries at each Gauss point the + !! immersed fraction of its section (linear across one diameter): the load is continuous as + !! the element moves through the surface in 0.1 mm steps (no jump where a Gauss point + !! crosses it), the position Jacobian with points in the band matches central FD, and a + !! fully submerged element is unchanged to the bit. !! !! Submerged straight beam along x (planar x-z), pinned ends, so the transverse (z) motion drives !! the normal drag. The beam sits well below the waterline, so the submerged fraction is 1. @@ -39,6 +44,7 @@ PROGRAM test_hermite_drag_dynamics nfail = 0 CALL check_drag_element_jacobian() + CALL check_drag_surface_band() CALL check_drag_arc_length_scaling() CALL check_set_drag_rollback() CALL check_fully_constrained_validation() @@ -143,6 +149,54 @@ SUBROUTINE check_drag_element_jacobian() CALL require(mmag > 1.0e-6_wp, 'material-tangent (m) DOFs carry consistent drag load (interior motion damped)') END SUBROUTINE check_drag_element_jacobian + SUBROUTINE check_drag_surface_band() + !! E: the drag of an element through the free surface (gate E in the header). + REAL(wp) :: qe(12), ve(12), fluid(3), fd(12), jq(12, 12), jv(12, 12), f0(12), f1(12) + REAL(wp) :: qp(12), fp(12), fm(12), dfd(12, 12), dj(12, 12), djd(12, 12), fs(12), fs2(12) + REAL(wp) :: hstep, errq, dz, jump, fmax + INTEGER :: i, k, es + CHARACTER(300) :: em + ! a deformed, moving element from z 0 to 0.2 m (D 0.3 m: the band is +-0.15 m about the surface) + qe = [0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.10_wp, 1.02_wp, 0.0_wp, 0.20_wp, 1.0_wp, 0.0_wp, -0.10_wp] + ve = [0.10_wp, 0.0_wp, 0.30_wp, 0.20_wp, 0.0_wp, 0.10_wp, -0.10_wp, 0.0_wp, 0.40_wp, 0.05_wp, 0.0_wp, 0.20_wp] + fluid = [0.20_wp, 0.0_wp, -0.10_wp] + ! the surface at z 0.08: every Gauss point (z within about 0.02-0.18) lies in the band + CALL CD_HermiteCable_Drag_Element(qe, ve, 1.0_wp, fluid, 0.08_wp, RHOW, DIAM, CDN, CDT, fd, jq, jv, es, em) + CALL require(es == CD_HCDYN_OK, 'E: drag element through the surface accepted: '//TRIM(em)) + DO i = 1, 12 + hstep = 1.0e-7_wp*MAX(1.0_wp, ABS(qe(i))) + qp = qe; qp(i) = qe(i) + hstep + CALL CD_HermiteCable_Drag_Element(qp, ve, 1.0_wp, fluid, 0.08_wp, RHOW, DIAM, CDN, CDT, fp, dj, djd, es, em) + qp(i) = qe(i) - hstep + CALL CD_HermiteCable_Drag_Element(qp, ve, 1.0_wp, fluid, 0.08_wp, RHOW, DIAM, CDN, CDT, fm, dj, djd, es, em) + dfd(:, i) = (fp - fm)/(2.0_wp*hstep) + END DO + errq = nan_max_abs(jq - dfd)/MAX(1.0_wp, nan_max_abs(dfd)) + WRITE (*, '(A,ES10.3)') ' [drag, surface band] position Jacobian vs central FD: err = ', errq + CALL require(errq < 1.0e-5_wp, 'E: drag position Jacobian in the surface band matches central FD') + ! the element moved down through the surface: the largest change between 0.1 mm steps against the + ! largest load (a wet/dry switch jumps by a Gauss weight, 5/18 or 8/18 of the element's load) + dz = 1.0e-4_wp + jump = 0.0_wp + fmax = 0.0_wp + CALL CD_HermiteCable_Drag_Element(qe, ve, 1.0_wp, fluid, -0.30_wp, RHOW, DIAM, CDN, CDT, f0, ErrStat=es, & + ErrMsg=em) + DO k = 1, 7000 + CALL CD_HermiteCable_Drag_Element(qe, ve, 1.0_wp, fluid, -0.30_wp + k*dz, RHOW, DIAM, CDN, CDT, f1, & + ErrStat=es, ErrMsg=em) + jump = MAX(jump, nan_max_abs(f1 - f0)) + fmax = MAX(fmax, nan_max_abs(f1)) + f0 = f1 + END DO + WRITE (*, '(A,ES10.3)') ' [drag, surface band] largest change per 0.1 mm / largest load = ', jump/fmax + CALL require(fmax > 0.0_wp .AND. jump < 2.0e-3_wp*fmax, 'E: the drag is continuous through the free surface') + ! fully submerged (every point more than D/2 below the surface at 1 m or at 100 m): the immersed + ! fraction is exactly 1, the load unchanged to the bit + CALL CD_HermiteCable_Drag_Element(qe, ve, 1.0_wp, fluid, 1.0_wp, RHOW, DIAM, CDN, CDT, fs, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Drag_Element(qe, ve, 1.0_wp, fluid, 100.0_wp, RHOW, DIAM, CDN, CDT, fs2, ErrStat=es, ErrMsg=em) + CALL require(ALL(fs == fs2), 'E: a fully submerged element is unchanged to the bit') + END SUBROUTINE check_drag_surface_band + SUBROUTINE check_drag_arc_length_scaling() !! Drag integrates over the DEFORMED cable length, not the reference length: a straight element !! uniformly stretched 2x (same l0) under the same transverse velocity gets ~2x the net drag. diff --git a/tests/test_static_surface_crossing.f90 b/tests/test_static_surface_crossing.f90 new file mode 100644 index 00000000..4eebf048 --- /dev/null +++ b/tests/test_static_surface_crossing.f90 @@ -0,0 +1,165 @@ +! File: tests/test_static_surface_crossing.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_static_surface_crossing + !! Statics of a light finite-EI cable through the free surface in a cross current: a 4.95 m + !! laboratory lazy-wave cable (OD 31 mm, 0.919 kg/m, EI 0.217 N m^2, fresh water 2 m deep), its top + !! 0.753 m above the surface and clamped vertical, its foot clamped on the floor, five buoyancy + !! modules as attachments, in a uniform current across its plane at 0.390-0.410 m/s every 1 mm/s. + !! At 0.400 m/s a Gauss point of the element through the surface sits at the waterline in the + !! equilibrium; with a wet/dry switch per Gauss point the drag jumped there, the residual had no + !! root and every static route stalled (current load stepping stopped at a drag fraction 0.997). + !! Gates: + !! S1 every speed solves; + !! S2 the sideways deflection and the top tension grow monotonically with the speed, and the + !! deflection at 0.400 m/s lies within 2 % of a step of the mean of its neighbours. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + INTEGER, PARAMETER :: NS = 21 + REAL(wp) :: speed(NS), ymax(NS), ttop(NS) + INTEGER :: nfail = 0, k + LOGICAL :: ok, all_ok + CHARACTER(1024) :: msg + CHARACTER(64) :: root + + all_ok = .TRUE. + DO k = 1, NS + speed(k) = 0.390_wp + 0.001_wp*REAL(k - 1, wp) + WRITE (root, '(A,I2.2)') 'ssc_', k + CALL write_deck(TRIM(root)//'.dat', speed(k)) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, 'S1: the static solve at the speed of case '//TRIM(root)//' converges: '//TRIM(msg)) + all_ok = all_ok .AND. ok + IF (ok) CALL read_static(TRIM(root)//'.static.out', ymax(k), ttop(k)) + END DO + IF (all_ok) THEN + WRITE (*, '(A,3F10.5)') 'S2: peak sideways deflection [m] at 0.399/0.400/0.401 m/s: ', ymax(10:12) + CALL require(ALL(ymax(2:NS) > ymax(1:NS - 1)) .AND. ALL(ttop(2:NS) > ttop(1:NS - 1)), & + 'S2: the deflection and the top tension grow monotonically with the speed') + CALL require(ABS(ymax(11) - 0.5_wp*(ymax(10) + ymax(12))) <= 0.02_wp*ABS(ymax(12) - ymax(10)), & + 'S2: the deflection at 0.400 m/s lies between its neighbours (no jump)') + END IF + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: statics of a cable through the free surface in a cross current' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE write_deck(path, u) + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: u + INTEGER :: io + ! a uniform current across the cable's plane (MoorDyn water-kinematics file, CurrentMod 1) + OPEN (NEWUNIT=io, FILE='ssc_current.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (io, '(A)') 'MoorDyn v2 water kinematics file' + WRITE (io, '(A)') 'uniform current along y for the surface-crossing statics gate' + WRITE (io, '(A)') '--------------------------- WAVES -------------------------------------' + WRITE (io, '(A)') '0 WaveKinMod - type of wave input' + WRITE (io, '(A)') '"" WaveKinFile - file containing wave elevation time series' + WRITE (io, '(A)') '0.000000E+00 dtWave - time step to use in setting up wave kinematics grid (s)' + WRITE (io, '(A)') '0 WaveDir - wave heading (deg)' + WRITE (io, '(A)') '2 - X wave input type' + WRITE (io, '(A)') '-5, 5, 2 - X wave grid point data' + WRITE (io, '(A)') '2 - Y wave input type' + WRITE (io, '(A)') '-5, 5, 2 - Y wave grid point data' + WRITE (io, '(A)') '2 - Z wave input type' + WRITE (io, '(A)') '-2, 0, 2 - Z wave grid point data' + WRITE (io, '(A)') '--------------------------- CURRENT -------------------------------------' + WRITE (io, '(A)') '1 CurrentMod - type of current input' + WRITE (io, '(A)') 'z-depth x-current y-current' + WRITE (io, '(A)') '(m) (m/s) (m/s)' + WRITE (io, '(A,F8.5)') '0.0 0.0 ', u + WRITE (io, '(A,F8.5)') '-2.0 0.0 ', u + WRITE (io, '(A)') '--------------------- need this line ------------------' + CLOSE (io) + OPEN (NEWUNIT=io, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (io, '(A)') '--------------------- CableDyn Input File ---------------------------------' + WRITE (io, '(A)') 'light lazy-wave cable through the free surface in a cross current (statics)' + WRITE (io, '(A)') '----------------------- LINE TYPES ------------------------------------------' + WRITE (io, '(A)') 'TypeName Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t Cl dF cF' + WRITE (io, '(A)') '(-) (m) (kg/m) (N) (N-s) (N-m^2) (-) (-) (-) (-) (-) (-) (-)' + WRITE (io, '(A)') 'cab 0.031 0.919 1.0e4 0.0 0.217 1.2 0.0 1.0 0.0 0 0.08 0.18' + WRITE (io, '(A)') '----------------------- POINTS ----------------------------------------------' + WRITE (io, '(A)') 'ID Attachment X Y Z M V CdA CA' + WRITE (io, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (io, '(A)') '1 Coupled 0.0 0.0 0.753 0 0 0 0' + WRITE (io, '(A)') '2 Fixed 2.798 0.0 -1.954 0 0 0 0' + WRITE (io, '(A)') '----------------------- LINES -----------------------------------------------' + WRITE (io, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (io, '(A)') '(-) (-) (-) (-) (m) (-) (-)' + WRITE (io, '(A)') '1 cab 1 2 4.95 100 -' + WRITE (io, '(A)') '--------------------- ATTACHMENTS ----------------------------------' + WRITE (io, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (io, '(A)') '(-) (m) (kg) (m^3) (m^2) (-)' + WRITE (io, '(A)') '1 3.1432 0.012375 1.237473e-04 0.0034 1.0' + WRITE (io, '(A)') '1 3.2299 0.012375 1.237473e-04 0.0034 1.0' + WRITE (io, '(A)') '1 3.4845 0.012375 1.237473e-04 0.0034 1.0' + WRITE (io, '(A)') '1 3.7516 0.012375 1.237473e-04 0.0034 1.0' + WRITE (io, '(A)') '1 4.0420 0.012375 1.237473e-04 0.0034 1.0' + WRITE (io, '(A)') '--------------------- END CONNECTIONS -------------------------------' + WRITE (io, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (io, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (io, '(A)') '1 B Rigid 0.644 0 -0.765' + WRITE (io, '(A)') '1 A Rigid 0 0 -1' + WRITE (io, '(A)') '---------------------- OPTIONS ----------------------------------------------' + WRITE (io, '(A)') '1000.0 rhoW' + WRITE (io, '(A)') '9.80665 g' + WRITE (io, '(A)') '2.0 WtrDpth' + WRITE (io, '(A)') 'ssc_current.dat WaterKin' + WRITE (io, '(A)') '0.001 dtM' + WRITE (io, '(A)') '0.002 TMax' + WRITE (io, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + WRITE (io, '(A)') 'FairTen1' + WRITE (io, '(A)') 'END' + WRITE (io, '(A)') '------------------------- need this line --------------------------------------' + CLOSE (io) + END SUBROUTINE write_deck + + SUBROUTINE run(deck, root, ok, msg) + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: msg + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(deck, root, conv, es, msg) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run + + SUBROUTINE read_static(path, ym, t1) + !! The largest sideways (y) node position and the tension at the top node of a static table. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(OUT) :: ym, t1 + CHARACTER(512) :: rec + INTEGER :: io, ios, line_id, node + REAL(wp) :: v(10) + ym = -HUGE(1.0_wp) + t1 = 0.0_wp + OPEN (NEWUNIT=io, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (io, '(A)') rec + READ (io, '(A)') rec + READ (io, '(A)') rec + DO + READ (io, '(A)', IOSTAT=ios) rec + IF (ios /= 0) EXIT + IF (LEN_TRIM(rec) == 0) CYCLE + READ (rec, *, IOSTAT=ios) line_id, node, v + IF (ios /= 0) CYCLE + ym = MAX(ym, v(3)) + IF (node == 1) t1 = v(5) + END DO + CLOSE (io) + END SUBROUTINE read_static + +END PROGRAM test_static_surface_crossing From b0830d429291384089e98f78afc373c18b002804 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sun, 15 Nov 2026 02:33:06 +0900 Subject: [PATCH 2/2] fix: wave loads of a point in the upper surface band take the field at the surface Review: a Gauss point above the instantaneous surface but inside the band (eta < z < eta + D/2) has a positive immersed fraction, but the Wheeler-stretched kinematics vanish above eta, so its immersed part carried no wave Froude-Krylov load or wave drag, and the load still jumped from about half its value to zero as the centre crossed the surface. Such a point now takes the wave velocity and acceleration at the surface (the kinematics evaluated at z = eta) in the FK and drag elements; the field gradient stays out of the Jacobian, as documented. test_hermite_wave_forcing E moves a short vertical element through the wave surface in steps of D/2000: the FK load and the wave drag change by at most 2.7e-4 of their largest value per step. Signed-off-by: Jae Hoon Seo --- doc/theory.rst | 6 +++-- src/CableDyn_HermiteCableDynamic.f90 | 38 ++++++++++++++++++++++++-- tests/test_hermite_wave_forcing.f90 | 40 +++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/doc/theory.rst b/doc/theory.rst index 731be7dd..391e179b 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1463,8 +1463,10 @@ with :math:`z_g` the height of the Gauss point and :math:`\eta` the local surfac deeper than :math:`D/2` has :math:`w = 1` exactly, so fully submerged elements, the regime of lazy-wave cables and moorings, are integrated as before to the bit; across the surface the load of a point is continuous in its height (with :math:`\partial w/\partial z_g = -1/D` in the -tangent). A wet/dry switch per point made it jump, and a static equilibrium with a Gauss point at -the surface then had no root: a 31 mm cable through the surface in a 0.400 m/s cross current +tangent). In waves a point above the instantaneous surface inside the band takes the wave velocity +and acceleration at the surface, where the Wheeler-stretched field vanishes above it. A wet/dry +switch per point made the load jump, and a static equilibrium with a Gauss point at the surface +then had no root: a 31 mm cable through the surface in a 0.400 m/s cross current failed every static route while 0.399 and 0.401 m/s solved. The Hermite buoyancy recovery is exact: the waterline crossings of the cubic centreline height are located on each element, and the load :math:`\rho g A` is integrated in diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 872e1e20..1d6bf871 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -11749,7 +11749,7 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4) REAL(wp) :: rpos(3), vvel(3), rp(3), speed, tangent(3), urel(3), fpl(3), Jrel(3, 3), Jtan(3, 3) - REAL(wp) :: jq3(3, 3), scale, eta_w, uw(3), aw(3), uamb(3), wf, dwf, gww + REAL(wp) :: jq3(3, 3), scale, eta_w, uw(3), aw(3), uamb(3), wf, dwf, gww, zsurf LOGICAL :: has_wv, has_shared, has_trio, has_cmp, any_wv_arg, want_jac, split INTEGER :: g, s, c, sp, cp, a, b, es ! the message of a per-Gauss-point CableDyn_Hydro kinematics or Morison call (at most 154 @@ -11844,6 +11844,23 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Drag_Element: '//TRIM(em2); RETURN END IF CALL CD_HermiteCable_Immersion(waterline_z + eta_w - rpos(3), diam, wf, dwf) + IF (wf > CD_ZERO .AND. rpos(3) - waterline_z > eta_w) THEN + ! a centre above the surface inside the band: its immersed part takes the wave velocity at + ! the surface (the Wheeler kinematics vanish above it), so the drag stays continuous + IF (has_cmp) THEN + zsurf = eta_w + CALL CD_Component_Wave_Kinematics(rpos(1), rpos(2), zsurf, wv_t, wv_depth, wv_dir, .TRUE., wvc_om, & + wvc_k, wvc_amp, wvc_ph, eta_w, uw, aw, es, em2, & + inputs_validated=.TRUE., exp_m2kd=wvc_e2kd) + ELSE + zsurf = eta_w + CALL CD_Airy_Wave_Kinematics_Precomputed(rpos(1), rpos(2), zsurf, wv_t, wv_h, wv_om, wv_k, wv_depth, & + wv_dir, .TRUE., eta_w, uw, aw, es, em2) + END IF + IF (es /= CD_HYDRO_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Drag_Element: '//TRIM(em2); RETURN + END IF + END IF ELSE CALL CD_HermiteCable_Immersion(waterline_z - rpos(3), diam, wf, dwf) END IF @@ -12163,7 +12180,7 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4) - REAL(wp) :: rpos(3), rp(3), speed, tangent(3), eta_w, uw(3), aw(3), area, alpha + REAL(wp) :: rpos(3), rp(3), speed, tangent(3), eta_w, uw(3), aw(3), area, alpha, zsurf REAL(wp) :: fpl(3), Jtan(3, 3), proj(3, 3), projk(3), dalpha, jq3(3, 3), wf, dwf LOGICAL :: has_trio, has_cmp, has_held, want_jac INTEGER :: g, s, c, sp, cp, a, b, k, es @@ -12277,6 +12294,23 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, END IF CALL CD_HermiteCable_Immersion(waterline_z + eta_w - rpos(3), diam, wf, dwf) IF (.NOT. (wf > CD_ZERO)) CYCLE ! above the instantaneous surface: dry + IF (.NOT. has_held .AND. rpos(3) - waterline_z > eta_w) THEN + ! a centre above the surface inside the band: its immersed part takes the field at the + ! surface (the Wheeler kinematics vanish above it), so the load stays continuous + IF (has_cmp) THEN + zsurf = eta_w + CALL CD_Component_Wave_Kinematics(rpos(1), rpos(2), zsurf, wv_t, wv_depth, wv_dir, .TRUE., wvc_om, & + wvc_k, wvc_amp, wvc_ph, eta_w, uw, aw, es, em2, inputs_validated=.TRUE., & + exp_m2kd=wvc_e2kd) + ELSE + zsurf = eta_w + CALL CD_Airy_Wave_Kinematics_Precomputed(rpos(1), rpos(2), zsurf, wv_t, wv_h, wv_om, wv_k, wv_depth, & + wv_dir, .TRUE., eta_w, uw, aw, es, em2) + END IF + IF (es /= CD_HYDRO_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_FK_Element: '//TRIM(em2); RETURN + END IF + END IF speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) IF (speed <= 1.0e-12_wp) THEN ErrStat = CD_HCDYN_NOCONVERGE diff --git a/tests/test_hermite_wave_forcing.f90 b/tests/test_hermite_wave_forcing.f90 index 113b18cc..8144df58 100644 --- a/tests/test_hermite_wave_forcing.f90 +++ b/tests/test_hermite_wave_forcing.f90 @@ -18,7 +18,10 @@ PROGRAM test_hermite_wave_forcing !! warmup), with bounded nonzero amplitude, every step converging, and the model clock !! advancing by n dt, !! D fail-closed: Set_Waves pre-init / without any hydro config / bad height/period/depth / - !! mismatched drag-vs-added-mass waterlines; partial wave arguments to the drag element. + !! mismatched drag-vs-added-mass waterlines; partial wave arguments to the drag element; + !! E SURFACE BAND IN WAVES: a short vertical element moved through the instantaneous surface + !! in steps of D/2000: the FK load and the wave drag change by under 0.2 % of their largest + !! value per step (a point above the surface inside the band takes the field at the surface). USE CableDyn_Precision, ONLY: wp USE CableDyn_Hydro, ONLY: CD_Airy_Wave_Kinematics_Precomputed, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & @@ -42,6 +45,7 @@ PROGRAM test_hermite_wave_forcing CALL check_crest_wetting() CALL check_wave_response() CALL check_fail_closed() + CALL check_band_continuity() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -62,6 +66,40 @@ SUBROUTINE wave_omk(om, k) CALL require(es == CD_HYDRO_OK, 'dispersion solve: '//TRIM(em)) END SUBROUTINE wave_omk + SUBROUTINE check_band_continuity() + !! E: the FK load and the wave drag of an element moved through the instantaneous surface. + REAL(wp) :: qe(12), ve(12), om, k, eta, uw(3), aw(3), f0(12), f1(12), d0(12), d1(12), fj(12, 12) + REAL(wp) :: dz, z0, jfk, jdr, mfk, mdr + INTEGER :: es, i + CHARACTER(300) :: em + CALL wave_omk(om, k) + CALL CD_Airy_Wave_Kinematics_Precomputed(0.0_wp, 0.0_wp, -1.0_wp, 0.9_wp, WVH, om, k, WVDEP, 0.0_wp, .TRUE., & + eta, uw, aw, es, em) + ve = 0.0_wp + dz = DIAM/2000.0_wp + jfk = 0.0_wp; jdr = 0.0_wp; mfk = 0.0_wp; mdr = 0.0_wp + DO i = 0, 16000 + ! a straight vertical element of length 0.2 m, its foot at z0 (from eta - 0.3 to eta + 0.1) + z0 = eta - 0.3_wp + REAL(i, wp)*dz ! 16000 steps of D/2000 = 0.4 m + qe = [0.0_wp, 0.0_wp, z0, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, z0 + 0.2_wp, 0.0_wp, 0.0_wp, 1.0_wp] + CALL CD_HermiteCable_FK_Element(qe, 0.2_wp, 0.0_wp, RHOW, DIAM, CAN, CAT, WVH, om, k, WVDEP, 0.0_wp, 0.9_wp, & + f1, fj, es, em) + CALL CD_HermiteCable_Drag_Element(qe, ve, 0.2_wp, [0.0_wp, 0.0_wp, 0.0_wp], 0.0_wp, RHOW, DIAM, CDN, CDT, d1, & + ErrStat=es, ErrMsg=em, wv_h=WVH, wv_om=om, wv_k=k, wv_depth=WVDEP, & + wv_dir=0.0_wp, wv_t=0.9_wp) + IF (i > 0) THEN + jfk = MAX(jfk, nan_max_abs(f1 - f0)) + jdr = MAX(jdr, nan_max_abs(d1 - d0)) + END IF + mfk = MAX(mfk, nan_max_abs(f1)); mdr = MAX(mdr, nan_max_abs(d1)) + f0 = f1; d0 = d1 + END DO + WRITE (*, '(A,2ES10.3)') ' [surface band, waves] largest change per step / largest load, FK and drag: ', & + jfk/mfk, jdr/mdr + CALL require(mfk > 0.0_wp .AND. jfk < 2.0e-3_wp*mfk, 'E: the FK load is continuous through the wave surface') + CALL require(mdr > 0.0_wp .AND. jdr < 2.0e-3_wp*mdr, 'E: the wave drag is continuous through the wave surface') + END SUBROUTINE check_band_continuity + SUBROUTINE check_fk_element_quadrature() !! FK element vs an independent 400-point trapezoid integral of the analytic per-length FK force !! along a straight submerged element (deformed length = reference here).