Fix logic error in defining "left" reservoir half in scenario 2.

Specifically, we must map into 0..cd[0]-1 and not some other
interval.  Moreover, as the "i" index cycles the most rapidly in
lexicographical ordering, a simple first dimension modulus operator is
sufficient.

On the other hand, this code does assume lexicographical ordering of
the cells which may or may not be guaranteed by the grid constructor.
The Cartesian constructors observe this behaviour, but other
constructors may not...
This commit is contained in:
Bård Skaflestad 2012-02-27 19:59:01 +01:00
parent 363c6564d9
commit 84aad52d81

View File

@ -393,7 +393,7 @@ main(int argc, char** argv)
std::vector<double>& sat = state.saturation();
for (int cell = 0; cell < num_cells; ++cell) {
const int* cd = grid->c_grid()->cartdims;
bool left = cell%(cd[1]*cd[2]) < cd[0]/2;
bool left = (cell % cd[0]) < cd[0]/2;
sat[2*cell] = left ? 1.0 : 0.0;
sat[2*cell + 1] = 1.0 - sat[2*cell];
}