GridHelpers.hpp
Go to the documentation of this file.
1/*
2 Copyright 2014, 2015 Dr. Markus Blatt - HPC-Simulation-Software & Services
3 Copyright 2014 Statoil AS
4 Copyright 2015
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21#ifndef OPM_CORE_GRIDHELPERS_HEADER_INCLUDED
22#define OPM_CORE_GRIDHELPERS_HEADER_INCLUDED
23
24#include <dune/common/fvector.hh>
25
27
28#include <opm/common/utility/IteratorRange.hpp>
29
30namespace Opm
31{
32
33class EclipseGrid;
34
35namespace UgGridHelpers
36{
37
44{
45public:
47 using row_type = iterator_range_pod<int>;
48
54 SparseTableView(int* data, unsigned *offset, std::size_t size_arg)
55 : data_(data), offset_(offset), size_(size_arg)
56 {}
57
61 row_type operator[](std::size_t row) const
62 {
63 assert(row<=size());
64 return row_type{data_ + offset_[row],
65 data_ + offset_[row+1]};
66 }
67
70 std::size_t size() const
71 {
72 return size_;
73 }
74
76 std::size_t noEntries() const
77 {
78 return offset_[size_];
79 }
80
81private:
83 const int* data_;
87 const unsigned* offset_;
89 std::size_t size_;
90};
91
93int numCells(const UnstructuredGrid& grid);
94
96int numFaces(const UnstructuredGrid& grid);
97
100
103
105const int* cartDims(const UnstructuredGrid& grid);
106
111const int* globalCell(const UnstructuredGrid& grid);
112
117std::vector<int> createACTNUM(const UnstructuredGrid& grid);
118
119
125template<class G>
127{
128};
129
130template<>
132{
133 typedef const double* IteratorType;
134 typedef const double* ValueType;
135};
136
143
144
148double cellCenterDepth(const UnstructuredGrid& grid, int cell_index);
149
155Dune::FieldVector<double,3> faceCenterEcl(const UnstructuredGrid& grid, int cell_index, int face_tag);
156
163Dune::FieldVector<double,3> faceAreaNormalEcl(const UnstructuredGrid& grid, int face_index);
164
165
170double cellCentroidCoordinate(const UnstructuredGrid& grid, int cell_index,
171 int coordinate);
172
173
177const double* cellCentroid(const UnstructuredGrid& grid, int cell_index);
178
179
183double cellVolume(const UnstructuredGrid& grid, int cell_index);
184
190template<class T>
192{
193};
194
195template<>
197{
198 typedef const double* IteratorType;
199};
200
223Opm::EclipseGrid createEclipseGrid(const UnstructuredGrid& grid, const Opm::EclipseGrid& inputGrid );
224
226const double* beginCellVolumes(const UnstructuredGrid& grid);
227
229const double* endCellVolumes(const UnstructuredGrid& grid);
230
231
232
238template<class G>
240{
241};
242
243template<>
245{
246 typedef const double* IteratorType;
247 typedef const double* ValueType;
248};
249
253
258faceCentroid(const UnstructuredGrid& grid, int face_index);
259
263const double* faceNormal(const UnstructuredGrid& grid, int face_index);
264
268double faceArea(const UnstructuredGrid& grid, int face_index);
269
274template<class T>
276{
277};
278
279template<>
281{
283};
284
289template<class T>
291{
292};
293
294template<>
296{
298};
299
303
307
311const double* vertexCoordinates(const UnstructuredGrid& grid, int index);
312
314{
315public:
316 explicit FaceCellsProxy(const UnstructuredGrid& grid)
317 : face_cells_(grid.face_cells)
318 {}
319 int operator()(int face_index, int local_index) const
320 {
321 return face_cells_[2*face_index+local_index];
322 }
323private:
324 const int* face_cells_;
325};
326
331template<class T>
333{};
334
335template<>
337{
339};
340
343
349template<class T>
350T* increment(T* cc, int i, int dim)
351{
352 return cc+(i*dim);
353}
358template<class T>
359T increment(const T& t, int i, int)
360{
361 return t+i;
362}
363
368template<class T>
369double getCoordinate(const T* cc, int i)
370{
371 return cc[i];
372}
373
379template<class T>
380double getCoordinate(T t, int i)
381{
382 return (*t)[i];
383}
384
385
386
387
388
389} // end namespace UGGridHelpers
390} // end namespace OPM
391#endif
DataHandle & data
Definition: CpGridData.hpp:1136
Definition: GridHelpers.hpp:314
FaceCellsProxy(const UnstructuredGrid &grid)
Definition: GridHelpers.hpp:316
int operator()(int face_index, int local_index) const
Definition: GridHelpers.hpp:319
Allows viewing a sparse table consisting out of C-array.
Definition: GridHelpers.hpp:44
SparseTableView(int *data, unsigned *offset, std::size_t size_arg)
Creates a sparse table view.
Definition: GridHelpers.hpp:54
std::size_t noEntries() const
Get the number of non-zero entries.
Definition: GridHelpers.hpp:76
iterator_range_pod< int > row_type
The type of the roww.
Definition: GridHelpers.hpp:47
std::size_t size() const
Get the size of the table.
Definition: GridHelpers.hpp:70
row_type operator[](std::size_t row) const
Get a row of the the table.
Definition: GridHelpers.hpp:61
T * increment(T *cc, int i, int dim)
Increment an iterator over an array that reresents a dense row-major matrix with dims columns.
Definition: GridHelpers.hpp:350
double faceArea(const Dune::CpGrid &grid, int face_index)
Dune::cpgrid::Cell2FacesContainer cell2Faces(const Dune::CpGrid &grid)
Get the cell to faces mapping of a grid.
double cellCenterDepth(const Dune::CpGrid &grid, int cell_index)
Get vertical position of cell center ("zcorn" average).
EclipseGrid createEclipseGrid(const Dune::CpGrid &grid, const EclipseGrid &inputGrid)
const FaceCentroidTraits< Dune::CpGrid >::ValueType & faceCentroid(const Dune::CpGrid &grid, int face_index)
Get a coordinate of a specific face centroid.
Vector faceAreaNormalEcl(const Dune::CpGrid &grid, int face_index)
Get a area weighted normal vector of a specific face.
CellVolumeIterator beginCellVolumes(const Dune::CpGrid &grid)
Get an iterator over the cell volumes of a grid positioned at the first cell.
Vector faceCenterEcl(const Dune::CpGrid &grid, int cell_index, int face_tag)
Get a coordinate of a specific face center.
const double * cellCentroid(const Dune::CpGrid &grid, int cell_index)
Get the centroid of a cell.
CellVolumeIterator endCellVolumes(const Dune::CpGrid &grid)
Get an iterator over the cell volumes of a grid positioned one after the last cell.
FaceCentroidTraits< Dune::CpGrid >::IteratorType beginFaceCentroids(const Dune::CpGrid &grid)
Get an iterator over the face centroids positioned at the first cell.
Face2VerticesTraits< Dune::CpGrid >::Type face2Vertices(const Dune::CpGrid &grid)
Get the face to vertices mapping of a grid.
double getCoordinate(const T *cc, int i)
Get the i-th corrdinate of a centroid.
Definition: GridHelpers.hpp:369
double cellCentroidCoordinate(const Dune::CpGrid &grid, int cell_index, int coordinate)
Get a coordinate of a specific cell centroid.
const int * cartDims(const Dune::CpGrid &grid)
Get the cartesion dimension of the underlying structured grid.
int numCells(const Dune::CpGrid &grid)
Get the number of cells of a grid.
const int * globalCell(const Dune::CpGrid &)
Get the local to global index mapping.
std::vector< int > createACTNUM(const Dune::CpGrid &grid)
Create Eclipse style ACTNUM array.
FaceCellTraits< Dune::CpGrid >::Type faceCells(const Dune::CpGrid &grid)
Get the face to cell mapping of a grid.
int numFaces(const Dune::CpGrid &grid)
Get the number of faces of a grid.
CellCentroidTraits< Dune::CpGrid >::IteratorType beginCellCentroids(const Dune::CpGrid &grid)
int numCellFaces(const Dune::CpGrid &grid)
Get the number of faces, where each face counts as many times as there are adjacent faces.
double cellVolume(const Dune::CpGrid &grid, int cell_index)
Get the volume of a cell.
int dimensions(const Dune::CpGrid &grid)
Get the dimensions of a grid.
const double * vertexCoordinates(const Dune::CpGrid &grid, int index)
Get the coordinates of a vertex of the grid.
const double * faceNormal(const Dune::CpGrid &grid, int face_index)
Holds the implementation of the CpGrid as a pimple.
Definition: CellQuadrature.hpp:26
face_tag
Definition: preprocess.h:66
SparseTableView Type
Definition: GridHelpers.hpp:282
Maps the grid type to the associated type of the cell to faces mapping.
Definition: GridHelpers.hpp:276
const double * IteratorType
Definition: GridHelpers.hpp:133
const double * ValueType
Definition: GridHelpers.hpp:134
Traits of the cell centroids of a grid.
Definition: GridHelpers.hpp:127
const double * IteratorType
Definition: GridHelpers.hpp:198
The mapping of the grid type to type of the iterator over the cell volumes.
Definition: GridHelpers.hpp:192
SparseTableView Type
Definition: GridHelpers.hpp:297
Maps the grid type to the associated type of the face to vertices mapping.
Definition: GridHelpers.hpp:291
FaceCellsProxy Type
Definition: GridHelpers.hpp:338
Traits of the face to attached cell mappping of a grid.
Definition: GridHelpers.hpp:333
const double * IteratorType
Definition: GridHelpers.hpp:246
const double * ValueType
Definition: GridHelpers.hpp:247
Traits of the face centroids of a grid.
Definition: GridHelpers.hpp:240
Definition: UnstructuredGrid.h:101