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)
244 for (
int i = 0; i <
size(); ++i) {
247 const int rsize = r.size();
248 for (
int j = 0; j < rsize; ++j) {
249 os << i <<
' ' << r[j].index() <<
' ' << (r[j].orientation() ? 1 : -1) <<
'\n';
274 int columns = numberOfColumns();
275 for (
int i = 0; i <
size(); ++i) {
280 ToType to_ent = r[next_ent];
281 int next_print = to_ent.
index();
282 while (cur_col < columns) {
283 if (cur_col == next_print) {
290 if (next_ent >= r.size()) {
291 next_print = columns;
293 to_ent = r[next_ent];
294 next_print = to_ent.
index();
316 for (
int i = 0; i <
size(); ++i) {
319 for (
int j = 0; j < r.size(); ++j) {
321 int ind = to_ent.
index();
322 maxind = std::max(ind, maxind);
326 std::vector<int> new_sizes(maxind + 1);
328 for (
int i = 0; i <
size(); ++i) {
331 datacount += r.size();
332 for (
int j = 0; j < r.size(); ++j) {
334 int ind = to_ent.
index();
339 std::vector<int> cumul_sizes(new_sizes.size() + 1);
341 std::partial_sum(new_sizes.begin(), new_sizes.end(), cumul_sizes.begin() + 1);
345 std::vector<EntityRep<codim_from> > new_data(datacount);
346 for (
int i = 0; i <
size(); ++i) {
349 for (
int j = 0; j < r.size(); ++j) {
351 int ind = to_ent.
index();
352 int data_ind = cumul_sizes[ind];
364 int numberOfColumns()
const
367 for (
int i = 0; i <
size(); ++i) {
368 FromType from_ent(i,
true);
370 for (
int j = 0; j < r.size(); ++j) {
371 maxind = std::max(maxind, r[j].index());
Struct that hods all the data needed to represent a Cpgrid.
Definition CpGridData.hpp:147
Represents an entity of a given codim, with positive or negative orientation.
Definition PartitionTypeIndicator.hpp:47
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
void swap(OrientedEntityTable &other)
Swap contents for other OrientedEntityTable.
Definition OrientedEntityTable.hpp:215
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:272
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:242
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:311
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
void swap(SparseTable< T > &other)
Swap contents for other SparseTable<T>
Definition SparseTable.hpp:134
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