Changeset 14ac561 in OpenModelica
- Timestamp:
- 2022-05-16T11:43:04+02:00 (23 months ago)
- Parents:
- e1dbd879
- git-author:
- Philip Hannebohm <phannebohm@…> (05/16/22 11:40:47)
- git-committer:
- Philip Hannebohm <phannebohm@…> (05/16/22 11:43:04)
- Location:
- OMCompiler/SimulationRuntime/c/simulation/solver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/SimulationRuntime/c/simulation/solver/events.c
re1dbd879 r14ac561 149 149 TRACE_PUSH 150 150 151 if (checkForStateEvent(data, eventLst)) 152 { 153 if (useRootFinding) 154 { 155 *eventTime = findRoot(data, threadData, eventLst); 156 } 151 int found = checkForStateEvent(data, eventLst); 152 if(found && useRootFinding) 153 { 154 *eventTime = findRoot(data, threadData, eventLst, data->simulationInfo->timeValueOld, data->simulationInfo->realVarsOld, data->localData[0]->timeValue, data->localData[0]->realVars); 157 155 } 158 156 … … 287 285 * \param [ref] [threadData] 288 286 * \param [ref] [eventList] 289 * \return: first event of interval [oldTime, timeValue] 290 * 291 * This function perform a root finding for interval = [oldTime, timeValue] 292 */ 293 double findRoot(DATA* data, threadData_t *threadData, LIST *eventList) 287 * \param [in] [time_left] 288 * \param [in] [values_left] 289 * \param [in] [time_right] 290 * \param [in] [values_right] 291 * \return: first event of interval [time_left, time_right] 292 */ 293 double findRoot(DATA* data, threadData_t* threadData, LIST* eventList, double time_left, double* values_left, double time_right, double* values_right) 294 294 { 295 295 TRACE_PUSH … … 303 303 static double *states_right = NULL; 304 304 305 double time_left = data->simulationInfo->timeValueOld;306 double time_right = data->localData[0]->timeValue;307 308 305 /* allocate memory once at first call, never free */ 309 306 if(!states_left) … … 319 316 320 317 /* write states to work arrays */ 321 memcpy(states_left, data->simulationInfo->realVarsOld,data->modelData->nStates * sizeof(double));322 memcpy(states_right, data->localData[0]->realVars, data->modelData->nStates * sizeof(double));318 memcpy(states_left, values_left, data->modelData->nStates * sizeof(double)); 319 memcpy(states_right, values_right, data->modelData->nStates * sizeof(double)); 323 320 324 321 for(it=listFirstNode(eventList); it; it=listNextNode(it)) -
OMCompiler/SimulationRuntime/c/simulation/solver/events.h
r83be5f2b r14ac561 50 50 void handleEvents(DATA* data, threadData_t *threadData, LIST* eventLst, double *eventTime, SOLVER_INFO* solverInfo); 51 51 52 double findRoot(DATA *data, threadData_t *threadData, LIST *eventList);52 double findRoot(DATA* data, threadData_t* threadData, LIST* eventList, double time_left, double* states_left, double time_right, double* states_right); 53 53 54 54 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.