Skip to content

perf: reuse the clamped-cable Jacobian columns across body steps - #10

Merged
SMI-Lab-Inha merged 2 commits into
devfrom
perf/clamped-cable-jacobian
Oct 14, 2026
Merged

SMI-Lab-Inha merged 2 commits into
devfrom
perf/clamped-cable-jacobian

Conversation

@SMI-Lab-Inha

@SMI-Lab-Inha SMI-Lab-Inha commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Speeds up the monolithic multibody step when a body holds a clamped cable (examples/buoy_clamped_cable.dat).

Profiling that deck showed 77 % of the run in cable steps: 4849 of them for 600 march steps. Each step:

  1. took one outer iteration;
  2. rebuilt the junction Jacobian. Its clamped-cable part is six finite-difference columns, and each column re-steps the whole cable from the step entry;
  3. converged at the second iteration.

That is eight cable steps per march step.

Changes (mb_step_implicit in src/CableDyn_DeckDriver.f90):

  • Each clamped cable's columns are stored (MultibodyMarch%cab_jac) and reused across steps. The refresh rules are those of the mooring lines' condensed tangent (tan_age). The columns are rebuilt:
    • on a step's first Jacobian when they are 20 steps old;
    • when the previous step needed more than two outer iterations;
    • when the step size changed (step halving);
    • on every Jacobian from the third outer iteration on.
  • A failed step discards the stored columns.
  • A fresh build adds exactly the values it added before.

Speed (IFX 2025.3.2 release-mirror build, one thread, median of 3, isolated runs, before = dev b5c647f):

Deck Before After
buoy_clamped_cable 6.60 s 2.25 s (−66 %)
chain_two_train_sea, mixed_body_rods_points, lazy_wave_vessel_rao, als_volturnus_line_break_time, lozon_gomaine200_power_cable — unchanged within noise

With gfortran 16.2 the deck goes from 7.50 s to 3.03 s, and the mean outer iterations per step are unchanged (2.01).

Results. The junction Newton still converges to the same tolerance (JUNCTION_TOL = 1e-6 of each object's force and moment scale). It now reaches that tolerance from a slightly different Jacobian, so results move within the tolerance.

  • Decks without a clamped cable: outputs bit-identical (IFX, all five decks above).
  • buoy_clamped_cable (IFX), largest differences per channel:
Channel max |diff| relative to channel max
Body1My 2.13 N·m 1.9e-4
Body1Pz 7.3e-7 m 2.2e-5
Body1Ry 3.0e-5 rad 2.2e-5
AnchTen4 0.015 N 3.6e-6
FairTen4 0.058 N 1.9e-6
BendMom4N1 0.023 N·m 2.1e-6

To check that these differences come from the convergence tolerance and not from a different solution, both versions were also run with JUNCTION_TOL tightened to 1e-10 (gfortran, local build only, not committed):

Comparison (Body1My, the largest) max |diff|
before, default tolerance vs. before, 1e-10 1.68 N·m
after, default tolerance vs. before, 1e-10 2.48 N·m
after, 1e-10 vs. before, 1e-10 8.4e-4 N·m (7e-8 relative)

So the existing tolerance already allows differences of this size, and with a tight tolerance both versions converge to the same solution.

Tests

  • New driver_clamped_cable_pinned_rod: tests/data/buoy_clamped_cable_pinned_rod.dat is the clamped-cable buoy with an arm rod pinned to the body, so the body's junction group has nine coordinates. The kept columns are sized for the largest group (review fix 76cf96f). Under the Debug build's bounds checks, a cache sized for six stops with index 9 outside 1:6; the fixed code runs cleanly.
  • Full suite, Windows, gfortran 16.2, Release, slow tier included: 251/251 pass, on the branch rebased onto dev with feat: add a run-time profile to the standalone driver #8 and perf: evaluate each directional-sea phase and depth profile once #9.
  • pre-commit run --all-files passes.

Checklist

  • pre-commit run --all-files passes
  • ctest --test-dir build --output-on-failure passes
  • python -m pytest tests python/tests passes (if Python or validation records changed) — not applicable
  • VALIDATION.md updated if a validation result changed — no validation result changes
  • CHANGELOG.md updated under [Unreleased] (heading added if missing) for user-visible changes
  • Documentation in doc/ updated for changed inputs, options, or outputs — not applicable, no inputs or outputs changed
  • Conventional Commit title (feat:, fix:, docs:, ...)
  • Commits are signed off (git commit -s) under the
    Developer Certificate of Origin

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T12:53:04.691856Z 76cf96f 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

read-the-docs-community Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 CableDyn | 🛠️ Build #35142395 | 📁 Comparing 76cf96f against latest (f27c5e3)

  🔍 Preview build  

4 files changed
± changelog.html
± cli.html
± development.html
± faq.html

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 645f81fbd9

ℹ️ 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".

Comment thread src/CableDyn_DeckDriver.f90 Outdated
@SMI-Lab-Inha
SMI-Lab-Inha force-pushed the perf/clamped-cable-jacobian branch from 645f81f to 6b8d71d Compare October 14, 2026 11:38
Profiling a buoy with a clamped power cable showed 77 % of the run in
cable steps: 4849 of them for 600 march steps. Each monolithic step took
one outer iteration, then rebuilt the junction Jacobian, whose clamped-
cable part is six finite-difference columns, each re-stepping the whole
cable from the step entry, and converged at the second iteration: eight
cable steps per step.

The cable columns are now kept per cable and reused across steps, with
the refresh rules of the mooring lines' condensed tangent: rebuilt on a
step's first Jacobian when they are 20 steps old, when the previous step
needed more than two outer iterations, or when the step size changed
(step halving), and on every Jacobian from the third outer iteration
on; a failed step discards them. A fresh build adds the same values as
before.

examples/buoy_clamped_cable.dat runs in 3.03 s instead of 7.50 s with
the same mean outer iterations (2.01). The junction still converges to
its tolerance, so results change within it: tensions by about 2e-6
relative, the body position by under 1 um, the body pitch moment by
2 N m on a 10 kN m channel. Decks without a clamped cable are
unchanged.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha
SMI-Lab-Inha force-pushed the perf/clamped-cable-jacobian branch from 6b8d71d to 296fb9a Compare October 14, 2026 12:37
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 296fb9ab4b

ℹ️ 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".

Review found that the cache of a clamped cable's Jacobian columns was
allocated as 6 x 6, the coordinates of a free body. A body's junction
group also holds three coordinates for every rod pinned to it, and a
clamped cable on that body, or on one of its pinned rods, fills the
whole group: with one pinned rod the cache was indexed up to 9, out of
bounds.

The cache is now allocated with the junction layout, sized for the
largest group. A test deck, the clamped-cable buoy with an arm rod
pinned to the body, runs in the Debug build's bounds checks; before the
fix it stopped there with index 9 outside 1:6.

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

Copy link
Copy Markdown

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

Reviewed commit: 76cf96f2a7

ℹ️ 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 4d706a9 into dev Oct 14, 2026
15 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the perf/clamped-cable-jacobian branch October 14, 2026 13:55
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