36 #ifndef OPM_ORIENTEDENTITYTABLE_HEADER
37 #define OPM_ORIENTEDENTITYTABLE_HEADER
39 #include "EntityRep.hpp"
40 #include <opm/core/utility/SparseTable.hpp>
43 #include <boost/algorithm/minmax_element.hpp>
54 template <
int codim_to>
71 : R(r), orientation_(orientation)
74 int size ()
const {
return R::size(); }
83 ToType erep = R::operator[](subindex);
84 return orientation_ ? erep : erep.
opposite();
101 template <
int codim_from,
int codim_to>
127 template <
typename DataIter,
typename IntegerIter>
129 IntegerIter rowsize_beg, IntegerIter rowsize_end)
130 :
super_t(data_beg, data_end, rowsize_beg, rowsize_end)
191 for (
int i = 0; i <
size(); ++i) {
194 const int rsize = r.size();
195 for (
int j = 0; j < rsize; ++j) {
196 os << i <<
' ' << r[j].index() <<
' ' << (r[j].orientation() ? 1 : -1) <<
'\n';
221 int columns = numberOfColumns();
222 for (
int i = 0; i <
size(); ++i) {
227 ToType to_ent = r[next_ent];
228 int next_print = to_ent.
index();
229 while (cur_col < columns) {
230 if (cur_col == next_print) {
237 if (next_ent >= r.size()) {
238 next_print = columns;
240 to_ent = r[next_ent];
241 next_print = to_ent.
index();
263 for (
int i = 0; i <
size(); ++i) {
266 for (
int j = 0; j < r.size(); ++j) {
268 int ind = to_ent.
index();
269 maxind = std::max(ind, maxind);
273 std::vector<int> new_sizes(maxind + 1);
275 for (
int i = 0; i <
size(); ++i) {
278 datacount += r.size();
279 for (
int j = 0; j < r.size(); ++j) {
281 int ind = to_ent.
index();
286 std::vector<int> cumul_sizes(new_sizes.size() + 1);
288 std::partial_sum(new_sizes.begin(), new_sizes.end(), cumul_sizes.begin() + 1);
292 std::vector<EntityRep<codim_from> > new_data(datacount);
293 for (
int i = 0; i <
size(); ++i) {
296 for (
int j = 0; j < r.size(); ++j) {
298 int ind = to_ent.
index();
299 int data_ind = cumul_sizes[ind];
311 int numberOfColumns()
const
314 for (
int i = 0; i <
size(); ++i) {
315 FromType from_ent(i,
true);
317 for (
int j = 0; j < r.size(); ++j) {
318 maxind = std::max(maxind, r[j].index());
332 #endif // OPM_ORIENTEDENTITYTABLE_HEADER
int rowSize(int row) const
Returns the size of a table row.
Definition: SparseTable.hpp:150
int index() const
The (positive) index of an entity.
Definition: EntityRep.hpp:126
A SparseTable stores a table with rows of varying size as efficiently as possible.
Definition: SparseTable.hpp:54
void appendRow(DataIter row_beg, DataIter row_end)
Appends a row to the table.
Definition: SparseTable.hpp:107
Represents the topological relationships between sets of entities, for example cells and faces...
Definition: OrientedEntityTable.hpp:102
void makeInverseRelation(OrientedEntityTable< codim_to, codim_from > &inv) const
Makes the inverse relation, mapping codim_to entities to their codim_from neighbours.
Definition: OrientedEntityTable.hpp:258
void printRelationMatrix(std::ostream &os) const
Prints the full relation matrix corresponding to the table.
Definition: OrientedEntityTable.hpp:219
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:105
OrientedEntityTable()
Default constructor.
Definition: OrientedEntityTable.hpp:112
bool operator==(const SparseTable &other) const
Equality.
Definition: SparseTable.hpp:186
void clear()
Makes the table empty().
Definition: SparseTable.hpp:159
ToType operator[](int subindex) const
Random access operator.
Definition: OrientedEntityTable.hpp:81
bool operator==(const OrientedEntityTable &other) const
Elementwise equality.
Definition: OrientedEntityTable.hpp:162
void printSparseRelationMatrix(std::ostream &os) const
Prints the relation matrix corresponding to the table, sparse format.
Definition: OrientedEntityTable.hpp:189
int rowSize(const FromType &e) const
Given an entity e of codimension codim_from, returns the number of neighbours of codimension codim_to...
Definition: OrientedEntityTable.hpp:144
bool empty() const
True if the table contains no rows.
Definition: SparseTable.hpp:118
OrientedEntityRange()
Default constructor yielding an empty range.
Definition: OrientedEntityTable.hpp:63
int dataSize() const
Returns the number of data elements.
Definition: SparseTable.hpp:144
int size() const
Returns the number of rows in the table.
Definition: SparseTable.hpp:124
bool orientation() const
Returns true if the entity has positive orientation.
Definition: EntityRep.hpp:135
row_type operator[](const FromType &e) const
Given an entity e of codimension codim_from, returns a row (an indirect container) containing its nei...
Definition: OrientedEntityTable.hpp:154
boost::iterator_range< const T * > row_type
Defining the row type, returned by operator[].
Definition: SparseTable.hpp:166
OrientedEntityRange(const R &r, bool orientation)
Constructor taking a row type and an orientation.
Definition: OrientedEntityTable.hpp:70
Represents an entity of a given codim, with positive or negative orientation.
Definition: CpGridData.hpp:94
OrientedEntityTable(DataIter data_beg, DataIter data_end, IntegerIter rowsize_beg, IntegerIter rowsize_end)
Constructor taking iterators to a sequence of table data and a sequence of row size data...
Definition: OrientedEntityTable.hpp:128
EntityRep opposite() const
Returns an EntityRep with opposite orientation.
Definition: EntityRep.hpp:142
A class used as a row type for OrientedEntityTable.
Definition: OrientedEntityTable.hpp:55