Skip to content

Commit

Permalink
Check isfinite() and fix includes
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Sep 26, 2024
1 parent fa78248 commit 72cc1e1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fmusim/FMI1CSSimulation.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "FMIUtil.h"
#include "FMI1.h"
#include "FMI1CSSimulation.h"

#define FMI_PATH_MAX 4096

#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus FMI1CSSimulate(const FMISimulationSettings* s) {

FMIStatus status = FMIOK;
Expand Down
7 changes: 1 addition & 6 deletions fmusim/FMI1MESimulation.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include <stdlib.h>
#include <math.h>

#include "FMIUtil.h"
#include "FMI1.h"
#include "FMI1MESimulation.h"


#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)


FMIStatus FMI1MESimulate(const FMISimulationSettings* s) {

FMIStatus status = FMIOK;
Expand Down Expand Up @@ -57,10 +56,6 @@ FMIStatus FMI1MESimulate(const FMISimulationSettings* s) {
// initialize
CALL(FMI1Initialize(S, s->tolerance > 0, s->tolerance, &eventInfo));

if (!eventInfo.upcomingTimeEvent) {
eventInfo.nextEventTime = INFINITY;
}

const FMISolverParameters solverFunctions = {
.modelInstance = S,
.input = s->input,
Expand Down
1 change: 0 additions & 1 deletion fmusim/FMI2CSSimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "FMI2.h"
#include "FMI2CSSimulation.h"


#define FMI_PATH_MAX 4096

#define CALL(f) do { status = f; if (status > FMIOK) goto TERMINATE; } while (0)
Expand Down
4 changes: 4 additions & 0 deletions fmusim/FMIUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@ FMIStatus FMIDuplicateBuffer(const void* source, void** destination, size_t size

bool FMIIsClose(double a, double b) {

if (!isfinite(a) || !isfinite(b)) {
return false;
}

if (fabs(a - b) <= EPSILON) {
return true;
}
Expand Down

0 comments on commit 72cc1e1

Please sign in to comment.