Skip to content

perf: evaluate a cable's line-wide channel values once per output row - #184

Merged
SMI-Lab-Inha merged 1 commit into
devfrom
perf/coupled-calcoutput
Nov 19, 2026
Merged

SMI-Lab-Inha merged 1 commit into
devfrom
perf/coupled-calcoutput

Conversation

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner

Summary

CalcOutput of the coupled route was dominated by the deck channels, not by the solve. Every Twist<L>N<J> channel of a finite-EI cable re-evaluated the twist of every element of its line (CD_HermiteCable_Dyn_Element_Twist: the twist reference and its Hessian per element), and OpenFAST evaluates the channels in each of its ~2.1 CalcOutput calls per step and once more for the committed-step row of the .CD.out.

The channels of one output row now share the line-wide values of a cable: they are evaluated once per row instead of once per channel. Every output is unchanged to the bit.

  • Row cache. CD_ChannelRow (the former load-power row) also carries the torsion state, the element and end twists, the node torques, the section curvature (CurvX/CurvY) and the VIV amplitude. The first channel of a row that needs a value evaluates it with the call the channel made before; the cable's other channels of the row read it.
  • Scope of a row. CD_AGG_EvalChannels (new) clears the rows at the start and at the end of every row, so nothing is carried from one state to the next. The standalone routes clear them per output row.
  • Where it is used:
    • CD_CalcOutput, its committed-step .CD.out row and lin_eval (OpenFAST and FAST.Farm);
    • the standalone mixed route (write_mixed_row), the multibody march and the cubic-Hermite writer.
  • Supercycled row. With dtM > DT, the .CD.out row takes the channels the same call has just evaluated on the committed state (the re-evaluation repeated them bit for bit).
  • Failures. A channel that fails still ends the row after the channels before it, as the channel-by-channel loops did.

Profile

IEA-15MW UMaine (r-test MD_Shared turbine 1, pose reset), DT = 0.01 s, 1000 steps, SeaState JONSWAP waves with WaterKin SEASTATE, one thread, CABLEDYN_PROFILE=1. Deck: the three chains and the lazy-wave cable of iea15mw_umaine_mixed_cabledyn.dat refined to 1 m elements (600 elements), restrained in torsion (GJ 5e4 N m², Irn from the sections, pinned ends, 90° pretwist), seabed friction 0.35, and 37 channels (nine Twist4N<J>, nine BendMom4N<J>, Twist4, two Torq4N<J>, tensions, kinematics, point forces). Medians of three runs each, in ms per step:

Phase dev this PR
CalcOutput (2.1 calls per step) 26.6 12.3
 save + output-probe overlay 4.3 4.2
 loads 2.6 2.4
 channels 9.9 1.0
 restore 4.6 4.0
 .CD.out row 5.1 0.6
UpdateStates 15.4 14.0
 implicit step 11.6 10.2
 SeaState sampling 3.7 3.8
CableDyn total 42.0 26.3
OpenFAST wall time, 10 s simulated 49.5 s 33.7 s
  • Repeatability. The three dev runs gave a CalcOutput of 24.9–29.2 ms; this PR's gave 12.1–12.5. The overlay, restore and step rows run unchanged code, so their differences are timing noise on a shared machine.
  • Calls. The 2102 CalcOutput calls are all fresh (nsuper = 1).
  • BendMom. It was already O(1) per channel: two element residuals, cached per element state. Its code is unchanged, and all 37 channels together now take 1.0 ms, so the old channel time was the twist channels.

Not done: skipping the output-probe overlay at the committed kinematics

The overlay and restore of CalcOutput (save, transfer, restore of the mirror; 8.2 ms per step above) are left as they are. Skipping them when a call's input carries exactly the kinematics of the last advance is not bit-identical in general, so it is not in this PR.

  • How often it would apply. An instrumented build counted the calls whose input equals the committed input bit for bit. Under the OpenFAST glue (ModCoupling 3, InterpOrder 2) this was the first call after the advance in 764 of 1000 steps; the others differ by at most 7e-15 (extrapolation round-off). Under the module driver and FAST.Farm it was every call.

  • Why it is not exact. The overlay of the committed kinematics is not a no-op:

    • on a cable with a parent-attached torsion frame it re-bases the nodal-twist reference (CD_HermiteCable_Dyn_Set_Torsion_Frames);
    • on a rigid end connection it re-projects the end tangent and its rates (prepare_parent_end).

    The restore also resets in-step copies that a skipped call would keep: the VIV phases at the evaluation point, the cached committed force and a_restored (CD_HFMF_UnpackMirror).

  • A measured counterexample. In an aggregate-level check (not part of this PR) with two clamped, torsion-restrained cables (one with GJ|K coupling and an end spring), the overlay of the committed kinematics changed Torq2N1, Twist3N2, Torq3N1 and both fairlead moments by one ulp at step 4 of 12, for example 6.7999987504996443E+02 against 6.7999987504996454E+02.

  • The exact case is not worth the code. A skip that is provably exact needs a deck without end connections, torsion, friction, VIV, viscoelastic or Syrope lines, bodies, rods and failures. On such a deck (the UMaine chains) the overlay and restore cost 0.03 ms of a 0.27 ms CalcOutput.

The instrumented runs found no difference on the decks below. The counterexample is the reason the skip is still left out.

Bit-identity

Every output of the dev executables (origin/dev 5f1db71) is compared line by line with this branch's; only header lines carrying a date, a time or the version are skipped.

Coupled OpenFAST, gfortran, double precision (r-test MD_Shared turbine 1; OutFmt ES24.15E3, DT_Out every step):

Case What it exercises Files Result
profile deck the 600-element torsion cable above, 1000 steps, SeaState waves, friction .out, .CD.out, .CD.static.out identical
tors1 the same deck at the example's 2–2.5 m mesh, 1000 steps 3 identical
crc NumCrctn = 1: every step rewinds and re-advances 3 identical
loose ModCoupling = 1 3 identical
ckpt + restart checkpoint at 2 s, -restart to 4 s 3 + 3 identical; the restart also equals the uninterrupted run
lin Linearize, LinTimes 1.0, 2.5, LinInputs/LinOutputs 2, still water (dYdu/dYdx difference lin_eval's channels) 10 .lin + 3 identical
sc iea15mw_umaine_mixed_cabledyn.dat with dtM = 0.05 s (nsuper = 5): the reused .CD.out row 3 identical
ei0 CableDyn_UMaine.dat chains, dtM = DT 3 identical
module driver cd_settle, cd_harmonic of the OpenFAST tree, and the torsion deck under six-DOF platform motion 3 each identical
FAST.Farm MD_Shared with Mod_SharedMooring = 5, 10 s FarmCD.out, FarmCD.static.out, T1.out, T2.out identical

Single precision (-DDOUBLE_PRECISION=OFF, the release executable's ReKi): tors1, crc, ckpt + restart and lin (10 .lin files and its 3 outputs) are identical between dev and this PR.

Standalone driver: all 63 example decks (191 output files) and all 52 test-data decks (150 files) are byte-identical, the decks that fail on purpose included.

Checkpoint files. The .chkp files themselves cannot be compared: two runs of the same dev executable already differ in 8241 bytes (wall-clock strings, and uninitialised or pointer-valued words). Restarts are therefore compared by their outputs.

Tests

  • New channel_row test. A coupled deck has an EI = 0 line and two finite-EI cables restrained in torsion; one has GJ|K and a torsional end spring, and every fairlead surges and rolls. Its 29 channels mix twists, torques, bend moments, curvatures, CurvX/CurvY, tensions, kinematics and point forces. The test checks:
    • the static state and every step of a 12-step march: the row equals the channels one at a time, bit for bit;
    • a second row at the same state repeats the first;
    • every twist and torque channel changes from step to step;
    • after a non-stepping probe transfer, the row follows the new state.
  • Mutation check: with the row reset removed from CD_AGG_EvalChannels, the test fails (3 checks).

Checks

  • ctest, default OpenBLAS kernel: 433/433 pass (fortran fast tier 346, slow 16, others 71), with 0 build warnings.
  • ctest, OPENBLAS_CORETYPE=Prescott: 433/433 pass.
  • Debug build (-fcheck=all): the 19 tests that evaluate aggregate or cable channels pass:
    • channel_row, openfast_aggregate, openfast_aggregate_touchdown;
    • coupled_torsion, lin_torsion, control_torsion, torsion_one_end, torsion_deck;
    • mixed_route_torsion, mixed_route_currents, two_moving_ends, coupled_cable_tolerance;
    • point_seabed_contact, load_power_deck, viv_amplitude_deck, section_curvature;
    • line_values_match_channels, step_allocations, memory_growth_aggregate.
  • Formatting: fprettify leaves the changed sources unchanged.
  • Docs: sphinx-build -W --keep-going -b html doc passes.
  • CHANGELOG: entry under [Unreleased] → Changed. No input, option or output changes, so no doc pages change.

Every Twist<L>N<J> channel of a finite-EI cable re-evaluated the twist
of every element of the line (CD_HermiteCable_Dyn_Element_Twist, with
the twist reference and its Hessian per element), and every Torq<L>N<J>,
CurvX/CurvY and VIV amplitude channel re-evaluated its own line-wide
array.
On the coupled OpenFAST route the channels are evaluated in every
CalcOutput (about two per step) and again for the committed-step row of
the .CD.out, so a deck with a few twist channels spent most of its
CalcOutput time on them.

The channels of one output row now share these values: CD_ChannelRow
(the former load-power row cache) also carries the torsion state, the
element and end twists, the node torques, the section curvature and the
VIV amplitude of a cable. The first channel of a row that needs a value
evaluates it with the same call the channel made before, and the cable's
other channels of the row read it, so every value is bit-identical. A
row is valid for one state only: CD_AGG_EvalChannels (new) clears it at
the start and the end of every row, the standalone routes per row.

- CD_CalcOutput, its committed-step row and lin_eval evaluate the
  channels with CD_AGG_EvalChannels. A supercycled module's row takes
  the channels the same call has just evaluated on the committed state
  (the re-evaluation repeated them bit for bit).
- The standalone mixed route (write_mixed_row), the multibody march and
  the cubic-Hermite writer pass the row through
  CD_Eval_Aggregate_Channel / eval_cable_channel.
- A channel that fails still ends the row after the channels before it.

On the IEA-15MW UMaine model with a 600-element lazy-wave cable
restrained in torsion (nine Twist and nine BendMom channels, DT 0.01 s),
CalcOutput takes 12.3 ms per step instead of 26.6 ms (channels 1.0 ms
instead of 9.9 ms, the .CD.out row 0.6 ms instead of 5.1 ms).
The coupled cases, restarts, linearization files, FAST.Farm and the
example decks are bit-identical to dev.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T11:45:03.086227Z c86b84b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CableDyn | 🛠️ Build #36011443 | 📁 Comparing c86b84b against latest (789cb6d)

  🔍 Preview build  

15 files changed · ± 15 modified

± Modified

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: c86b84b60d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SMI-Lab-Inha
SMI-Lab-Inha merged commit 3aec0cb into dev Nov 19, 2026
22 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the perf/coupled-calcoutput branch November 19, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant