Conversation
…alues Points, rods and bodies keep length = max() as a sentinel, and MoorDyn::Init() sets cfl = max() when dtM is prescribed. Multiplying those sentinels raised FE_OVERFLOW, and a null velocity in the stationary solver raised FE_DIVBYZERO. The resulting inf/nan values were discarded by std::min(), so the time step is unchanged, but the host program is killed if it traps those exceptions. Fixes FloatingArrayDesign#404 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The interpolation factor i / N was 0 / 0 for zero-length rods (N = 0), raising FE_INVALID and setting the node position to nan until it was overwritten later on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…C solver The Newton-Raphson iterations of Catenary() may visit points out of the domain of the involved functions (e.g. weightless or buoyant lines), raising FE_INVALID, FE_DIVBYZERO or FE_OVERFLOW. The solver detects those failures by itself, and Line::initialize() falls back to the linear profile, so the raised exceptions are now held while the solver runs and discarded afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #404.
MoorDyn_Init()(and in some configurationsMoorDyn_Create()) raisedFE_OVERFLOW,FE_DIVBYZEROorFE_INVALIDon intermediate values that are discarded afterwards. The results are correct, but a host program that traps floating-point exceptions (feenableexcept()on Linux, FPCR trap bits on macOS arm64) gets killed. While checking the maintainer's question in #404 (whether anything else trips once the CFL overflow is patched), I ran the whole test suite with the traps enabled and found three more sites. This PR fixes all of them.Changes
CFL::cfl2dt(cfl, v):cfl * max() / vfor points, rods and bodies (the case reported in #404)max()sentinel unchangedCFL::cfl2dt(cfl, v)withv == 0inStationaryScheme::Step()max()NatFreqCFL::cfl2dt(cfl)withcfl = max(), whichMoorDyn::Init()sets whendtMis prescribed, for lines whose segment natural period is > 1 smax()sentinel unchangedRod::setup():i / (real)NwithN = 0for zero-length rodsf = 0Catenary()Newton-Raphson iterations (weightless or buoyant lines,log/sqrtof negatives,x/0) called fromLine::initialize()feholdexcept/fesetenv) and discard the flags; the solver already reports the failure and the line falls back to the linear profileIn every case the old value was
inf/nanand was already dropped bystd::minor by the caller, so results do not change. The catenary change leaves the solver itself untouched. If you'd rather guard each operation insideCatenary(), I can do that instead, but it is a much more invasive change to that routine.tests/fpe.cppadds a portable test (no traps needed) that clears the flags, then runs create, init and 10 steps on 5 inputs covering the sites above, and requiresfetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW) == 0.Testing
macOS 26 arm64, AppleClang, RelWithDebInfo,
PYTHON_WRAPPER=OFF:ctest: 32/32 pass.ctestwith the traps enabled in every test process (a preloaded library sets the FPCR trap bits):devtests/fpe.cppondev: 5/5 cases fail; with this PR: 5/5 pass.The
*.outfiles written by the test suite (76 files) are byte-identical betweendevand this branch.The reproducer from MoorDyn_Init raises FE_OVERFLOW in CFL::cfl2dt (stationary IC solver); fatal when the host traps floating-point exceptions #404 (line between two fixed points in air, external kinematics) runs Init plus 60 s of simulated time (6000 steps of 0.01 s with a gusty cross-flow) with all three traps enabled. It raises no flags and gives the same fairlead tension as
dev.🤖 Generated with Claude Code