opm-grid
Loading...
Searching...
No Matches
Dune::cpgrid::CpGridData Class Reference

Struct that hods all the data needed to represent a Cpgrid. More...

#include <CpGridData.hpp>

Public Types

enum  { MAX_DATA_PER_CELL = 2 }
using MPICommunicator = CpGridDataTraits::MPICommunicator
 The type of the mpi communicator.
using Communication = CpGridDataTraits::Communication
 The type of the collective communication.
using CollectiveCommunication = CpGridDataTraits::CollectiveCommunication
using AttributeSet = CpGridDataTraits::AttributeSet
 The type of the set of the attributes.

Public Member Functions

 CpGridData (MPIHelper::MPICommunicator comm, std::vector< std::shared_ptr< CpGridData > > &data)
 Constructor for parallel grid data.
 CpGridData (std::vector< std::shared_ptr< CpGridData > > &data)
 Constructor.
 ~CpGridData ()
 Destructor.
int size (int codim) const
 number of leaf entities per codim in this process
int size (GeometryType type) const
 number of leaf entities per geometry type in this process
void readEclipseFormat (const std::string &filename, bool periodic_extension, bool turn_normals=false, bool edge_conformal=false)
 Read the Eclipse grid format ('grdecl').
void processEclipseFormat (const grdecl &input_data, std::array< std::set< std::pair< int, int > >, 2 > &nnc, bool remove_ij_boundary, bool turn_normals, bool pinchActive, double tolerance_unique_points, bool edge_conformal)
 Read the Eclipse grid format ('grdecl').
void getIJK (int c, std::array< int, 3 > &ijk) const
 Extract Cartesian index triplet (i,j,k) of an active cell.
int cellFace (int cell, int local_index) const
auto cellToFace (int cellIdx) const
const auto & cellToPoint () const
const auto & cellToPoint (int cellIdx) const
int faceToCellSize (int face) const
auto faceTag (int faceIdx) const
auto faceNormals (int faceIdx) const
auto faceToPoint (int faceIdx) const
int numFaces () const
auto cornerHistorySize () const
const auto & getCornerHistory (int cornerIdx) const
const std::vector< int > & globalCell () const
 Return global_cell_ of any level grid, or the leaf grid view (in presence of refinement).
bool hasNNCs (const std::vector< int > &cellIndices) const
 Check all cells selected for refinement have no NNCs (no neighbor connections).
bool mark (int refCount, const cpgrid::Entity< 0 > &element)
 Mark entity for refinement or coarsening.
int getMark (const cpgrid::Entity< 0 > &element) const
 Return refinement mark for entity.
bool preAdapt ()
 Set mightVanish flags for elements that will be refined in the next adapt() call Need to be called after elements have been marked for refinement.
bool adapt ()
 TO DO: Documentation. Triggers the grid refinement process - Currently, returns preAdapt().
void postAdapt ()
 Clean up refinement/coarsening markers - set every element to the mark 0 which represents 'doing nothing'.
int getGridIdx () const
 Add doc/or remove method and replace it with better approach.
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > & levelData () const
 Add doc/or remove method and replace it with better approach.
const std::tuple< int, std::vector< int > > & getChildrenLevelAndIndexList (int elemIdx) const
 Retrieves the level and child indices of a given parent cell.
const std::vector< std::tuple< int, std::vector< int > > > & getParentToChildren () const
const cpgrid::DefaultGeometryPolicy getGeometry () const
int getLeafIdxFromLevelIdx (int level_cell_idx) const
std::tuple< const std::shared_ptr< CpGridData >, const std::vector< std::array< int, 2 > >, const std::vector< std::tuple< int, std::vector< int > > >, const std::tuple< int, std::vector< int > >, const std::vector< std::array< int, 2 > >, const std::vector< std::array< int, 2 > > > refineSingleCell (const std::array< int, 3 > &cells_per_dim, const int &parent_idx) const
 Refine a single cell and return a shared pointer of CpGridData type.
std::array< double, 3 > computeEclCentroid (const int idx) const
std::array< double, 3 > computeEclCentroid (const Entity< 0 > &elem) const
void computeUniqueBoundaryIds ()
bool uniqueBoundaryIds () const
 Is the grid currently using unique boundary ids?
void setUniqueBoundaryIds (bool uids)
 Set whether we want to have unique boundary ids.
const std::vector< double > & zcornData () const
 Return the internalized zcorn copy from the grid processing, if no cells were adjusted during the minpvprocessing this can be and empty vector.
const IndexSet & indexSet () const
 Get the index set.
const cpgrid::IdSetlocalIdSet () const
 Get the local index set.
const cpgrid::LevelGlobalIdSetglobalIdSet () const
 Get the global index set.
const std::array< int, 3 > & logicalCartesianSize () const
 The logical cartesian size of the grid.
void distributeGlobalGrid (CpGrid &grid, const CpGridData &view_data, const std::vector< int > &cell_part)
 Redistribute a global grid.
template<class DataHandle>
void communicate (DataHandle &data, InterfaceType iftype, CommunicationDirection dir)
 communicate objects for all codims on a given level
void computeCellPartitionType ()
void computePointPartitionType ()
void computeCommunicationInterfaces (int noexistingPoints)
const std::vector< int > & sortedNumAquiferCells () const
 Get sorted active cell indices of numerical aquifer.

Friends

template<class T, int i>
struct mover::Mover
class GlobalIdSet
class HierarchicIterator
class Dune::cpgrid::IndexSet
class Dune::cpgrid::IdSet
class Dune::cpgrid::LevelGlobalIdSet
class Dune::CpGrid
template<int>
class Entity
template<int>
class EntityRep
class Intersection
class PartitionTypeIndicator
friend void::refine_and_check (const Dune::cpgrid::Geometry< 3, 3 > &, const std::array< int, 3 > &, bool)

Detailed Description

Struct that hods all the data needed to represent a Cpgrid.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_DATA_PER_CELL 

The maximum data items allowed per cell (DUNE < 2.5.2).

Due to a bug in DUNE < 2.5.2 we need to limit this when communicating. 1 is big enough for OPM as we always use one block for all unknowns, but some DUNE's grid checks actually need 2. So 2 it is.

Constructor & Destructor Documentation

◆ CpGridData()

Dune::cpgrid::CpGridData::CpGridData ( MPIHelper::MPICommunicator comm,
std::vector< std::shared_ptr< CpGridData > > & data )
explicit

Constructor for parallel grid data.

Parameters
commThe MPI communicator
dataPointer to existing data to use Default constructor.

Member Function Documentation

◆ communicate()

template<class DataHandle>
void Dune::cpgrid::CpGridData::communicate ( DataHandle & data,
InterfaceType iftype,
CommunicationDirection dir )

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).

◆ distributeGlobalGrid()

void Dune::cpgrid::CpGridData::distributeGlobalGrid ( CpGrid & grid,
const CpGridData & view_data,
const std::vector< int > & cell_part )

Redistribute a global grid.

The whole grid must be available on all processors.

◆ getChildrenLevelAndIndexList()

const std::tuple< int, std::vector< int > > & Dune::cpgrid::CpGridData::getChildrenLevelAndIndexList ( int elemIdx) const
inline

Retrieves the level and child indices of a given parent cell.

Parameters
elemIdxThe index of the parent cell.
Returns
A tuple of (- could be a pair -)
  • An integer representing the refinement level (LGR) of the parent cell.
  • A vector of integers representing the indices of the child cells.
  • If the parent cell has no children, the entry is {-1, {}}.

◆ getIJK()

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

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

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

◆ getMark()

int Dune::cpgrid::CpGridData::getMark ( const cpgrid::Entity< 0 > & element) const

Return refinement mark for entity.

Returns
refinement mark (1 refinement, 0 doing nothing, -1 coarsening - not supported yet).

◆ globalCell()

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

Return global_cell_ of any level grid, or the leaf grid view (in presence of refinement).

global_cell_ has size number of cells present on a process and maps to the underlying Cartesian Grid.

Note: CpGrid::globalCell() returns current_view_data_-> global_cell_ (current_view_data_ points at data_.back() or distributed_data_.back(), in general. If the grid has been refined, current_view_data_ points at the "leaf grid view").

◆ hasNNCs()

bool Dune::cpgrid::CpGridData::hasNNCs ( const std::vector< int > & cellIndices) const

Check all cells selected for refinement have no NNCs (no neighbor connections).

Assumption: all grid cells are active.

◆ indexSet()

const IndexSet & Dune::cpgrid::CpGridData::indexSet ( ) const
inline

Get the index set.

This is the lead as well as th level index set.

Returns
The index set.

◆ logicalCartesianSize()

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

The logical cartesian size of the grid.

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

◆ mark()

bool Dune::cpgrid::CpGridData::mark ( int refCount,
const cpgrid::Entity< 0 > & element )

Mark entity for refinement or coarsening.

Refinement on CpGrid is partially supported for Cartesian grids, with the keyword CARFIN. This only works for entities of codim 0.

Parameters
[in]refCountTo mark the element for
  • refinement, refCount == 1
  • doing nothing, refCount == 0
  • coarsening, refCount == -1 (not applicable yet)
[in]elementEntity<0>. Currently, an element from the GLOBAL grid (level zero).
Returns
true, if marking was succesfull. false, if marking was not possible.

◆ preAdapt()

bool Dune::cpgrid::CpGridData::preAdapt ( )

Set mightVanish flags for elements that will be refined in the next adapt() call Need to be called after elements have been marked for refinement.

Communicate marks accross processes, in parallel runs. An element may be marked somewhere in opm-simulators because it does not fulfill a certain property, regardless of whether it belongs to the interior or overlap partition.

Returns
True if at least one element has been marked for refinement, false otherwise.

◆ processEclipseFormat()

void Dune::cpgrid::CpGridData::processEclipseFormat ( const grdecl & input_data,
std::array< std::set< std::pair< int, int > >, 2 > & nnc,
bool remove_ij_boundary,
bool turn_normals,
bool pinchActive,
double tolerance_unique_points,
bool edge_conformal )

Read the Eclipse grid format ('grdecl').

Read the Eclipse grid format ('.grdecl').

Parameters
[in]input_dataCorner-point grid input data.
[in,out]ecl_stateHigh level object from opm-common that provides information regarding pore volumes, NNCs and aquifers. NNC and aquifer connection information will also be updated during the function call when necessary if ecl_state is non-null.
[in,out]nncNon-neighboring connections.
[in]remove_ij_boundaryTrue to remove outer cell layer
[in]turn_normalsWhether or not to turn all normals. This is intended for handling inputs with wrong orientations.
[in]pinchActiveWhether or not to force specific pinch behaviour. If set, a face will connect two vertical cells, that are topological connected, even if there are cells with zero volume between them. If false these cells will not be connected despite their faces coinciding.
[in]tolerance_unique_pointsTolerance used to identify points based on their cooridinate.
[in]edge_conformalWhether or not to construct an edge-conformal grid. Typically useful in geo-mechanical applications.

◆ readEclipseFormat()

void Dune::cpgrid::CpGridData::readEclipseFormat ( const std::string & filename,
bool periodic_extension,
bool turn_normals = false,
bool edge_conformal = false )

Read the Eclipse grid format ('grdecl').

Parameters
[in]filenamethe name of the file to read.
[in]periodic_extensionWhether or not to process the resulting grid in order to have intersections/faces along i and j boundaries match those on the other side. That is, i- faces will match i+ faces etc.
[in]turn_normalsWhether or not to turn all normals. This is intended for handling inputs with wrong orientations.
[in]edge_conformalWhether or not to construct an edge-conformal grid. Typically useful in geo-mechanical applications.

◆ refineSingleCell()

std::tuple< const std::shared_ptr< CpGridData >, const std::vector< std::array< int, 2 > >, const std::vector< std::tuple< int, std::vector< int > > >, const std::tuple< int, std::vector< int > >, const std::vector< std::array< int, 2 > >, const std::vector< std::array< int, 2 > > > Dune::cpgrid::CpGridData::refineSingleCell ( const std::array< int, 3 > & cells_per_dim,
const int & parent_idx ) const

Refine a single cell and return a shared pointer of CpGridData type.

refineSingleCell() takes a cell and refines it in a chosen amount of cells (per direction); creating the geometries, topological relations, etc. Stored in a CpGridData object. Additionally, containers for parent-to-new-born entities are buil, as well as, new-born-to-parent. Maps(<int,bool>) to detect parent faces or cells are also provided. (Cell with 6 faces required).

Parameters
[in]cells_per_dimNumber of (refined) cells in each direction that each parent cell should be refined to.
[in]parent_idxParent cell index, cell to be refined.
Returns
refined_grid_ptr Shared pointer pointing at refined_grid.
parent_to_refined_corners For each corner of the parent cell, we store the index of the refined corner that coincides with the old one. We assume they are ordered 0,1,..7 6—7 2—3 | | TOP FACE | | 4—5 0—1 BOTTOM FACE
parent_to_children_faces/cell For each parent face/cell, we store its child-face/cell indices. {parent face/cell index in coarse level, {indices of its children in refined level}}
child_to_parent_faces/cells {child index, parent index}

◆ setUniqueBoundaryIds()

void Dune::cpgrid::CpGridData::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::CpGridData::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.

The documentation for this class was generated from the following files:
  • opm/grid/cpgrid/CpGridData.hpp
  • opm/grid/cpgrid/CpGridData.cpp
  • opm/grid/cpgrid/processEclipseFormat.cpp