From e41145dcd2c10ec8668d38bcb7b959010edab55b Mon Sep 17 00:00:00 2001 From: Willi Braun Date: Wed, 5 Nov 2014 21:42:26 +0000 Subject: [PATCH] - fixed #2878. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23223 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- SimulationRuntime/c/simulation/solver/dassl.c | 21 +++++++++++++++++-- .../c/simulation/solver/perform_simulation.c | 3 ++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/SimulationRuntime/c/simulation/solver/dassl.c b/SimulationRuntime/c/simulation/solver/dassl.c index 0c5e4987903..b092322c514 100644 --- a/SimulationRuntime/c/simulation/solver/dassl.c +++ b/SimulationRuntime/c/simulation/solver/dassl.c @@ -449,7 +449,9 @@ int dassl_step(DATA* data, SOLVER_INFO* solverInfo) double tout = 0; int i = 0; unsigned int ui = 0; - int retVal = 0; + int retVal = 1; + int saveJumpState; + threadData_t *threadData = data->threadData; DASSL_DATA *dasslData = (DASSL_DATA*) solverInfo->solverData; @@ -468,6 +470,14 @@ int dassl_step(DATA* data, SOLVER_INFO* solverInfo) TRACE_PUSH + saveJumpState = data->threadData->currentErrorStage; + data->threadData->currentErrorStage = ERROR_INTEGRATOR; + + /* try */ +#if !defined(OMC_EMCC) + MMC_TRY_INTERNAL(simulationJumpBuffer) +#endif + assertStreamPrint(data->threadData, 0 != dasslData->rpar, "could not passed to DDASKR"); /* If an event is triggered and processed restart dassl. */ @@ -510,7 +520,7 @@ int dassl_step(DATA* data, SOLVER_INFO* solverInfo) solverInfo->currentTime = tout; TRACE_POP - return retVal; + return 0; } /* If dasslsteps is selected, we just use the outer ring buffer */ @@ -597,6 +607,13 @@ int dassl_step(DATA* data, SOLVER_INFO* solverInfo) } while(dasslData->idid == 1 || (dasslData->idid == -1 && solverInfo->currentTime <= data->simulationInfo.stopTime)); + retVal = 0; + +#if !defined(OMC_EMCC) + MMC_CATCH_INTERNAL(simulationJumpBuffer) +#endif + data->threadData->currentErrorStage = saveJumpState; + if (!dasslData->dasslSteps) { diff --git a/SimulationRuntime/c/simulation/solver/perform_simulation.c b/SimulationRuntime/c/simulation/solver/perform_simulation.c index a2f112f947b..6d0274c853c 100644 --- a/SimulationRuntime/c/simulation/solver/perform_simulation.c +++ b/SimulationRuntime/c/simulation/solver/perform_simulation.c @@ -162,7 +162,7 @@ int prefixedName_performSimulation(DATA* data, SOLVER_INFO* solverInfo) } solverInfo->currentStepSize = (double)(__currStepNo*(simInfo->stopTime-simInfo->startTime))/(simInfo->numSteps) + simInfo->startTime - solverInfo->currentTime; - // if retry reduce stepsize + /* if retry reduce stepsize */ if(0 != retry) { solverInfo->currentStepSize /= 2; @@ -348,6 +348,7 @@ int prefixedName_performSimulation(DATA* data, SOLVER_INFO* solverInfo) restoreOldValues(data); solverInfo->currentTime = data->localData[0]->timeValue; overwriteOldSimulationData(data); + updateDiscreteSystem(data); warningStreamPrint(LOG_STDOUT, 0, "Integrator attempt to handle a problem with a called assert."); retry = 1; solverInfo->didEventStep = 1;