12 struct ExtractColumnCompare
20 bool operator()(
const int i,
const int j)
62 std::map<int, int> global_to_local;
66 int i_cart = index % dims[0];
67 int k_cart = index / dims[0] / dims[1];
68 int j_cart = (index - k_cart*dims[0]*dims[1])/ dims[0];
71 std::map<int, int>::iterator local_index_iterator = global_to_local.find(i_cart+j_cart*dims[0]);
72 if (local_index_iterator != global_to_local.end()) {
73 local_index = local_index_iterator->second;
75 local_index = columns.size();
76 global_to_local[i_cart+j_cart*dims[0]] = local_index;
77 columns.push_back(std::vector<int>());
79 columns[local_index].push_back(cell);
82 int num_cols = columns.size();
83 for (
int col = 0; col < num_cols; ++col) {
84 std::sort(columns[col].begin(), columns[col].end(), ExtractColumnCompare(grid));
89 std::vector< std::vector<int> > new_columns;
90 for (
int col = 0; col < num_cols; ++col) {
91 const int colsz = columns[col].size();
93 for (
int k = 1; k < colsz; ++k) {
94 const int c0 = columns[col][k-1];
95 const int c1 = columns[col][k];
96 if (!neighbours(grid, c0, c1)) {
99 new_columns.push_back(std::vector<int>());
100 new_columns.back().assign(columns[col].begin() + first_of_col, columns[col].begin() + k);
105 if (first_of_col != 0) {
109 columns[col].erase(columns[col].begin(), columns[col].begin() + first_of_col);
114 const int num_cols_all = num_cols + new_columns.size();
115 columns.resize(num_cols_all);
116 for (
int col = num_cols; col < num_cols_all; ++col) {
117 columns[col].swap(new_columns[col - num_cols]);
Main OPM-Core grid data structure along with helper functions for construction, destruction and readi...
Holds the implementation of the CpGrid as a pimple.
Definition: CellQuadrature.hpp:29
void extractColumn(const UnstructuredGrid &grid, std::vector< std::vector< int > > &columns)
Extract each column of the grid.
Definition: ColumnExtract.hpp:57
Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary num...
Definition: UnstructuredGrid.h:99
int number_of_cells
The number of cells in the grid.
Definition: UnstructuredGrid.h:109
int * cell_faces
Contains for each cell, the indices of its adjacent faces.
Definition: UnstructuredGrid.h:146
int * cell_facepos
For a cell c, cell_facepos[c] contains the starting index for c's faces in the cell_faces array.
Definition: UnstructuredGrid.h:152
int * face_cells
For a face f, face_cells[2*f] and face_cells[2*f + 1] contain the cell indices of the cells adjacent ...
Definition: UnstructuredGrid.h:138
int cartdims[3]
Contains the size of the logical cartesian structure (if any) of the grid.
Definition: UnstructuredGrid.h:227
int * global_cell
If non-null, this array contains the logical cartesian indices (in a lexicographic ordering) of each ...
Definition: UnstructuredGrid.h:214