36#ifndef OPM_ORIENTEDENTITYTABLE_HEADER
37#define OPM_ORIENTEDENTITYTABLE_HEADER
39#include "EntityRep.hpp"
40#include <opm/grid/utility/SparseTable.hpp>
53 template <
int codim_to>
70 :
R(r), orientation_(orientation)
73 int size ()
const {
return R::size(); }
82 ToType erep = *(this->begin() + subindex);
83 return orientation_ ? erep : erep.
opposite();
92 template <
int codim_to>
109 :
R(r), orientation_(orientation)
112 int size ()
const {
return R::size(); }
121 ToType erep = R::operator[](subindex);
122 return orientation_ ? erep : erep.
opposite();
137 template <
int codim_from,
int codim_to>
164 template <
typename DataIter,
typename IntegerIter>
166 IntegerIter rowsize_beg, IntegerIter rowsize_end)
167 :
super_t(data_beg, data_end, rowsize_beg, rowsize_end)
238 for (
int i = 0; i <
size(); ++i) {
241 const int rsize = r.size();
242 for (
int j = 0; j < rsize; ++j) {
243 os << i <<
' ' << r[j].index() <<
' ' << (r[j].orientation() ? 1 : -1) <<
'\n';
268 int columns = numberOfColumns();
269 for (
int i = 0; i <
size(); ++i) {
274 ToType to_ent = r[next_ent];
275 int next_print = to_ent.
index();
276 while (cur_col < columns) {
277 if (cur_col == next_print) {
284 if (next_ent >= r.size()) {
285 next_print = columns;
287 to_ent = r[next_ent];
288 next_print = to_ent.
index();
310 for (
int i = 0; i <
size(); ++i) {
313 for (
int j = 0; j < r.size(); ++j) {
315 int ind = to_ent.
index();
316 maxind = std::max(ind, maxind);
320 std::vector<int> new_sizes(maxind + 1);
322 for (
int i = 0; i <
size(); ++i) {
325 datacount += r.size();
326 for (
int j = 0; j < r.size(); ++j) {
328 int ind = to_ent.
index();
333 std::vector<int> cumul_sizes(new_sizes.size() + 1);
335 std::partial_sum(new_sizes.begin(), new_sizes.end(), cumul_sizes.begin() + 1);
339 std::vector<EntityRep<codim_from> > new_data(datacount);
340 for (
int i = 0; i <
size(); ++i) {
343 for (
int j = 0; j < r.size(); ++j) {
345 int ind = to_ent.
index();
346 int data_ind = cumul_sizes[ind];
358 int numberOfColumns()
const
361 for (
int i = 0; i <
size(); ++i) {
362 FromType from_ent(i,
true);
364 for (
int j = 0; j < r.size(); ++j) {
365 maxind = std::max(maxind, r[j].index());
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:122
Represents an entity of a given codim, with positive or negative orientation.
Definition: EntityRep.hpp:99
bool orientation() const
Returns true if the entity has positive orientation.
Definition: EntityRep.hpp:140
EntityRep opposite() const
Returns an EntityRep with opposite orientation.
Definition: EntityRep.hpp:147
int index() const
The (positive) index of an entity.
Definition: EntityRep.hpp:126
A class used as a row type for OrientedEntityTable.
Definition: OrientedEntityTable.hpp:94
MutableOrientedEntityRange()
Default constructor yielding an empty range.
Definition: OrientedEntityTable.hpp:101
MutableOrientedEntityRange(const R &r, bool orientation)
Constructor taking a row type and an orientation.
Definition: OrientedEntityTable.hpp:108
ToType operator[](int subindex) const
Random access operator.
Definition: OrientedEntityTable.hpp:119
A class used as a row type for OrientedEntityTable.
Definition: OrientedEntityTable.hpp:55
OrientedEntityRange(const R &r, bool orientation)
Constructor taking a row type and an orientation.
Definition: OrientedEntityTable.hpp:69
OrientedEntityRange()
Default constructor yielding an empty range.
Definition: OrientedEntityTable.hpp:62
ToType operator[](int subindex) const
Random access operator.
Definition: OrientedEntityTable.hpp:80
Represents the topological relationships between sets of entities, for example cells and faces.
Definition: OrientedEntityTable.hpp:139
int size() const
Returns the number of rows in the table.
Definition: SparseTable.hpp:121
void printRelationMatrix(std::ostream &os) const
Prints the full relation matrix corresponding to the table.
Definition: OrientedEntityTable.hpp:266
mutable_row_type row(const FromType &e)
Given an entity e of codimension codim_from, returns a row (an indirect container) containing its nei...
Definition: OrientedEntityTable.hpp:202
OrientedEntityTable()
Default constructor.
Definition: OrientedEntityTable.hpp:149
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:165
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:192
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:182
bool operator==(const OrientedEntityTable &other) const
Elementwise equality.
Definition: OrientedEntityTable.hpp:209
void printSparseRelationMatrix(std::ostream &os) const
Prints the relation matrix corresponding to the table, sparse format.
Definition: OrientedEntityTable.hpp:236
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:305
A SparseTable stores a table with rows of varying size as efficiently as possible.
Definition: SparseTable.hpp:55
bool empty() const
True if the table contains no rows.
Definition: SparseTable.hpp:115
void appendRow(DataIter row_beg, DataIter row_end)
Appends a row to the table.
Definition: SparseTable.hpp:108
int size() const
Returns the number of rows in the table.
Definition: SparseTable.hpp:121
row_type operator[](int row) const
Returns a row of the table.
Definition: SparseTable.hpp:168
int rowSize(int row) const
Returns the size of a table row.
Definition: SparseTable.hpp:147
int dataSize() const
Returns the number of data elements.
Definition: SparseTable.hpp:141
void allocate(IntegerIter rowsize_beg, IntegerIter rowsize_end)
Request storage for table of given size.
Definition: SparseTable.hpp:96
void clear()
Makes the table empty().
Definition: SparseTable.hpp:157
bool operator==(const SparseTable &other) const
Equality.
Definition: SparseTable.hpp:227
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10
Definition: IteratorRange.hpp:50
Definition: IteratorRange.hpp:70