Made column extractor work also if grid.global_cell is null.

This commit is contained in:
Atgeirr Flø Rasmussen 2012-03-02 13:18:49 +01:00
parent 14a8990d15
commit cac47830ed

View File

@ -18,10 +18,12 @@ struct ExtractColumnCompare
bool operator()(const int i, const int j)
{
// Extract k-index
int k_i = grid.global_cell[i] / grid.cartdims[0] / grid.cartdims[1];
int k_j = grid.global_cell[j] / grid.cartdims[0] / grid.cartdims[1];
int index_i = grid.global_cell ? grid.global_cell[i] : i;
int k_i = index_i / grid.cartdims[0] / grid.cartdims[1];
int index_j = grid.global_cell ? grid.global_cell[j] : j;
int k_j = index_j / grid.cartdims[0] / grid.cartdims[1];
return k_i <= k_j;
return k_i < k_j;
}
const UnstructuredGrid& grid;
@ -38,7 +40,7 @@ void extractColumn( const UnstructuredGrid& grid, std::map<int, std::vector<int>
const int* dims = grid.cartdims;
for (int i = 0; i < grid.number_of_cells; ++i) {
// Extract Cartesian coordinates
int index = grid.global_cell[i];
int index = grid.global_cell ? grid.global_cell[i] : i; // If null, assume mapping is identity.
int i_cart = index % dims[0];
int k_cart = index / dims[0] / dims[1];
int j_cart = (index - k_cart*dims[0]*dims[1])/ dims[0];