Loading...
Searching...
No Matches
GridHelpers.hpp
/*
Copyright 2014, 2015 Dr. Markus Blatt - HPC-Simulation-Software & Services
Copyright 2014 Statoil AS
Copyright 2015
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_CORE_GRIDHELPERS_HEADER_INCLUDED
#define OPM_CORE_GRIDHELPERS_HEADER_INCLUDED
#include <dune/common/fvector.hh>
#include <opm/grid/UnstructuredGrid.h>
#include <opm/grid/utility/IteratorRange.hpp>
namespace Opm
{
class EclipseGrid;
namespace UgGridHelpers
{
class SparseTableView
{
public:
using row_type = iterator_range_pod<int>;
SparseTableView(int* data, unsigned *offset, std::size_t size_arg)
: data_(data), offset_(offset), size_(size_arg)
{}
row_type operator[](std::size_t row) const
{
assert(row<=size());
return row_type{data_ + offset_[row],
data_ + offset_[row+1]};
}
std::size_t size() const
{
return size_;
}
std::size_t noEntries() const
{
return offset_[size_];
}
private:
const int* data_;
const unsigned* offset_;
std::size_t size_;
};
int numCells(const UnstructuredGrid& grid);
int numFaces(const UnstructuredGrid& grid);
int dimensions(const UnstructuredGrid& grid);
int numCellFaces(const UnstructuredGrid& grid);
const int* cartDims(const UnstructuredGrid& grid);
const int* globalCell(const UnstructuredGrid& grid);
#if HAVE_ECL_INPUT
std::vector<int> createACTNUM(const UnstructuredGrid& grid);
#endif
template<class G>
struct CellCentroidTraits
{
};
template<>
struct CellCentroidTraits<UnstructuredGrid>
{
typedef const double* IteratorType;
typedef const double* ValueType;
};
CellCentroidTraits<UnstructuredGrid>::IteratorType
beginCellCentroids(const UnstructuredGrid& grid);
double cellCenterDepth(const UnstructuredGrid& grid, int cell_index);
Dune::FieldVector<double,3> faceCenterEcl(const UnstructuredGrid& grid, int cell_index, int face_tag);
Dune::FieldVector<double,3> faceAreaNormalEcl(const UnstructuredGrid& grid, int face_index);
double cellCentroidCoordinate(const UnstructuredGrid& grid, int cell_index,
int coordinate);
const double* cellCentroid(const UnstructuredGrid& grid, int cell_index);
double cellVolume(const UnstructuredGrid& grid, int cell_index);
template<class T>
struct CellVolumeIteratorTraits
{
};
template<>
struct CellVolumeIteratorTraits<UnstructuredGrid>
{
typedef const double* IteratorType;
};
#if HAVE_ECL_INPUT
Opm::EclipseGrid createEclipseGrid(const UnstructuredGrid& grid, const Opm::EclipseGrid& inputGrid );
#endif
const double* beginCellVolumes(const UnstructuredGrid& grid);
const double* endCellVolumes(const UnstructuredGrid& grid);
template<class G>
struct FaceCentroidTraits
{
};
template<>
struct FaceCentroidTraits<UnstructuredGrid>
{
typedef const double* IteratorType;
typedef const double* ValueType;
};
FaceCentroidTraits<UnstructuredGrid>::IteratorType
beginFaceCentroids(const UnstructuredGrid& grid);
FaceCentroidTraits<UnstructuredGrid>::ValueType
faceCentroid(const UnstructuredGrid& grid, int face_index);
const double* faceNormal(const UnstructuredGrid& grid, int face_index);
double faceArea(const UnstructuredGrid& grid, int face_index);
template<class T>
struct Cell2FacesTraits
{
};
template<>
struct Cell2FacesTraits<UnstructuredGrid>
{
typedef SparseTableView Type;
};
template<class T>
struct Face2VerticesTraits
{
};
template<>
struct Face2VerticesTraits<UnstructuredGrid>
{
typedef SparseTableView Type;
};
Cell2FacesTraits<UnstructuredGrid>::Type
cell2Faces(const UnstructuredGrid& grid);
Face2VerticesTraits<UnstructuredGrid>::Type
face2Vertices(const UnstructuredGrid& grid);
const double* vertexCoordinates(const UnstructuredGrid& grid, int index);
class FaceCellsProxy
{
public:
explicit FaceCellsProxy(const UnstructuredGrid& grid)
: face_cells_(grid.face_cells)
{}
int operator()(int face_index, int local_index) const
{
return face_cells_[2*face_index+local_index];
}
private:
const int* face_cells_;
};
template<class T>
struct FaceCellTraits
{};
template<>
struct FaceCellTraits<UnstructuredGrid>
{
typedef FaceCellsProxy Type;
};
FaceCellTraits<UnstructuredGrid>::Type faceCells(const UnstructuredGrid& grid);
template<class T>
T* increment(T* cc, int i, int dim)
{
return cc+(i*dim);
}
template<class T>
T increment(const T& t, int i, int)
{
return t+i;
}
template<class T>
double getCoordinate(const T* cc, int i)
{
return cc[i];
}
template<class T>
double getCoordinate(T t, int i)
{
return (*t)[i];
}
} // end namespace UGGridHelpers
} // end namespace OPM
#endif
UnstructuredGrid.h
Main OPM-Core grid data structure along with helper functions for construction, destruction and readi...
Opm::UgGridHelpers::FaceCellsProxy
Definition GridHelpers.hpp:318
Opm::UgGridHelpers::SparseTableView
Allows viewing a sparse table consisting out of C-array.
Definition GridHelpers.hpp:44
Opm::UgGridHelpers::SparseTableView::SparseTableView
SparseTableView(int *data, unsigned *offset, std::size_t size_arg)
Creates a sparse table view.
Definition GridHelpers.hpp:54
Opm::UgGridHelpers::SparseTableView::noEntries
std::size_t noEntries() const
Get the number of non-zero entries.
Definition GridHelpers.hpp:76
Opm::UgGridHelpers::SparseTableView::row_type
iterator_range_pod< int > row_type
The type of the roww.
Definition GridHelpers.hpp:47
Opm::UgGridHelpers::SparseTableView::size
std::size_t size() const
Get the size of the table.
Definition GridHelpers.hpp:70
Opm::UgGridHelpers::SparseTableView::operator[]
row_type operator[](std::size_t row) const
Get a row of the the table.
Definition GridHelpers.hpp:61
Opm
Holds the implementation of the CpGrid as a pimple.
Definition CellQuadrature.cpp:68
face_tag
face_tag
Connection taxonomy.
Definition preprocess.h:66
Opm::UgGridHelpers::Cell2FacesTraits
Maps the grid type to the associated type of the cell to faces mapping.
Definition GridHelpers.hpp:280
Opm::UgGridHelpers::CellCentroidTraits
Traits of the cell centroids of a grid.
Definition GridHelpers.hpp:129
Opm::UgGridHelpers::CellVolumeIteratorTraits
The mapping of the grid type to type of the iterator over the cell volumes.
Definition GridHelpers.hpp:194
Opm::UgGridHelpers::Face2VerticesTraits
Maps the grid type to the associated type of the face to vertices mapping.
Definition GridHelpers.hpp:295
Opm::UgGridHelpers::FaceCellTraits
Traits of the face to attached cell mappping of a grid.
Definition GridHelpers.hpp:337
Opm::UgGridHelpers::FaceCentroidTraits
Traits of the face centroids of a grid.
Definition GridHelpers.hpp:244
Opm::iterator_range_pod
Definition IteratorRange.hpp:29
UnstructuredGrid
Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary num...
Definition UnstructuredGrid.h:101
UnstructuredGrid::face_cells
int * face_cells
For a face f, face_cells[2*f] and face_cells[2*f + 1] contain the cell indices of the cells adjacent ...
Definition UnstructuredGrid.h:140