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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,25 @@ All notable changes to CableDyn are recorded in this file. The format follows
the statics matrix overflowed the 1 MiB stack of an MSVC-linked program. Every ifx build now
compiles with `/heap-arrays:1024` (`-heap-arrays 1024` off Windows), as the static release and
the OpenFAST Visual Studio project did; the static release is unchanged.
- A finite-EI cable on the coupled aggregate (a mixed `EI = 0` + finite-EI standalone deck,
OpenFAST `CompMooring = 5`, FAST.Farm and the C API) stepped to a fixed relative Newton
tolerance of 5e-3 (200 iterations) whatever the deck's `dynamic_solver` row said, and its static
start to 1e-6; the same cable alone in a deck stepped to the deck's tolerance (default 1e-8, 30
iterations). Every route now takes the deck's `rel` and `max_iter` and the static tolerance
`min(1e-6, rel)`. A lazy cable beside a chain, both fairleads moved 3.5 m from rest: at
`rhoInf` 1, `dtM` 0.05 s the mixed route's fairlead tension peaked at 4.3e5 N (anchor 5.5e5 N)
against 1.9e4 N (2.1e3 N) for the cable alone; at `dtM` 0.1 s it fell to 8307 N against
10799 N and the fairlead bend moment rose to 1612 against 3.9 N m. The routes, and the C API,
OpenFAST and FAST.Farm builds driven through the same motion, now agree to 5e-8 of the peak
tension. The loose steps also made the coupled cable non-dissipative: held at both ends in still
water, the residual each step left grew at `rhoInf` 0.4 into a sustained oscillation (+-2.1 N on
1.5e4 N in 10 s on that cable; +-14 N at 8 Hz on 1.2e4 N on the IEA-15 MW mixed cable, also in
OpenFAST `CompMooring = 5`), and at `rhoInf` 1 a seeded march diverged; the held cable
now stays at its static tensions to 6e-5 N and a seeded one decays as on the single-line route.
On the default `rhoInf` 0.4 under motion the difference was 4.7e-4 of the anchor tension, and
the IEA-15 MW mixed example in a 60 s platform motion changes by 1.6e-6 of its cable tension.
Cost: a coupled cable step takes about 2.0 tangent factorisations instead of 1.1, and the
aggregate step of that example (chains included) 38 % more CPU time (the D03 deck: 19 %).
- A rod numbered as a body no longer joins the body's attachment points. A `Rod<N>A/B` end point
keeps its rod's id where a `Body<N>` point keeps its body's, and the body's point list took
every point with its id: a rod end POINT row listed before the body's points became the body's
Expand Down
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,15 @@ target_link_libraries(test_c_api PRIVATE cabledyn_core)
add_test(NAME c_api COMMAND test_c_api)
set_tests_properties(c_api PROPERTIES LABELS "fortran;unit;dynamic;capi")

# One Newton tolerance for a finite-EI cable on every route: the mixed deck's cable (coupled
# aggregate) against the same cable alone (standalone cubic-Hermite route) at rhoInf 1 / dtM 0.05
# and rhoInf 0.4 / dtM 0.1, and the C API, OpenFAST and FAST.Farm builds of the aggregate driven
# by a host through the same motion, against the driver.
add_executable(test_coupled_cable_tolerance tests/test_coupled_cable_tolerance.f90)
target_link_libraries(test_coupled_cable_tolerance PRIVATE cabledyn_core)
add_test(NAME coupled_cable_tolerance COMMAND test_coupled_cable_tolerance $<TARGET_FILE:cabledyn>)
set_tests_properties(coupled_cable_tolerance PROPERTIES LABELS "fortran;driver;integration;dynamic;capi;openfast")

# Compile and run through the installed-style C header against the SHARED ABI
# product. This catches missing Windows exports, C/Fortran prototype drift, ABI
# version drift, and loader failures that the Fortran-native lifecycle gate cannot.
Expand Down Expand Up @@ -1513,9 +1522,12 @@ set_tests_properties(memory_growth_aggregate PROPERTIES LABELS "fortran;openfast
# Zero heap allocations in the per-step aggregate advance after warm-up, counted through
# GNU ld --wrap malloc/calloc/realloc wrappers (GNU toolchains only).
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_executable(test_step_allocations tests/test_step_allocations.f90 tests/allocation_counter.c)
add_executable(test_step_allocations tests/test_step_allocations.f90 tests/allocation_counter.c
tests/allocation_phase_counter.c)
target_link_libraries(test_step_allocations PRIVATE cabledyn_core)
target_link_options(test_step_allocations PRIVATE "-Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc")
# the phase window of a whole driver run (tests/allocation_phase_counter.c) wraps CD_Profile_Enter
target_link_options(test_step_allocations PRIVATE
"-Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=__cabledyn_profile_MOD_cd_profile_enter")
add_test(NAME step_allocations
COMMAND test_step_allocations ${CMAKE_CURRENT_SOURCE_DIR}/examples/iea15mw_umaine_mixed_cabledyn.dat
200.0 200)
Expand Down Expand Up @@ -1546,6 +1558,10 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN
# And with the nodal twist of a line free in torsion at one end.
add_test(NAME step_allocations_torsion_one_end COMMAND test_step_allocations free)
set_tests_properties(step_allocations_torsion_one_end PROPERTIES LABELS "fortran;dynamic;memory")
# The standalone driver's march of a finite-EI line on the cubic-Hermite route moved by a vessel,
# run in process: the step phase of every step after warm-up.
add_test(NAME step_allocations_driver_vessel COMMAND test_step_allocations driver_vessel)
set_tests_properties(step_allocations_driver_vessel PROPERTIES LABELS "fortran;driver;dynamic;memory")
endif()

add_executable(test_snap_load tests/test_snap_load.f90)
Expand Down
2 changes: 1 addition & 1 deletion doc/driver_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ syntax form. The most frequently edited keywords are:
| `ei0_substep_max` | integer from 2 to 1024; most sub-steps `auto` takes for one step | `16` |
| `axial_quadrature_order` | Gauss order 1–6 for the finite-EI axial energy; a value different from the bending order gives selective integration | `4` |
| `bending_quadrature_order` | Gauss order 1–6 for the finite-EI curvature energy | `4` |
| `dynamic_solver rel abs max_iter backtracks [rhoInf]` | dynamic Newton controls; keyword-first syntax, unlike scalar rows. `EI = 0` solves use all four; standalone finite-EI decks use `rel` and `max_iter` (coupled cables: see the OPTIONS reference). Choose them for the mesh and load case; the 952-element Gulf of Maine example uses `1e-4 1e-14 100 12` | `1e-8 1e-14 30 12` |
| `dynamic_solver rel abs max_iter backtracks [rhoInf]` | dynamic Newton controls; keyword-first syntax, unlike scalar rows. `EI = 0` solves use all four; finite-EI cables use `rel` and `max_iter` on every route (standalone, mixed, OpenFAST, FAST.Farm, C API). Choose them for the mesh and load case; the 952-element Gulf of Maine example uses `1e-4 1e-14 100 12` | `1e-8 1e-14 30 12` |
| `current` | `none current` / `uniform vx vy vz current` / `profile z1 vx1 vy1 vz1 z2 vx2 vy2 vz2 current`; included in the static initial condition. Standalone only | none |
| `waves` | `none waves` / `airy H T dir waves` / `stream H T dir waves` (`dean`; regular nonlinear stream-function wave) / `jonswap Hs Tp gamma dir waves` / `pm Hs Tp dir waves` (`issc`, `bretschneider`) / `torsethaugen Hs Tp dir waves` / `ochihubble Hs1 Tp1 lambda1 Hs2 Tp2 lambda2 dir waves`. Standalone only | none |
| `wavetrain` | one train of a multi-train sea, rows add up (at most 16): `airy H T dir wavetrain`, `jonswap Hs Tp gamma dir s wavetrain`, `pm Hs Tp dir s wavetrain`, `torsethaugen Hs Tp dir s wavetrain`, `ochihubble Hs1 Tp1 lambda1 Hs2 Tp2 lambda2 dir s wavetrain`; `s` is the cos-2s spreading exponent (`0` long-crested). Excludes a `waves` row | none |
Expand Down
13 changes: 6 additions & 7 deletions doc/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,12 @@ rejected as unknown. The dynamic Newton controls are set with ``dynamic_solver``
- ``1e-8 1e-14 30 12``
- ``rel`` and ``abs`` finite and > 0; ``max_iter`` an integer ≥ 1; ``backtracks`` an integer
≥ 0; the optional sixth token sets ``rhoInf`` (same range). ``EI = 0`` dynamic solves
use all four controls. A standalone finite-EI (Hermite) deck uses only ``rel`` and
``max_iter`` for each step (``abs`` and ``backtracks`` are ignored on this route) and
converges its static equilibrium to at least ``min(1e-6, rel)``. Finite-EI cables in
OpenFAST and in mixed ``EI = 0`` + finite-EI standalone decks do not read ``rel``,
``abs``, ``max_iter`` or ``backtracks``: they use a fixed step tolerance (relative
``5e-3``, 200 Newton iterations) and a ``1e-6`` static tolerance; only the optional
``rhoInf`` token applies to them. Use controls qualified for
use all four controls. A finite-EI (Hermite) cable uses only ``rel`` and ``max_iter``
for each step (``abs`` and ``backtracks`` are ignored on this route) and converges its
static equilibrium to at least ``min(1e-6, rel)``, on every route: alone in a standalone
deck, in a mixed ``EI = 0`` + finite-EI standalone deck, in OpenFAST
(``CompMooring = 5``), in FAST.Farm and behind the C API, so a cable driven by the same
motion steps to the same state on each. Use controls qualified for
the mesh and load case; the maintained 952-element Gulf of Maine cable uses
``1e-4 1e-14 100 12``
- both (see rules)
Expand Down
55 changes: 32 additions & 23 deletions src/CableDyn_DeckDriver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts,
INTEGER, INTENT(OUT) :: coupled_node
INTEGER, INTENT(OUT) :: ErrStat
CHARACTER(*), INTENT(OUT) :: ErrMsg
! TRUE: a standalone build (its notes printed, a Fixed End A admitted). FALSE: a static helper
! build inside this one (still-water, light-line, coarse pass), whose cable is never stepped:
! its static tolerance stays at COUPLED_STATIC_TOL. Absent: a coupled build (aggregate, OpenFAST,
! FAST.Farm, C API, mixed deck). Every build that is stepped takes the deck's dynamic_solver
! rel and max_iter, so a cable steps to the same Newton tolerance on every route.
LOGICAL, INTENT(IN), OPTIONAL :: standalone_controls
TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry
REAL(wp), INTENT(IN), OPTIONAL :: fairlead_orientation(3, 3)
Expand Down Expand Up @@ -1651,8 +1656,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts,
REAL(wp) :: step_tol, static_tol, static_tol_target
REAL(wp), ALLOCATABLE :: q_coupled_tol(:)
INTEGER :: polish_iters
! Static tolerance of the coupled route (step_tol 5e-3 there), on which the mesh-
! sequenced hierarchy's intermediate readiness and recovery budgets are exercised.
! Loosest static tolerance (that of a static helper build), on which the mesh-sequenced
! hierarchy's intermediate readiness and recovery budgets are exercised.
REAL(wp), PARAMETER :: COUPLED_STATIC_TOL = 1.0e-6_wp
! Newton-iteration budget of one mesh-sequenced fallback solve: a bounded failure path.
INTEGER, PARAMETER :: FALLBACK_SEQUENCE_BUDGET = 2000
Expand Down Expand Up @@ -1724,8 +1729,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts,

ErrStat = CD_DECKDRV_OK
ErrMsg = ''
step_max_iter = 200
step_tol = 5.0e-3_wp
step_max_iter = opts%dynamic_max_iter
step_tol = opts%dynamic_rel_tol
standalone_mode = .FALSE.
weightless_bow = .FALSE.
contact_enabled = .FALSE.
Expand Down Expand Up @@ -1774,20 +1779,19 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts,
end_b_dcm = end_b_orientation
END IF
contact_z = -2000.0_wp
IF (PRESENT(standalone_controls)) THEN
IF (standalone_controls) THEN
standalone_mode = .TRUE.
step_max_iter = opts%dynamic_max_iter
step_tol = opts%dynamic_rel_tol
END IF
END IF
fixed_fairlead_ok = standalone_mode
IF (PRESENT(fixed_fairlead)) fixed_fairlead_ok = fixed_fairlead_ok .OR. fixed_fairlead
! Hand the dynamic integrator an equilibrium converged at least as tightly as
! its own Newton stopping criterion. A looser static tolerance can otherwise
! appear as an artificial load impulse on the first nominally stationary step,
! particularly after local refinement of a light, bending-stiff cable.
static_tol = MIN(COUPLED_STATIC_TOL, step_tol)
IF (PRESENT(standalone_controls)) THEN
standalone_mode = standalone_controls
! a static helper build is never stepped: the static state it hands back is the one of
! the loosest static tolerance, as before (the parent build polishes its own)
IF (.NOT. standalone_controls) static_tol = COUPLED_STATIC_TOL
END IF
fixed_fairlead_ok = standalone_mode
IF (PRESENT(fixed_fairlead)) fixed_fairlead_ok = fixed_fairlead_ok .OR. fixed_fairlead
contact_enabled = opts%has_wtrdpth .OR. PRESENT(bathymetry)
IF (opts%has_wtrdpth) contact_z = -opts%wtrdpth
IF (PRESENT(bathymetry)) THEN
Expand Down Expand Up @@ -3093,11 +3097,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts,
' attachment(s) lumped at the nearest nodes (largest arc offset ', att_offset, ' m)'
CALL report_note(note_text)
END IF
! Dynamic step controls: a relative Newton tolerance of 5e-3 (0.5% of the physical weight
! force scale, on the coupling boundary) with a generous iteration budget. This is the
! usual order for a coupling-boundary force residual; a stiffer 1e-4/1e-3 would demand a
! static seed tighter than the static solve delivers and add
! no coupling-force accuracy. The 1e-6 static seed sits far inside it at rest.
! Dynamic step controls: the deck's dynamic_solver relative tolerance and iteration budget
! (default 1e-8 and 30) on every route, standalone or coupled, so that a cable driven by the
! same motion steps to the same state on each. The tolerance is not a coupling-force accuracy
! alone: at rhoInf near 1 the march does not damp the residual a step leaves in the modes dtM
! does not resolve, and a lazy wave stepped to 5e-3 under the same motion peaked at 4.3e5 N
! against 1.9e4 N (the subdivision ladder takes the steps that do not converge in max_iter).
CALL CD_HFMF_Init(cable, l0, ea, ei, rho_a, w, q_static, dynamic_fixed_dofs, contact_z, CD_ZERO, &
opts%rho_inf, dt, coupled_node, es, em, max_iter=step_max_iter, tol=step_tol, &
frame_cs=frame_cs, axial_quadrature_order=opts%axial_quadrature_order, &
Expand Down Expand Up @@ -31030,12 +31035,14 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca
IF (motion%has_rot) THEN
! vessel motion: the fairlead end connection turns with the vessel (the DCM is
! global-to-vessel, the transpose of the vessel rotation); a moving End B rides on the
! same vessel
! same vessel. The DCM is formed in a local array: TRANSPOSE as an actual argument is
! a strided view the compiler packs into a heap temporary at every step.
dcm_a = TRANSPOSE(motion%rot(:, :, step + 1))
CALL hermite_step_ends(cables(i), up, uv, ua, ubp, ubv, uba, es, em, &
u_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), &
u_orientation=dcm_a, &
u_angular_velocity=motion%omega(:, step + 1), &
u_angular_acceleration=motion%alpha(:, step + 1), &
ub_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), &
ub_orientation=dcm_a, &
ub_angular_velocity=motion%omega(:, step + 1), &
ub_angular_acceleration=motion%alpha(:, step + 1))
ELSE IF (motion%has_turb_rot) THEN
Expand Down Expand Up @@ -31493,11 +31500,13 @@ SUBROUTINE apply_motion_to_hermite_cables(cables, lines, points, motion, time_in
END IF
IF (motion%has_rot) THEN
! vessel motion: an end connection at the fairlead (and at a moving End B) turns with the vessel
! (the DCM in a local array, as in the march: no packed temporary)
dcm_a = TRANSPOSE(motion%rot(:, :, time_index))
CALL hermite_set_ends(cables(i), q, v, a, qb, vb, ab, es, em, &
u_orientation=TRANSPOSE(motion%rot(:, :, time_index)), &
u_orientation=dcm_a, &
u_angular_velocity=motion%omega(:, time_index), &
u_angular_acceleration=motion%alpha(:, time_index), &
ub_orientation=TRANSPOSE(motion%rot(:, :, time_index)), &
ub_orientation=dcm_a, &
ub_angular_velocity=motion%omega(:, time_index), &
ub_angular_acceleration=motion%alpha(:, time_index))
ELSE IF (motion%has_turb_rot) THEN
Expand Down
46 changes: 46 additions & 0 deletions tests/allocation_phase_counter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* File: tests/allocation_phase_counter.c
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University
*
* Phase window of the allocation counter (tests/allocation_counter.c) for a whole standalone
* driver run made in process. The test executable is linked with GNU ld
* --wrap=__cabledyn_profile_MOD_cd_profile_enter (the gfortran symbol of CD_Profile_Enter), which
* every time march calls at each phase change of every step, armed or not. Armed, the wrapper
* counts the allocations of the step phase (CD_PROF_SOLVE) after a number of warm-up steps and
* switches the counter off at the next phase change, so the march's fluid sampling, checks and
* outputs stay outside the counted window. */

void __real___cabledyn_profile_MOD_cd_profile_enter(const int *phase);
void cd_test_allocation_counting(int on);

/* CD_PROF_SOLVE of CableDyn_Profile */
enum { PHASE_SOLVE = 4 };

static int armed = 0;
static long long warm_steps = 0;
static long long solve_entries = 0;

void __wrap___cabledyn_profile_MOD_cd_profile_enter(const int *phase)
{
if (armed) {
if (*phase == PHASE_SOLVE) {
solve_entries++;
cd_test_allocation_counting(solve_entries > warm_steps);
} else {
cd_test_allocation_counting(0);
}
}
__real___cabledyn_profile_MOD_cd_profile_enter(phase);
}

/* Arm (on != 0) with the number of step phases left uncounted, or disarm. */
void cd_test_phase_counting(int on, long long warm)
{
armed = on;
warm_steps = warm;
solve_entries = 0;
if (!on) cd_test_allocation_counting(0);
}

/* Step phases entered since the arming. */
long long cd_test_phase_solve_entries(void) { return solve_entries; }
Loading
Loading