Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect canHandleVariableCommunicationStepSize in FMI{2|3}CSSimulation.c #615

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions fmusim/FMI2CSSimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ FMIStatus FMI2CSSimulate(const FMISimulationSettings* s) {
fmi2Real nextCommunicationPoint = 0.0;
fmi2Real nextInputEventTime = 0.0;
fmi2Real stepSize = 0.0;

const bool canHandleVariableCommunicationStepSize = s->modelDescription->coSimulation->canHandleVariableCommunicationStepSize;

char resourcePath[FMI_PATH_MAX] = "";
char resourceURI[FMI_PATH_MAX] = "";
Expand Down Expand Up @@ -68,12 +70,16 @@ FMIStatus FMI2CSSimulate(const FMISimulationSettings* s) {

nextInputEventTime = FMINextInputEvent(s->input, time);

if (nextCommunicationPoint > nextInputEventTime && !FMIIsClose(nextCommunicationPoint, nextInputEventTime)) {
if (canHandleVariableCommunicationStepSize &&
nextCommunicationPoint > nextInputEventTime &&
!FMIIsClose(nextCommunicationPoint, nextInputEventTime)) {

nextCommunicationPoint = nextInputEventTime;
}

if (nextCommunicationPoint > s->stopTime && !FMIIsClose(nextCommunicationPoint, s->stopTime)) {
if (s->modelDescription->coSimulation->canHandleVariableCommunicationStepSize) {

if (canHandleVariableCommunicationStepSize) {
nextCommunicationPoint = s->stopTime;
} else {
break;
Expand Down
9 changes: 7 additions & 2 deletions fmusim/FMI3CSSimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ FMIStatus FMI3CSSimulate(const FMISimulationSettings* s) {
FMIStatus status = FMIOK;

FMIInstance* S = s->S;
const bool canHandleVariableCommunicationStepSize = s->modelDescription->coSimulation->canHandleVariableCommunicationStepSize;

fmi3Boolean inputEvent = fmi3False;
fmi3Boolean eventEncountered = fmi3False;
Expand Down Expand Up @@ -141,12 +142,16 @@ FMIStatus FMI3CSSimulate(const FMISimulationSettings* s) {

nextInputEventTime = FMINextInputEvent(s->input, time);

if (nextCommunicationPoint > nextInputEventTime && !FMIIsClose(nextCommunicationPoint, nextInputEventTime)) {
if (canHandleVariableCommunicationStepSize &&
nextCommunicationPoint > nextInputEventTime &&
!FMIIsClose(nextCommunicationPoint, nextInputEventTime)) {

nextCommunicationPoint = nextInputEventTime;
}

if (nextCommunicationPoint > s->stopTime && !FMIIsClose(nextCommunicationPoint, s->stopTime)) {
if (s->modelDescription->coSimulation->canHandleVariableCommunicationStepSize) {

if (canHandleVariableCommunicationStepSize) {
nextCommunicationPoint = s->stopTime;
} else {
break;
Expand Down
Loading