Dune::CpGrid Class Reference

[ provides Dune::Grid ] More...

#include <CpGrid.hpp>

Inheritance diagram for Dune::CpGrid:

Classes

class  CentroidIterator
 An iterator over the centroids of the geometry of the entities. More...
 

Public Types

typedef CpGridFamily GridFamily
 Family typedef, why is this not defined by Grid<>?
 

Public Member Functions

 CpGrid ()
 Default constructor.
 
bool uniqueBoundaryIds () const
 Is the grid currently using unique boundary ids? More...
 
void setUniqueBoundaryIds (bool uids)
 Set whether we want to have unique boundary ids. More...
 
IO routines
void readSintefLegacyFormat (const std::string &grid_prefix)
 Read the Sintef legacy grid format ('topogeom'). More...
 
void writeSintefLegacyFormat (const std::string &grid_prefix) const
 Write the Sintef legacy grid format ('topogeom'). More...
 
void processEclipseFormat (const grdecl &input_data, double z_tolerance, bool remove_ij_boundary, bool turn_normals=false)
 Read the Eclipse grid format ('grdecl'). More...
 
Cartesian grid extensions.

A cornerpoint grid can be seen as a degenerated and distorted cartesian grid.

Therefore it provides mappings from cells to the underlying cartesian index.

void createCartesian (const array< int, 3 > &dims, const array< double, 3 > &cellsize)
 Create a cartesian grid. More...
 
const std::array< int, 3 > & logicalCartesianSize () const
 The logical cartesian size of the global grid. More...
 
const std::vector< int > & globalCell () const
 Retrieve mapping from internal ("compressed") active grid cells to external ("uncompressed") cells. More...
 
void getIJK (const int c, std::array< int, 3 > &ijk) const
 Extract Cartesian index triplet (i,j,k) of an active cell. More...
 
The DUNE grid interface implementation
std::string name () const
 Get the grid name. More...
 
int maxLevel () const
 Return maximum level defined in this grid. More...
 
template<int codim>
Traits::template Codim< codim >::LevelIterator lbegin (int level) const
 Iterator to first entity of given codim on level.
 
template<int codim>
Traits::template Codim< codim >::LevelIterator lend (int level) const
 one past the end on this level
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin (int level) const
 Iterator to first entity of given codim on level.
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend (int level) const
 one past the end on this level
 
template<int codim>
Traits::template Codim< codim >::LeafIterator leafbegin () const
 Iterator to first leaf entity of given codim.
 
template<int codim>
Traits::template Codim< codim >::LeafIterator leafend () const
 one past the end of the sequence of leaf entities
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin () const
 Iterator to first leaf entity of given codim.
 
template<int codim, PartitionIteratorType PiType>
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend () const
 one past the end of the sequence of leaf entities
 
int size (int level, int codim) const
 Number of grid entities per level and codim.
 
int size (int codim) const
 number of leaf entities per codim in this process
 
int size (int level, GeometryType type) const
 number of entities per level and geometry type in this process
 
int size (GeometryType type) const
 number of leaf entities per geometry type in this process
 
const Traits::GlobalIdSet & globalIdSet () const
 Access to the GlobalIdSet.
 
const Traits::LocalIdSet & localIdSet () const
 Access to the LocalIdSet.
 
const Traits::LevelIndexSet & levelIndexSet (int level) const
 Access to the LevelIndexSets.
 
const Traits::LeafIndexSet & leafIndexSet () const
 Access to the LeafIndexSet.
 
void globalRefine (int)
 global refinement
 
const std::vector< Dune ::GeometryType > & geomTypes (const int codim) const
 
template<int codim>
cpgrid::Entity< codim > entity (const cpgrid::EntityPointer< codim > &seed) const
 given an EntitySeed (or EntityPointer) return an entity object
 
unsigned int overlapSize (int) const
 Size of the overlap on the leaf level.
 
unsigned int ghostSize (int) const
 Size of the ghost cell layer on the leaf level.
 
unsigned int overlapSize (int, int) const
 Size of the overlap on a given level.
 
unsigned int ghostSize (int, int) const
 Size of the ghost cell layer on a given level.
 
unsigned int numBoundarySegments () const
 returns the number of boundary segments within the macro grid
 
bool loadBalance (int overlapLayers=1)
 Distributes this grid over the available nodes in a distributed machine. More...
 
std::pair< bool, std::unordered_set< std::string > > loadBalance (const OpmEclipseStateType *ecl, const double *transmissibilities=nullptr, int overlapLayers=1)
 Distributes this grid over the available nodes in a distributed machine. More...
 
template<class DataHandle >
std::pair< bool, std::unordered_set< std::string > > loadBalance (DataHandle &data, const OpmEclipseStateType *ecl, const double *transmissibilities=nullptr, int overlapLayers=1)
 Distributes this grid and data over the available nodes in a distributed machine. More...
 
template<class DataHandle >
bool loadBalance (DataHandle &data, int overlapLayers=1)
 Distributes this grid and data over the available nodes in a distributed machine. More...
 
template<class DataHandle >
void communicate (DataHandle &data, InterfaceType iftype, CommunicationDirection dir, int) const
 The new communication interface. More...
 
template<class DataHandle >
void communicate (DataHandle &data, InterfaceType iftype, CommunicationDirection dir) const
 The new communication interface. More...
 
const CollectiveCommunication & comm () const
 Get the collective communication object.
 

The simplified grid interface.

It provides additional methods not in the DUNE interface but needed by OPM.

Vertices, faces, and cells are not represented as entities but identified by indices.

typedef Dune::FieldVector< double, 3 > Vector
 
const std::vector< double > & zcornData () const
 
int numCells () const
 Get the number of cells.
 
int numFaces () const
 Get the number of faces.
 
int numVertices () const
 Get The number of vertices.
 
int numCellFaces (int cell) const
 Get the number of faces of a cell. More...
 
int cellFace (int cell, int local_index) const
 Get a specific face of a cell. More...
 
const cpgrid::OrientedEntityTable< 0, 1 >::row_type cellFaceRow (int cell) const
 Get a list of indices identifying all faces of a cell. More...
 
int faceCell (int face, int local_index) const
 Get the index identifying a cell attached to a face. More...
 
int numCellFaces () const
 Get the sum of all faces attached to all cells. More...
 
int numFaceVertices (int face) const
 
int faceVertex (int face, int local_index) const
 Get the index identifying a vertex of a face. More...
 
double cellCenterDepth (int cell_index) const
 Get vertical position of cell center ("zcorn" average). More...
 
const Vector faceCenterEcl (int cell_index, int faceTag) const
 
const Vector faceAreaNormalEcl (int face) const
 
const Vector & vertexPosition (int vertex) const
 Get the Position of a vertex. More...
 
double faceArea (int face) const
 Get the area of a face. More...
 
const Vector & faceCentroid (int face) const
 Get the coordinates of the center of a face. More...
 
const Vector & faceNormal (int face) const
 Get the unit normal of a face. More...
 
double cellVolume (int cell) const
 Get the volume of the cell. More...
 
const Vector & cellCentroid (int cell) const
 Get the coordinates of the center of a cell. More...
 
CentroidIterator< 0 > beginCellCentroids () const
 Get an iterator over the cell centroids positioned at the first one.
 
CentroidIterator< 1 > beginFaceCentroids () const
 Get an iterator over the face centroids positioned at the first one.
 
int boundaryId (int face) const
 
template<class Cell2FacesRowIterator >
int faceTag (const Cell2FacesRowIterator &cell_face) const
 Get the cartesian tag associated with a face tag. More...
 

Parallel grid extensions.

Methods extending the DUNE's parallel grid interface.

These are basically for scattering/gathering data to/from distributed views.

typedef std::map< int, std::list< int > > InterfaceMap
 The type of the map describing communication interfaces.
 
template<class DataHandle >
void scatterData (DataHandle &handle)
 Moves data from the global (all data on process) view to the distributed view. More...
 
template<class DataHandle >
void gatherData (DataHandle &handle)
 Moves data from the distributed view to the global (all data on process) view. More...
 
const InterfaceMapcellScatterGatherInterface () const
 Get an interface for gathering/scattering data with communication. More...
 
void switchToGlobalView ()
 Switch to the global view.
 
void switchToDistributedView ()
 Switch to the distributed view.
 

Detailed Description

[ provides Dune::Grid ]

Member Function Documentation

◆ cellCenterDepth()

double Dune::CpGrid::cellCenterDepth ( int  cell_index) const
inline

Get vertical position of cell center ("zcorn" average).

cell_index The index of the specific cell.

◆ cellCentroid()

const Vector& Dune::CpGrid::cellCentroid ( int  cell) const
inline

Get the coordinates of the center of a cell.

Parameters
cellThe index identifying the face.

◆ cellFace()

int Dune::CpGrid::cellFace ( int  cell,
int  local_index 
) const
inline

Get a specific face of a cell.

Parameters
cellThe index identifying the cell.
local_indexThe local index (in [0,numFaces(cell))) of the face in this cell.
Returns
The index identifying the face.

◆ cellFaceRow()

const cpgrid::OrientedEntityTable<0,1>::row_type Dune::CpGrid::cellFaceRow ( int  cell) const
inline

Get a list of indices identifying all faces of a cell.

Parameters
cellThe index identifying the cell.

◆ cellScatterGatherInterface()

const InterfaceMap& Dune::CpGrid::cellScatterGatherInterface ( ) const
inline

Get an interface for gathering/scattering data with communication.

Scattering means sending data from the indices of the global grid on process 0 to the distributed grid on all ranks independent of the grid. Gathering is the other way around. The interface can be used with VariableSizeCommunicator and a custom index based data handle to scatter (forward direction of the communicator) and gather data (backward direction of the communicator). Here is a small example that prints the received values when scattering:

struct Handle{
typedef int DataType;
const std::vector<int>& vals;
bool fixedsize() { return true; }
size_t size(std::size_t) { return 1; }
void gather(auto& B buf, size_t i)[ buf.write(vals[i]); }
void scatter(auto& B buf, size_t i, std::size_t) {
int val;
buf.read(val);
cout<<i<<": "<<val<<" "; }
};
Handle handle;
handle.vals.resize(grid.size(0), -1);
Dune::VariableSizeCommunicator<> comm(grid.comm(),
grid.cellScatterGatherInterface());
comm.forward(handle);

◆ cellVolume()

double Dune::CpGrid::cellVolume ( int  cell) const
inline

Get the volume of the cell.

Parameters
cellThe index identifying the cell.

◆ communicate() [1/2]

template<class DataHandle >
void Dune::CpGrid::communicate ( DataHandle &  data,
InterfaceType  iftype,
CommunicationDirection  dir,
int   
) const
inline

The new communication interface.

communicate objects for all codims on a given level

Parameters
dataThe data handle describing the data. Has to adhere to the Dune::DataHandleIF interface.
iftypeThe interface to use for the communication.
dirThe direction of the communication along the interface (forward or backward).
leveldiscarded as CpGrid is not adaptive.

◆ communicate() [2/2]

template<class DataHandle >
void Dune::CpGrid::communicate ( DataHandle &  data,
InterfaceType  iftype,
CommunicationDirection  dir 
) const
inline

The new communication interface.

communicate objects for all codims on a given level.

Template Parameters
DataHandleThe type of the data handle describing the data.
Parameters
dataThe data handle describing the data. Has to adhere to the Dune::DataHandleIF interface.
iftypeThe interface to use for the communication.
dirThe direction of the communication along the interface (forward or backward).
leveldiscarded as CpGrid is not adaptive.

◆ createCartesian()

void Dune::CpGrid::createCartesian ( const array< int, 3 > &  dims,
const array< double, 3 > &  cellsize 
)

Create a cartesian grid.

Parameters
dimsthe number of cells in each cartesian direction.
cellsizethe size of each cell in each dimension.

◆ faceArea()

double Dune::CpGrid::faceArea ( int  face) const
inline

Get the area of a face.

Parameters
cellThe index identifying the face.

◆ faceCell()

int Dune::CpGrid::faceCell ( int  face,
int  local_index 
) const
inline

Get the index identifying a cell attached to a face.

Note that a face here is always oriented. If there are two neighboring cells then the orientation will be from local_index 0 to local_index 1

Parameters
faceThe index identifying the face.
local_indexThe local_index of the cell.
Returns
The index identifying a cell or -1 if there is no such cell due the face being part of the grid boundary or the cell being stored on another process.

◆ faceCentroid()

const Vector& Dune::CpGrid::faceCentroid ( int  face) const
inline

Get the coordinates of the center of a face.

Parameters
cellThe index identifying the face.

◆ faceNormal()

const Vector& Dune::CpGrid::faceNormal ( int  face) const
inline

Get the unit normal of a face.

Parameters
cellThe index identifying the face.
See also
faceCell

◆ faceTag()

template<class Cell2FacesRowIterator >
int Dune::CpGrid::faceTag ( const Cell2FacesRowIterator &  cell_face) const
inline

Get the cartesian tag associated with a face tag.

The tag tells us in which direction the face would point in the underlying cartesian grid.

Parameters
Aniterator that points to the face and was obtained by iterating over Opm::UgGridHelpers::cell2Faces(grid).

◆ faceVertex()

int Dune::CpGrid::faceVertex ( int  face,
int  local_index 
) const
inline

Get the index identifying a vertex of a face.

Parameters
cellThe index identifying the face.
local_indexThe local_index (in [0,numFaceVertices(vertex) - 1]]) of the vertex.

◆ gatherData()

template<class DataHandle >
void Dune::CpGrid::gatherData ( DataHandle &  handle)
inline

Moves data from the distributed view to the global (all data on process) view.

Template Parameters
DataHandleThe type of the data handle describing the data and responsible for gathering and scattering the data.
Parameters
handleThe data handle describing the data and responsible for gathering and scattering the data.

◆ getIJK()

void Dune::CpGrid::getIJK ( const int  c,
std::array< int, 3 > &  ijk 
) const
inline

Extract Cartesian index triplet (i,j,k) of an active cell.

Parameters
[in]cActive cell index.
[out]ijkCartesian index triplet

◆ globalCell()

const std::vector<int>& Dune::CpGrid::globalCell ( ) const
inline

Retrieve mapping from internal ("compressed") active grid cells to external ("uncompressed") cells.

Specifically,

is the linearized Cartesian index of grid cell

i

. This method should only be used by classes which really need it, such as those dealing with permeability fields from the input deck from whence the current CpGrid was constructed.

◆ loadBalance() [1/4]

bool Dune::CpGrid::loadBalance ( int  overlapLayers = 1)
inline

Distributes this grid over the available nodes in a distributed machine.

Parameters
Thenumber of layers of cells of the overlap region (default: 1).
Warning
May only be called once.

◆ loadBalance() [2/4]

std::pair<bool, std::unordered_set<std::string> > Dune::CpGrid::loadBalance ( const OpmEclipseStateType *  ecl,
const double *  transmissibilities = nullptr,
int  overlapLayers = 1 
)
inline

Distributes this grid over the available nodes in a distributed machine.

Parameters
eclPointer to the eclipse state information. Default: null If this is not null then complete well information of of the last scheduler step of the eclipse state will be used to make sure that all the possible completion cells of each well are stored on one process. This done by adding an edge with a very high edge weight for all possible pairs of cells in the completion set of a well.
Thenumber of layers of cells of the overlap region (default: 1).
Warning
May only be called once.

◆ loadBalance() [3/4]

template<class DataHandle >
std::pair<bool, std::unordered_set<std::string> > Dune::CpGrid::loadBalance ( DataHandle &  data,
const OpmEclipseStateType *  ecl,
const double *  transmissibilities = nullptr,
int  overlapLayers = 1 
)
inline

Distributes this grid and data over the available nodes in a distributed machine.

Parameters
dataA data handle describing how to distribute attached data.
eclPointer to the eclipse state information. Default: null If this is not null then complete well information of of the last scheduler step of the eclipse state will be used to make sure that all the possible completion cells of each well are stored on one process. This done by adding an edge with a very high edge weight for all possible pairs of cells in the completion set of a well.
overlapLayersThe number of layers of overlap cells to be added (default: 1)
Template Parameters
DataHandleThe type implementing DUNE's DataHandle interface.
Warning
May only be called once.

◆ loadBalance() [4/4]

template<class DataHandle >
bool Dune::CpGrid::loadBalance ( DataHandle &  data,
int  overlapLayers = 1 
)
inline

Distributes this grid and data over the available nodes in a distributed machine.

Parameters
dataA data handle describing how to distribute attached data.
overlapLayersThe number of layers of overlap cells to be added (default: 1)
Template Parameters
DataHandleThe type implementing DUNE's DataHandle interface.
Warning
May only be called once.

◆ logicalCartesianSize()

const std::array<int, 3>& Dune::CpGrid::logicalCartesianSize ( ) const
inline

The logical cartesian size of the global grid.

This function is not part of the Dune grid interface, and should be used with caution.

◆ maxLevel()

int Dune::CpGrid::maxLevel ( ) const
inline

Return maximum level defined in this grid.

Levels are numbered 0 ... maxlevel with 0 the coarsest level.

◆ name()

std::string Dune::CpGrid::name ( ) const
inline

Get the grid name.

It's the same as the class name. What did you expect, something funny?

◆ numCellFaces() [1/2]

int Dune::CpGrid::numCellFaces ( int  cell) const
inline

Get the number of faces of a cell.

Due to faults, and collapsing vertices (along pillars) this number is quite arbitrary. Its lower bound is 4, but there is no upper bound. cell the index identifying the cell.

◆ numCellFaces() [2/2]

int Dune::CpGrid::numCellFaces ( ) const
inline

Get the sum of all faces attached to all cells.

Each face identified by a unique index is counted as often as there are neigboring cells attached to it. $ numCellFaces()=\sum_{c} numCellFaces(c) $

See also
numCellFaces(int)const

◆ processEclipseFormat()

void Dune::CpGrid::processEclipseFormat ( const grdecl input_data,
double  z_tolerance,
bool  remove_ij_boundary,
bool  turn_normals = false 
)

Read the Eclipse grid format ('grdecl').

Parameters
input_datathe data in grdecl format, declared in preprocess.h.
z_tolerancepoints along a pillar that are closer together in z coordinate than this parameter, will be replaced by a single point.
remove_ij_boundaryif true, will remove (i, j) boundaries. Used internally.

◆ readSintefLegacyFormat()

void Dune::CpGrid::readSintefLegacyFormat ( const std::string &  grid_prefix)

Read the Sintef legacy grid format ('topogeom').

Parameters
grid_prefixthe grid name, such that topology is found in <grid_prefix>-topo.dat etc.

◆ scatterData()

template<class DataHandle >
void Dune::CpGrid::scatterData ( DataHandle &  handle)
inline

Moves data from the global (all data on process) view to the distributed view.

This method does not do communication but assumes that the global grid is present on every process and simply copies data to the distributed view.

Template Parameters
DataHandleThe type of the data handle describing the data and responsible for gathering and scattering the data.
Parameters
handleThe data handle describing the data and responsible for gathering and scattering the data.

◆ setUniqueBoundaryIds()

void Dune::CpGrid::setUniqueBoundaryIds ( bool  uids)
inline

Set whether we want to have unique boundary ids.

Parameters
uidsif true, each boundary intersection will have a unique boundary id.

◆ uniqueBoundaryIds()

bool Dune::CpGrid::uniqueBoundaryIds ( ) const
inline

Is the grid currently using unique boundary ids?

Returns
true if each boundary intersection has a unique id false if we use the (default) 1-6 ids for i- i+ j- j+ k- k+ boundaries.

◆ vertexPosition()

const Vector& Dune::CpGrid::vertexPosition ( int  vertex) const
inline

Get the Position of a vertex.

Parameters
cellThe index identifying the cell.
Returns
The coordinates of the vertex.

◆ writeSintefLegacyFormat()

void Dune::CpGrid::writeSintefLegacyFormat ( const std::string &  grid_prefix) const

Write the Sintef legacy grid format ('topogeom').

Parameters
grid_prefixthe grid name, such that topology will be found in <grid_prefix>-topo.dat etc.

The documentation for this class was generated from the following files: