Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,17 @@ if(Python3_Interpreter_FOUND)
TIMEOUT 300
ENVIRONMENT "${_cabledyn_python_test_environment}")

# A Rigid-ended cable in a strong current follows its drag path past a limit point by the
# pseudo-arclength continuation, as a stiff rotational spring does.
add_test(NAME arclength_rigid_end
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_arclength_rigid_end.py
--exe $<TARGET_FILE:cabledyn>
--output ${CMAKE_BINARY_DIR}/arclength_rigid_end)
set_tests_properties(arclength_rigid_end PROPERTIES
LABELS "python;hermite;static;robustness;current"
TIMEOUT 900
ENVIRONMENT "${_cabledyn_python_test_environment}")

# The note on grounded lines that a current moves over a seabed without friction: once per run
# on every standalone route, and never without a grounded node, a current, or a march, or
# with friction.
Expand Down
4 changes: 3 additions & 1 deletion doc/theory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,9 @@ still-water equilibrium is found first and the drag is brought in by load steps.
that stalls hands over to a pseudo-arclength continuation in the drag fraction
:math:`\lambda`: each corrector solves the bordered system
:math:`[K,\,-D;\ t_q^T,\ t_\lambda]` (:math:`D` the drag at full current) by block elimination
with two banded solves, so the path can turn at a limit point in :math:`\lambda`. A current
with two banded solves, so the path can turn at a limit point in :math:`\lambda`. At a ``Rigid``
end the system is taken in the basis of the end direction, as in the static solve, with the
two transverse components of the end tangent held. A current
across the vertical plane of the line makes the static solve three-dimensional, as the
dynamics are.

Expand Down
55 changes: 47 additions & 8 deletions src/CableDyn_HermiteCableStatic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,10 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_
REAL(wp), ALLOCATABLE :: fres(:), kband(:, :), kwork(:, :), dvec(:)
LOGICAL, ALLOCATABLE :: free(:)
REAL(wp) :: wq
! A Rigid end in the arclength solve: the end tangent in the basis of its direction (the
! static solve's residual and tangent come in it), the two transverse components held.
REAL(wp) :: arc_basis(3, 3, 2)
LOGICAL :: arc_rigid(2)
CHARACTER(1024) :: first_msg
CHARACTER(16) :: frac_txt
! Seabed friction of the current (active in every stage after the still-water one).
Expand Down Expand Up @@ -3628,6 +3632,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_
END IF
IF (use_fric) ALLOCATE (fric_stage, SOURCE=current%friction)
drag_homotopy = PRESENT(current)
arc_rigid = .FALSE.
CALL ei_homotopy()
IF (.NOT. PRESENT(current)) THEN
IF (ErrStat /= CD_HCSTAT_OK) RETURN
Expand Down Expand Up @@ -3672,7 +3677,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_
planar_run_limit = .FALSE.
IF (.NOT. picard_ok .AND. COUNT(MOD(fixed_dofs - 1, 6) == 1) >= nn) &
planar_run_limit = frictionless_run_limit(q)
IF (.NOT. picard_ok .AND. .NOT. has_rigid_end() .AND. .NOT. planar_run_limit) THEN
IF (.NOT. picard_ok .AND. .NOT. planar_run_limit) THEN
arc_msg = em
iters_out = 0
IF (use_fric) THEN
Expand Down Expand Up @@ -3877,13 +3882,6 @@ SUBROUTINE full_fixed_point(ok)
iters_out = iters_out + iters_before
END SUBROUTINE full_fixed_point

LOGICAL FUNCTION has_rigid_end() RESULT(rig)
!! A rigid end connection solves its end tangent in a rotated basis (not supported by
!! the bordered arclength solve).
rig = .FALSE.
IF (PRESENT(endconn_mode)) rig = ANY(endconn_mode == CD_ENDCONN_RIGID)
END FUNCTION has_rigid_end

LOGICAL FUNCTION frictionless_run_limit(qx) RESULT(run_limit)
!! TRUE when the diagnosis of state qx is a grounded run driven along a frictionless
!! seabed (see current_compression_note).
Expand Down Expand Up @@ -3955,6 +3953,21 @@ SUBROUTINE drag_arclength(ok)
DO k = 1, SIZE(fixed_dofs)
free(fixed_dofs(k)) = .FALSE.
END DO
! A Rigid end: the static solve returns its end-tangent rows and columns in the basis of
! the end direction (CD_EndConn_Basis), whose first component is the free tangent
! magnitude and whose two transverse components are held.
arc_rigid = .FALSE.
IF (PRESENT(endconn_mode) .AND. PRESENT(endconn_direction)) THEN
DO k = 1, 2
IF (endconn_mode(k) /= CD_ENDCONN_RIGID) CYCLE
CALL CD_EndConn_Basis(endconn_direction(:, k), arc_basis(:, :, k), es_a, em)
IF (es_a /= CD_ENDCONN_OK) THEN
em = 'arclength continuation: '//TRIM(em); RETURN
END IF
arc_rigid(k) = .TRUE.
free(arc_tangent_base(k) + 2:arc_tangent_base(k) + 3) = .FALSE.
END DO
END IF
ei_stage = EI
IF (PRESENT(endconn_stiffness)) k_stage = endconn_stiffness
wq = CD_ONE/SUM(l0)
Expand Down Expand Up @@ -3994,6 +4007,8 @@ SUBROUTINE drag_arclength(ok)
z2 = dvec
CALL CD_Solve_Banded(kwork, KL_H, KU_H, z2, es_a, em)
IF (es_a /= CD_LINALG_OK) EXIT
CALL arc_to_global(z1)
CALL arc_to_global(z2)
CALL CD_Arclength_Bordered_Update(wq, tq, tl, g, z1, z2, qc, lamc, es_a)
IF (es_a /= 0) EXIT
IF (.NOT. CD_All_Finite(qc) .OR. .NOT. CD_Is_Finite(lamc)) EXIT
Expand Down Expand Up @@ -4087,6 +4102,12 @@ SUBROUTINE arc_assemble(qx, lamx, resx, esx)
IF (esx /= CD_HCSTAT_OK) RETURN
CALL CD_HermiteCable_Current_Load(l0, qx, current, dvec, esx, em)
IF (esx /= CD_HCSTAT_OK) RETURN
! the drag load in the basis of a Rigid end, as the residual and tangent are
DO kk = 1, 2
IF (.NOT. arc_rigid(kk)) CYCLE
jj = arc_tangent_base(kk)
dvec(jj + 1:jj + 3) = MATMUL(TRANSPOSE(arc_basis(:, :, kk)), dvec(jj + 1:jj + 3))
END DO
! Held DOFs: zero residual and load, identity rows and columns of the band.
DO kk = 1, SIZE(dvec)
IF (free(kk)) CYCLE
Expand Down Expand Up @@ -4114,9 +4135,27 @@ SUBROUTINE arc_tangent(tqx, tlx, esx)
esx = CD_HCSTAT_NOCONVERGE; RETURN
END IF
esx = CD_HCSTAT_OK
CALL arc_to_global(tqx)
CALL CD_Arclength_Unit_Tangent(wq, tqx, tlx)
END SUBROUTINE arc_tangent

INTEGER FUNCTION arc_tangent_base(iend) RESULT(base)
!! The DOF before the end tangent of End A (iend 1) or End B (iend 2).
INTEGER, INTENT(IN) :: iend
base = MERGE(3, 6*(nn - 1) + 3, iend == 1)
END FUNCTION arc_tangent_base

SUBROUTINE arc_to_global(vx)
!! A solved increment from the basis of each Rigid end back to the global components.
REAL(wp), INTENT(INOUT) :: vx(:)
INTEGER :: ie, b0
DO ie = 1, 2
IF (.NOT. arc_rigid(ie)) CYCLE
b0 = arc_tangent_base(ie)
vx(b0 + 1:b0 + 3) = MATMUL(arc_basis(:, :, ie), vx(b0 + 1:b0 + 3))
END DO
END SUBROUTINE arc_to_global

SUBROUTINE drag_load_steps(ok)
!! Bring the current in at full stiffness from the still-water equilibrium in load
!! steps (fraction of the drag advancing by up to half the load, halved on failure),
Expand Down
97 changes: 97 additions & 0 deletions tests/test_arclength_rigid_end.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University
"""A clamped (Rigid) finite-EI line in a strong current follows its drag path past a limit point.

A 2982 m cable hangs from a fairlead 1300 m above a soft seabed, clamped there (Rigid End A), in
a 1.1 m/s current that carries its grounded run 34 m past the anchor, where it folds back (a
hairpin). The drag load steps stall at a limit point in the drag fraction; the pseudo-arclength
continuation that follows the path around such a point was skipped for a line with a Rigid end,
and the statics failed, while the same line with a rotational spring of 1e9 N m/rad, or pinned,
solved. The Rigid line must solve, with end tensions within 1e-3 of the stiff-spring line's.

usage: test_arclength_rigid_end.py --exe <cabledyn> --output <dir>
"""

from __future__ import annotations

import argparse
import os
import subprocess
import sys
from pathlib import Path

DECK = """--------------------- CableDyn Input File ------------------------------------
Clamped cable in a strong current, folded back past its anchor
--------------------- LINE TYPES ---------------------------------------
TypeName Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t
(-) (m) (kg/m) (N) (N-s) (N-m2) (-) (-) (-) (-)
t1 0.220140427337277 98.69067167615302 1404666756.1903045 -1.0 28098.621431099004 1.2 0.01 1.0 0.0
--------------------- POINTS -------------------------------------------
ID Type X Y Z
(-) (-) (m) (m) (m)
1 Coupled -86.22983517581444 29.680326533513522 -18.41049814550798
2 Fixed 1829.3161686664414 -108.94426352048342 -1300.878186612071
--------------------- LINES --------------------------------------------
ID NodeA NodeB Outputs
(-) (-) (-) (-)
1 1 2 -
--------------------- SECTIONS -----------------------------------------
LineID LineType Length NumSegs
(-) (-) (m) (-)
1 t1 2982.4084481132636 100
--------------------- END CONNECTIONS -------------------------------
LineID End Stiffness EzX EzY EzZ
(-) (-) (N-m/rad) (-) (-) (-)
1 A {k} 0.9264201469208807 0.154631906329435 -0.343270571013623
--------------------- OPTIONS ------------------------------------------
1300.878186612071 WtrDpth
6413.910151738813 kBot
0.02 dtM
0.0 TMax
uniform 1.12 -0.2 0.0 current
--------------------- OUTPUTS ------------------------------------------
FairTen1
AnchTen1
--------------------- need this line -----------------------------------
"""


def run(exe: str, out: Path, k: str) -> list:
name = "clamped_%s" % k.replace(".", "p")
deck = out / (name + ".dat")
deck.write_text(DECK.format(k=k), encoding="utf-8", newline="\n")
root = out / name
env = dict(os.environ)
env.setdefault("OPENBLAS_NUM_THREADS", "1")
p = subprocess.run([exe, str(deck), str(root)], capture_output=True, text=True, env=env, cwd=str(out))
if p.returncode != 0:
raise RuntimeError("End A %s: exit %d: %s" % (k, p.returncode, (p.stdout + p.stderr)[-400:]))
rows = Path(str(root) + ".out").read_text(encoding="utf-8").splitlines()
return [float(v) for v in rows[2].split()[1:3]]


def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("--exe", required=True)
ap.add_argument("--output", required=True)
a = ap.parse_args()
out = Path(a.output)
out.mkdir(parents=True, exist_ok=True)
failures = []
try:
rigid = run(a.exe, out, "Rigid")
spring = run(a.exe, out, "1.0e9")
for r, s, ch in zip(rigid, spring, ("FairTen1", "AnchTen1")):
if abs(r - s) > 1.0e-3 * spring[0]:
failures.append("%s %.6e (Rigid) against %.6e (1e9 N m/rad spring)" % (ch, r, s))
except RuntimeError as ex:
failures.append(str(ex))
print("clamped cable in a strong current: %d failures" % len(failures))
for f in failures:
print("FAIL:", f)
return 1 if failures else 0


if __name__ == "__main__":
sys.exit(main())
Loading