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>
59 typedef typename Opm::SparseTable<ToType>::row_type R;
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>
98 typedef typename Opm::SparseTable<ToType>::mutable_row_type R;
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>
146 typedef typename super_t::mutable_row_type mutable_row_type;
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());
385 #endif // OPM_ORIENTEDENTITYTABLE_HEADER 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
int index() const
The (positive) index of an entity.
Definition: EntityRep.hpp:125
OPM_HOST_DEVICE bool empty() const
True if the table contains no rows.
Definition: SparseTable.hpp:189
bool orientation() const
Returns true if the entity has positive orientation.
Definition: EntityRep.hpp:139
MutableOrientedEntityRange(const R &r, bool orientation)
Constructor taking a row type and an orientation.
Definition: OrientedEntityTable.hpp:108
EntityRep opposite() const
Returns an EntityRep with opposite orientation.
Definition: EntityRep.hpp:146
void printSparseRelationMatrix(std::ostream &os) const
Prints the relation matrix corresponding to the table, sparse format.
Definition: OrientedEntityTable.hpp:242
A SparseTable stores a table with rows of varying size as efficiently as possible.
Definition: SparseTable.hpp:116
The namespace Dune is the main namespace for all Dune code.
Definition: CartesianIndexMapper.hpp:9
ToType operator[](int subindex) const
Random access operator.
Definition: OrientedEntityTable.hpp:119
OPM_HOST_DEVICE int size() const
Returns the number of rows in the table.
Definition: SparseTable.hpp:195
void swap(SparseTable< T > &other)
Swap contents for other SparseTable<T>
Definition: SparseTable.hpp:208
OPM_HOST_DEVICE int dataSize() const
Returns the number of data elements.
Definition: SparseTable.hpp:215
Represents the topological relationships between sets of entities, for example cells and faces...
Definition: OrientedEntityTable.hpp:138
OPM_HOST_DEVICE bool operator==(const SparseTable &other) const
Equality.
Definition: SparseTable.hpp:331
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
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:117
OrientedEntityTable()
Default constructor.
Definition: OrientedEntityTable.hpp:149
void clear()
Makes the table empty().
Definition: SparseTable.hpp:231
ToType operator[](int subindex) const
Random access operator.
Definition: OrientedEntityTable.hpp:80
OPM_HOST_DEVICE row_type operator[](int row) const
Returns a row of the table.
Definition: SparseTable.hpp:272
MutableOrientedEntityRange()
Default constructor yielding an empty range.
Definition: OrientedEntityTable.hpp:101
OPM_HOST_DEVICE int rowSize(int row) const
Returns the size of a table row.
Definition: SparseTable.hpp:221
void allocate(IntegerIter rowsize_beg, IntegerIter rowsize_end)
Request storage for table of given size.
Definition: SparseTable.hpp:170
OrientedEntityRange()
Default constructor yielding an empty range.
Definition: OrientedEntityTable.hpp:62
void printRelationMatrix(std::ostream &os) const
Prints the full relation matrix corresponding to the table.
Definition: OrientedEntityTable.hpp:272
void swap(OrientedEntityTable &other)
Swap contents for other OrientedEntityTable.
Definition: OrientedEntityTable.hpp:215
A class used as a row type for OrientedEntityTable.
Definition: OrientedEntityTable.hpp:93
OrientedEntityRange(const R &r, bool orientation)
Constructor taking a row type and an orientation.
Definition: OrientedEntityTable.hpp:69
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
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
Represents an entity of a given codim, with positive or negative orientation.
Definition: CpGridData.hpp:96
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
void appendRow(DataIter row_beg, DataIter row_end)
Appends a row to the table.
Definition: SparseTable.hpp:182
bool operator==(const OrientedEntityTable &other) const
Elementwise equality.
Definition: OrientedEntityTable.hpp:209
A class used as a row type for OrientedEntityTable.
Definition: OrientedEntityTable.hpp:54