From c9a7342d60b499d097d9956f1b32793ae5bc99f5 Mon Sep 17 00:00:00 2001 From: bernhardbachmann Date: Mon, 13 Mar 2023 09:14:44 +0100 Subject: [PATCH] Utilize simulation flag -noRootFinding in GBODE (#10391) * Utilize simulation flag -noRootFinding in GBODE --- .../c/simulation/solver/gbode_events.c | 10 +++++++--- .../SimulationRuntime/c/simulation/solver/gbode_main.c | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_events.c b/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_events.c index 155e11d589e..17d3d6e5eae 100644 --- a/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_events.c +++ b/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_events.c @@ -275,10 +275,14 @@ double checkForEvents(DATA* data, threadData_t* threadData, SOLVER_INFO* solverI *foundEvent = checkForStateEvent(data, solverInfo->eventLst); if (*foundEvent) { - eventTime = findRoot_gb(data, threadData, solverInfo, solverInfo->eventLst, timeLeft, leftValues, timeRight, rightValues, isInnerIntegration); - infoStreamPrint(LOG_SOLVER, 0, "gbode detected an event at time: %20.16g", eventTime); + if (omc_flag[FLAG_NO_ROOTFINDING]) { + eventTime = timeRight; + infoStreamPrint(LOG_SOLVER, 0, "gbode detected an event at time: %20.16g (rootfinding is disabled)", eventTime); + } else { + eventTime = findRoot_gb(data, threadData, solverInfo, solverInfo->eventLst, timeLeft, leftValues, timeRight, rightValues, isInnerIntegration); + infoStreamPrint(LOG_SOLVER, 0, "gbode detected an event at time: %20.16g", eventTime); + } } - // re-store the pre values of the zeroCrossings for comparison memcpy(data->simulationInfo->zeroCrossings, data->simulationInfo->zeroCrossingsPre, data->modelData->nZeroCrossings * sizeof(modelica_real)); diff --git a/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.c b/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.c index d15b1ca5824..4b29b4bbedc 100644 --- a/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.c +++ b/OMCompiler/SimulationRuntime/c/simulation/solver/gbode_main.c @@ -1843,7 +1843,6 @@ int gbode_singlerate(DATA *data, threadData_t *threadData, SOLVER_INFO *solverIn } infoStreamPrint(LOG_SOLVER, 0, "Reject step from %10g to %10g, interpolation error %10g, new stepsize %10g", gbData->time, gbData->time + gbData->lastStepSize, gbData->err_int, gbData->stepSize); - // count failed steps and output information on the solver status // gbData->errorTestFailures++; continue;