bool Physical::isPhysical(constint residual) {
/* check if all the physical properties are satisfied
(compare some inequalities) */
if (/*all inequalities are fine*/) returntrue;
elsereturnfalse;
}
bool Physical::isPhysical(const Physical &U_left,
const Physical &U_right,
const Physical &U_top,
const Physical &U_bottom) {
/* modify U[i][j] using the neighboring cells */
/* check if all the physical properties are satisfied
(compare some inequalities ) */
if (/*all inequalities are fine*/) returntrue;
elsereturnfalse;
}
When I run this code I get an error with the following output.
1 2 3
going in 0
coming out 0
ERROR
But to debug it, if I introduce any cout statement inside isPhysical
1 2 3 4 5 6 7 8 9 10 11 12 13
bool Physical::isPhysical(const Physical &U_left,
const Physical &U_right,
const Physical &U_top,
const Physical &U_bottom) {
cout<<"inside isPhysical \n";
/* modify U[i][j] using the neighboring cells */
/* check if all the physical properties are satisified
(compare some inequalities ) */
if (/*all inequalities are fine*/) returntrue;
elsereturnfalse;
}
, the code starts to run fine, with the output as:
Use an std::vector instead of an array, and use .at() instead of the [] operator. .at() throws an exception when you go out of bounds (or maybe it was an assert()?)