From 38720378ac474ecbf3f3aa9d496f4aa9ec2d90b0 Mon Sep 17 00:00:00 2001 From: AnHeuermann <38031952+AnHeuermann@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:55:10 +0200 Subject: [PATCH] Return error if CVODE failed - If integrator CVode in oms::SystemSC::doStep() fails return error --- src/OMSimulatorLib/SystemSC.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/OMSimulatorLib/SystemSC.cpp b/src/OMSimulatorLib/SystemSC.cpp index aaa260973..7f15a6bbd 100644 --- a/src/OMSimulatorLib/SystemSC.cpp +++ b/src/OMSimulatorLib/SystemSC.cpp @@ -607,7 +607,10 @@ oms_status_enu_t oms::SystemSC::doStep() { double cvode_time = tlast; int flag = CVode(solverData.cvode.mem, tnext, solverData.cvode.y, &cvode_time, CV_NORMAL); - if (flag < 0) logError("SUNDIALS_ERROR: CVode() failed with flag = " + std::to_string(flag)); + if (flag < 0) { + logError("SUNDIALS_ERROR: CVode() failed with flag = " + std::to_string(flag)); + return oms_status_error; + } // set states for (int i=0, j=0; i < fmus.size(); ++i) @@ -626,8 +629,10 @@ oms_status_enu_t oms::SystemSC::doStep() // set time time = cvode_time; } - else + else { logError("Unknown solver method"); + return oms_status_fatal; + } // step is complete for (int i=0; i < fmus.size(); ++i)