/var/opm/opm-verteq/opm/verteq/utility/runlen.hpp Regards a set of (member) variables as a run-length encoded matrix. Each column can have a variable number of rows. Although the values of the matrix can be changed, its sparsity cannot, i.e. one cannot remove or add new elements to a column. Use this class to access and iterate over a run-length encoded matrix in the format that is used by UnstructuredGrid without having to worry about getting the indexing right.
RunLenView <int> faces_in_cell (
g.number_of_cells,
g.cell_facepos,
g.cell_faces
);
int num_local_faces = faces_in_cell.size (cellno);
int first_local_face = faces_in_cell [cellno] [0];
Notice if you want to loop through every item and know where you are (because you intend to use this as an index in another matrix), you can do: #ifndef OPM_VERTEQ_RUNLEN_HPP_INCLUDED
#define OPM_VERTEQ_RUNLEN_HPP_INCLUDED
// Copyright (C) 2013 Uni Research AS
// This file is licensed under the GNU General Public License v3.0
// forward declaration
struct UnstructuredGrid;
namespace Opm {
template <typename T>
class RunLenView {
protected:
T* data;
public:
// store them locally for later use
: num_of_cols (num_cols)
, pos (pos_ptr)
, data (values) {
}
// copy all fields verbatim
: num_of_cols (rhs.num_of_cols)
}
}
return num_of_cols;
}
}
}
};
template <typename T>
struct RunLenData : public RunLenView <T> {
// allocate a new vector for the data, containing the needed
// number of elements. note that there is only one new
// operation is the parameter list, so there is no leakage if
// an out-of-memory exception is thrown.
: RunLenView <T> (number, pos_ptr, new T [pos_ptr [number]]) {
}
~RunLenData () {
// this member is initialized with data allocated in our ctor
delete [] RunLenView <T>::data;
}
};
// shorthands for most used types
// access common run-length encoded matrices in a grid structure
} /* namespace Opm */
#endif /* OPM_VERTEQ_RUNLEN_HPP_INCLUDED */
RunLenView(int num_cols, int *pos_ptr, T *values) Definition: runlen.hpp:91 Definition: opmfwd.hpp:15 rlw_int grid_cell_facetag(const UnstructuredGrid &g) rlw_int grid_cell_faces(const UnstructuredGrid &g) |
||