Skip to content

Commit

Permalink
[iss-214]
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 23587cd
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Apr 19 13:21:53 2023 -0300

    Fix reinit state assignments.
  • Loading branch information
joaquinffernandez committed Apr 19, 2023
1 parent 8e1fdef commit 6383252
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
16 changes: 12 additions & 4 deletions src/engine/qss/parallel/qss_par_integrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ void QSS_PAR_internalEvent(QSS_simulator simulator)
if (event[index].direction == 0 || event[index].direction == s) {
nRHSSt = event[index].nRHSSt;
int restore_index = 0;
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
reinit_assign[restore_index++] = x[infCf0];
}
for (i = 0; i < nRHSSt; i++) {
j = event[index].RHSSt[i];
elapsed = t - tq[j];
Expand All @@ -346,7 +352,6 @@ void QSS_PAR_internalEvent(QSS_simulator simulator)
}
tq[j] = t;
elapsed = t - tx[j];
reinit_assign[restore_index++] = x[infCf0];
if (elapsed > 0) {
x[infCf0] = evaluatePoly(infCf0, elapsed, x, xOrder);
}
Expand All @@ -356,7 +361,6 @@ void QSS_PAR_internalEvent(QSS_simulator simulator)
} else {
qssModel->events->handlerNeg(index, x, q, d, a, t);
}
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
Expand Down Expand Up @@ -713,6 +717,12 @@ void QSS_PAR_integrator(QSS_simulator simulator)
#endif
nRHSSt = event[index].nRHSSt;
int restore_index = 0;
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
reinit_assign[restore_index++] = x[infCf0];
}
for (i = 0; i < nRHSSt; i++) {
j = event[index].RHSSt[i];
elapsed = t - tq[j];
Expand All @@ -722,7 +732,6 @@ void QSS_PAR_integrator(QSS_simulator simulator)
}
tq[j] = t;
elapsed = t - tx[j];
reinit_assign[restore_index++] = x[infCf0];
if (elapsed > 0) {
x[infCf0] = evaluatePoly(infCf0, elapsed, x, xOrder);
}
Expand All @@ -732,7 +741,6 @@ void QSS_PAR_integrator(QSS_simulator simulator)
} else {
qssModel->events->handlerNeg(index, x, q, d, a, t);
}
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
Expand Down
8 changes: 6 additions & 2 deletions src/engine/qss/qss_hyb_integrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,12 @@ void QSS_HYB_integrate(SIM_simulator simulate)
#endif
nRHSSt = event[index].nRHSSt;
int restore_index = 0;
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
reinit_assign[restore_index++] = x[infCf0];
}
for (i = 0; i < nRHSSt; i++) {
j = event[index].RHSSt[i];
infCf0 = j * coeffs;
Expand All @@ -719,7 +725,6 @@ void QSS_HYB_integrate(SIM_simulator simulate)
}
tq[j] = t;
elapsed = t - tx[j];
reinit_assign[restore_index++] = x[infCf0];
if (elapsed > 0) {
x[infCf0] = evaluatePoly(infCf0, elapsed, x, xOrder);
}
Expand All @@ -729,7 +734,6 @@ void QSS_HYB_integrate(SIM_simulator simulate)
} else {
qssModel->events->handlerNeg(index, x, q, d, a, t);
}
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
Expand Down
10 changes: 7 additions & 3 deletions src/engine/qss/qss_seq_integrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <math.h>

#include <common/data.h>
#include "../common/simulator.h"
#include <common/simulator.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_frw.h>
Expand Down Expand Up @@ -196,6 +196,12 @@ void QSS_SEQ_integrate(SIM_simulator simulate)
#endif
nRHSSt = event[index].nRHSSt;
int restore_index = 0;
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
reinit_assign[restore_index++] = x[infCf0];
}
for (i = 0; i < nRHSSt; i++) {
j = event[index].RHSSt[i];
infCf0 = j * coeffs;
Expand All @@ -205,7 +211,6 @@ void QSS_SEQ_integrate(SIM_simulator simulate)
}
tq[j] = t;
elapsed = t - tx[j];
reinit_assign[restore_index++] = x[infCf0];
if (elapsed > 0) {
x[infCf0] = evaluatePoly(infCf0, elapsed, x, xOrder);
}
Expand All @@ -215,7 +220,6 @@ void QSS_SEQ_integrate(SIM_simulator simulate)
} else {
qssModel->events->handlerNeg(index, x, q, d, a, t);
}
int nReinitAssign = event[index].nReinitAsg;
for (i = 0; i < nReinitAssign; i++) {
j = event[index].ReinitAsg[i];
infCf0 = j * coeffs;
Expand Down

0 comments on commit 6383252

Please sign in to comment.