From aabc5da24c12f9d6d54b1d816f8baf79cce8cfee Mon Sep 17 00:00:00 2001 From: David Ogden <12831266+dav-og@users.noreply.github.com> Date: Thu, 3 Dec 2026 12:24:09 +0000 Subject: [PATCH] Set an absolute tolerance on the joint reactions in the RM3 regular-wave regression test. The test uses Chrono's HHT integrator with step-size control and the GMRES solver. Chrono's default absolute tolerance on the constraint reactions is 1e-10, so a reaction component that is close to zero (the yaw moment in the prismatic joint is about 1e-3 N m, against 1e6 N m in pitch) has to converge to about 1e-10 when it passes through zero. The iterative solver does not reach that, the step is halved, and after enough halvings the run stops with "Reached minimum allowable step size". The long run (200 s) stopped this way in a continuous integration run on macOS. On Windows, 3 of 337 long runs stop when the wave amplitude is changed by multiples of 1e-12 m. The absolute tolerance on the reactions is now 0.01 N (N m); the tolerance on the accelerations keeps Chrono's default. With it, no step is cut in 60 long runs with the amplitude changed in the same way. The test now also fails with a message if the integrator cuts a step. The result moves against the stored reference, which was produced with step cuts in the first three steps: the float surge drift by 5.5 mm at most (RMS 3.3 mm against a limit of 6.3 mm, maximum limit 20 mm) and the float heave by 0.08 mm at most. The reference and the limits are unchanged. --- tests/regression/rm3/test_rm3_reg_waves.cpp | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/regression/rm3/test_rm3_reg_waves.cpp b/tests/regression/rm3/test_rm3_reg_waves.cpp index 6998356..00ccacf 100644 --- a/tests/regression/rm3/test_rm3_reg_waves.cpp +++ b/tests/regression/rm3/test_rm3_reg_waves.cpp @@ -8,6 +8,7 @@ #include #include +#include #include // std::chrono::high_resolution_clock::now #include // std::setprecision @@ -56,6 +57,23 @@ int main(int argc, char* argv[]) { double timestep = 0.01; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); + auto integrator = std::dynamic_pointer_cast(system.GetTimestepper()); + if (!integrator) { + std::cerr << "ERROR: the time stepper is not an implicit integrator" << std::endl; + return 1; + } + // Absolute tolerance on the constraint reactions [N, N m] in the Newton + // convergence test of the integrator. The waves travel along x, so the sway + // force, roll moment and yaw moment in the prismatic joint are close to zero + // (about 1e-3 N m in yaw, against 1e6 N m in pitch). With Chrono's default + // of 1e-10, such a component has to converge to about 1e-10 when it passes + // through zero, which the iterative solver does not reach. The step is then + // halved, and after enough halvings the run stops with "Reached minimum + // allowable step size". The tolerance on the accelerations keeps Chrono's + // default value. + integrator->SetAbsTolerances(1e-10, 1e-2); + // Newton iterations allowed in one attempt at a step. + const unsigned max_iterations = static_cast(integrator->GetMaxIters()); double simulationDuration = seastack::chrono::GetSimDuration(40.0, 200.0); // Output timeseries @@ -134,6 +152,17 @@ int main(int argc, char* argv[]) { while (system.GetChTime() <= simulationDuration) { system.DoStepDynamics(timestep); + // One attempt at a step takes at most max_iterations Newton iterations. + // More in one call means that an attempt did not converge and the + // integrator repeated it with a smaller step. This case should never + // need that (see the tolerance above). + if (integrator->GetNumStepIterations() > max_iterations) { + std::cerr << "ERROR: the integrator cut its step at t = " << system.GetChTime() << " s (" + << integrator->GetNumStepIterations() << " Newton iterations in one call, at most " + << max_iterations << " per attempt)" << std::endl; + return 1; + } + // append data to output vector time_vector.push_back(system.GetChTime()); float_heave_position.push_back(float_body1->GetPos().z());