My Project
Loading...
Searching...
No Matches
Opm Namespace Reference

Holds the implementation of the CpGrid as a pimple. More...

Classes

class  CellQuadrature
 A class providing numerical quadrature for cells. More...
 
class  ElementChunks
 Class to simplify creating parallel yet performant threaded loops over a grid. More...
 
class  FaceQuadrature
 A class providing numerical quadrature for faces. More...
 
class  GraphOfGrid
 A class storing a graph representation of the grid. More...
 
class  GridManager
 This class manages an Opm::UnstructuredGrid in the sense that it encapsulates creation and destruction of the grid. More...
 
struct  iterator_range
 
struct  iterator_range_pod
 
class  LevelCartesianIndexMapper
 
class  LevelCartesianIndexMapper< Dune::CpGrid >
 
class  LevelCartesianIndexMapper< Dune::PolyhedralGrid< dim, dimworld, coord_t > >
 
class  LookUpCartesianData
 LookUpCartesianData - To search field properties of leaf grid view elements via CartesianIndex (cartesianMapper) More...
 
struct  LookUpCellCentroid
 LookUpCellCentroid struct - To search cell centroids via element index. More...
 
class  LookUpData
 LookUpData class - To search field properties of leaf grid view elements via element/elementIndex. More...
 
class  MinpvProcessor
 Transform a corner-point grid ZCORN field to account for MINPV processing. More...
 
struct  mutable_iterator_range
 
class  RegionMapping
 Forward and reverse mappings between cells and regions/partitions (e.g., the ECLIPSE-style 'SATNUM', 'PVTNUM', or 'EQUILNUM' arrays). More...
 
class  SparseTable
 A SparseTable stores a table with rows of varying size as efficiently as possible. More...
 
class  VelocityInterpolationConstant
 A constant velocity approximation. More...
 
class  VelocityInterpolationECVI
 Interpolate velocity using the extended CVI scheme: compute a corner velocity for each cell corner that is consistent with fluxes of adjacent faces, then interpolate with generalized barycentric coordinates. More...
 
class  VelocityInterpolationInterface
 Abstract interface for velocity interpolation method classes. More...
 
class  WachspressCoord
 Class capable of computing Wachspress coordinates in 2d and 3d. More...
 

Functions

void extractColumn (const UnstructuredGrid &grid, std::vector< std::vector< int > > &columns)
 Extract each column of the grid.
 
template<class T , class A , class C >
std::pair< std::vector< T, A >, std::vector< int > > allGatherv (const std::vector< T, A > &input, const C &comm)
 Gathers vectors from all processes on all processes.
 
template<class T , class A , class C >
std::pair< std::vector< T, A >, std::vector< int > > gatherv (const std::vector< T, A > &input, const C &comm, int root)
 Gathers vectors from all processes on a root process.
 
std::pair< std::unordered_map< int, int >, std::vector< std::array< int, 3 > > > lgrIJK (const Dune::CpGrid &grid, const std::string &lgr_name)
 Retrieves Cartesian indices for a specified Local Grid Refinement (LGR) level in a Dune::CpGrid.
 
std::pair< std::vector< double >, std::vector< double > > lgrCOORDandZCORN (const Dune::CpGrid &grid, int level, const std::unordered_map< int, int > &lgrCartesianIdxToCellIdx, const std::vector< std::array< int, 3 > > &lgrIJK)
 Extracts the COORD and ZCORN values for the LGR (Local Grid Refinement) block.
 
void setPillarCoordinates (int i, int j, int nx, int topCorner, int bottomCorner, int positionIdx, const Dune::cpgrid::Entity< 0 > &topElem, const Dune::cpgrid::Entity< 0 > &bottomElem, std::vector< double > &lgrCOORD)
 Sets the coordinates for a pillar.
 
void processPillars (int i, int j, int nx, const Dune::cpgrid::Entity< 0 > &topElem, const Dune::cpgrid::Entity< 0 > &bottomElem, std::vector< double > &lgrCOORD)
 Processes and sets the coordinates for all four pillars of a given "(i,j) column of cells".
 
void addFutureConnectionWells (GraphOfGrid< Dune::CpGrid > &gog, const std::unordered_map< std::string, std::set< int > > &wells, bool checkWellIntersections=true)
 Adds well to the GraphOfGrid.
 
void addWellConnections (GraphOfGrid< Dune::CpGrid > &gog, const Dune::cpgrid::WellConnections &wells, bool checkWellIntersections=true)
 Add WellConnections to the GraphOfGrid.
 
void extendGIDtoRank (const GraphOfGrid< Dune::CpGrid > &gog, std::vector< int > &gIDtoRank, const int &root=-1)
 Correct gIDtoRank's data about well cells.
 
std::vector< int > getWellRanks (const std::vector< int > &gIDtoRank, const Dune::cpgrid::WellConnections &wellConnections)
 Find to which ranks wells were assigned.
 
SparseTable< int > cellNeighboursAcrossVertices (const UnstructuredGrid &grid)
 For each cell, find indices of all other cells sharing a vertex with it.
 
void orderCounterClockwise (const UnstructuredGrid &grid, SparseTable< int > &nb)
 For each cell, order the (cell) neighbours counterclockwise.
 
std::unordered_map< int, int > cartesianToCompressed (const int num_cells, const int *global_cell)
 
std::vector< int > compressedToCartesian (const int num_cells, const int *global_cell)
 
template<class Range >
auto createChunkIterators (const Range &r, const std::size_t num_elem, const std::size_t num_chunks)
 Create a vector containing a spread of iterators into the elements of the range, to facilitate for example OpenMP parallelization of iterations over the elements.
 
template<class Range >
auto createThreadIterators (const Range &r, const std::size_t num_elem, const std::size_t num_threads, const std::size_t max_chunk_size, int &chunk_size)
 Create a vector containing a spread of iterators into the elements of the range, to facilitate for example OpenMP parallelization of iterations over the elements.
 
template<class GridView >
auto createThreadIterators (const GridView &gv, const std::size_t num_threads, const std::size_t max_chunk_size, int &chunk_size)
 Convenience function for using createThreadIterators() with the cells in a grid view.
 

Detailed Description

Holds the implementation of the CpGrid as a pimple.

Author
Markus Blatt marku.nosp@m.s@dr.nosp@m.-blat.nosp@m.t.de Atgeirr F Rasmussen atgei.nosp@m.rr@s.nosp@m.intef.nosp@m..no Bård Skaflestad bard..nosp@m.skaf.nosp@m.lesta.nosp@m.d@si.nosp@m.ntef..nosp@m.no

Function Documentation

◆ addFutureConnectionWells()

void Opm::addFutureConnectionWells ( GraphOfGrid< Dune::CpGrid > &  gog,
const std::unordered_map< std::string, std::set< int > > &  wells,
bool  checkWellIntersections = true 
)

Adds well to the GraphOfGrid.

Translates wells' cartesian ID to global ID used in the graph. Adding the well contracts vertices of the well into one vertex.

checkWellIntersections==true makes the algorithm check if wells intersect and if their cell IDs are present in the graph. Setting it to false makes the algorithm faster but leaves user responsible for keeping wells disjoint.

◆ addWellConnections()

void Opm::addWellConnections ( GraphOfGrid< Dune::CpGrid > &  gog,
const Dune::cpgrid::WellConnections wells,
bool  checkWellIntersections = true 
)

Add WellConnections to the GraphOfGrid.

checkWellIntersections==true makes the algorithm check if wells intersect and if their cell IDs are present in the graph. Setting it to false makes the algorithm faster but leaves user responsible for keeping wells disjoint.

◆ allGatherv()

template<class T , class A , class C >
std::pair< std::vector< T, A >, std::vector< int > > Opm::allGatherv ( const std::vector< T, A > &  input,
const C &  comm 
)

Gathers vectors from all processes on all processes.

In parallel this will call MPI_Allgatherv. Has to be called on all ranks.

Parameters
inputThe input vector to gather from the rank.
commThe Dune::Communication object.
Returns
A pair of a vector with all the values gathered (first the ones from rank 0, then the ones from rank 1, ...) and a vector with the offsets of the first value from each rank (values[offset[rank]] will be the first value from rank). This vector is one bigger than the number of processes and the last entry is the size of the first array.

◆ cellNeighboursAcrossVertices()

SparseTable< int > Opm::cellNeighboursAcrossVertices ( const UnstructuredGrid grid)

For each cell, find indices of all other cells sharing a vertex with it.

For each cell, find indices of all cells sharing a vertex with it.

Parameters
[in]gridA grid object.
Returns
A table of neighbour cell-indices by cell.

◆ createChunkIterators()

template<class Range >
auto Opm::createChunkIterators ( const Range &  r,
const std::size_t  num_elem,
const std::size_t  num_chunks 
)

Create a vector containing a spread of iterators into the elements of the range, to facilitate for example OpenMP parallelization of iterations over the elements.

While the original range may have only forward iterators to the individual elements, the returned vector will provide random access to the chunks.

Template Parameters
RangeRange of elements that supports (multipass) forward iteration.
Parameters
[in]rRange to be iterated over.
[in]num_elemThe number of elements in r.
[in]num_chunksThe number of chunks to create.
Returns
A vector of iterators, with the range's begin and end iterators being the first and last ones, and filling in iterators in between such that the distance from one to the next is num_elem/num_chunks, except for possibly the last interval(s). The size of the vector will be num_chunks + 1.

◆ createThreadIterators()

template<class Range >
auto Opm::createThreadIterators ( const Range &  r,
const std::size_t  num_elem,
const std::size_t  num_threads,
const std::size_t  max_chunk_size,
int &  chunk_size 
)

Create a vector containing a spread of iterators into the elements of the range, to facilitate for example OpenMP parallelization of iterations over the elements.

While the original range may have only forward iterators to the individual elements, the returned vector will provide random access to the chunks.

Template Parameters
RangeRange of elements that supports (multipass) forward iteration.
Parameters
[in]rRange to be iterated over.
[in]num_elemThe number of elements in r.
[in]num_threadsThe number of threads to target.
[in]max_chunk_sizeThe maximum allowed chunk size.
[out]chunk_sizeThe chunk size found by the algorithm.
Returns
A vector of iterators, with the range's begin and end iterators being the first and last ones, and filling in iterators in between such that the distance from one to the next is chunk_size, except for possibly the last interval. If num_threads is 1, there will only be the begin and end iterators and no chunks in between.

◆ extendGIDtoRank()

void Opm::extendGIDtoRank ( const GraphOfGrid< Dune::CpGrid > &  gog,
std::vector< int > &  gIDtoRank,
const int &  root = -1 
)

Correct gIDtoRank's data about well cells.

gIDtoRank's entries come from Zoltan partitioner's export list that does not contain all well cells. Default value is root's rank. parameter root allows skipping wells that are correct.

◆ extractColumn()

void Opm::extractColumn ( const UnstructuredGrid grid,
std::vector< std::vector< int > > &  columns 
)

Extract each column of the grid.

Note
Assumes the pillars of the grid are all vertically aligned.
Parameters
gridThe grid from which to extract the columns.
columnswill for each (i, j) where (i, j) represents a non-empty column, contain the cell indices contained in the column centered at (i, j) in the second variable, and i+jN in the first variable.

◆ gatherv()

template<class T , class A , class C >
std::pair< std::vector< T, A >, std::vector< int > > Opm::gatherv ( const std::vector< T, A > &  input,
const C &  comm,
int  root 
)

Gathers vectors from all processes on a root process.

In parallel this will call MPI_Gatherv. Has to be called on all ranks.

Parameters
inputThe input vector to gather from the rank.
commThe Dune::Communication object.
rootThe rank of the processes to gather the values-
Returns
On non-root ranks a pair of empty vectors. On the root rank a pair of a vector with all the values gathered (first the ones from rank 0, then the ones from rank 1, ...) and a vector with the offsets of the first value from each rank (values[offset[rank]] will be the first value from rank). This vector is one bigger than the number of processes and the last entry is the size of the first array.

◆ getWellRanks()

std::vector< int > Opm::getWellRanks ( const std::vector< int > &  gIDtoRank,
const Dune::cpgrid::WellConnections wellConnections 
)

Find to which ranks wells were assigned.

returns the vector of ranks, ordering is given by wellConnections

Parameters
gIDtoRankTakes global ID and returns rank
wellConnectionsHas global IDs of well cells

◆ lgrCOORDandZCORN()

std::pair< std::vector< double >, std::vector< double > > Opm::lgrCOORDandZCORN ( const Dune::CpGrid grid,
int  level,
const std::unordered_map< int, int > &  lgrCartesianIdxToCellIdx,
const std::vector< std::array< int, 3 > > &  lgrIJK 
)

Extracts the COORD and ZCORN values for the LGR (Local Grid Refinement) block.

COORD: This retrieves a vector of std::array<double, 6>, where each element represents the coordinate values of a pillar in the LGR block. The values correspond to the COORD keyword, which defines the corner-point geometry of the grid. ZCORN: It is initialized to inactive values, i.e. set to std::numeric_limits<double>::max(), and then calculates the bottom and top ZCORN values for each cell in the LGR based on its geometry. It determines the active cell layers and assigns ZCORN values accordingly.

Special Cases:

  • If a pillar within the LGR block is "inactive", its COORD values are set to std::numeric_limits<double>::max() to indicate the inactive status.
  • If all pillars are "inactive", an exception is thrown.
Parameters
[in]grid
[in]levelThe refinement level of the LGR block.
[in]lgrCartesianIdxToCellIdxMapping from LGR Cartesian indices to level cell indices.
[in]lgrIJKThe IJK indices corresponding to the LGR block active cells.
Returns
A pair containing:
  • A std::vector<double> storing the coordinate values for each pillar.
  • A std::vector<double> storing the depth of each corner point of the LGR pillars.

◆ lgrIJK()

std::pair< std::unordered_map< int, int >, std::vector< std::array< int, 3 > > > Opm::lgrIJK ( const Dune::CpGrid grid,
const std::string &  lgr_name 
)

Retrieves Cartesian indices for a specified Local Grid Refinement (LGR) level in a Dune::CpGrid.

This function extracts the mapping between active cell indices and Cartesian indices for a given LGR name. If the specified name is not found, an exception is thrown.

Parameters
[in]gridThe Dune::CpGrid
[in]lgr_nameThe name of the LGR whose indices are to be retrieved.
Returns
A pair containing:
  • A std::unordered_map<int, int> mapping Cartesian indices back to cell indices (handles inactive parent cells).
  • A std::vector<std::array<int, 3>> storing the (i, j, k) Cartesian coordinates for active cells.

◆ orderCounterClockwise()

void Opm::orderCounterClockwise ( const UnstructuredGrid grid,
SparseTable< int > &  nb 
)

For each cell, order the (cell) neighbours counterclockwise.

Parameters
[in]gridA 2d grid object.
[in,out]nbA cell-cell neighbourhood table, such as from cellNeighboursAcrossVertices().
[in]gridA 2d grid object.
[in,out]nbA cell-cell neighbourhood table, such as from vertexNeighbours().

◆ processPillars()

void Opm::processPillars ( int  i,
int  j,
int  nx,
const Dune::cpgrid::Entity< 0 > &  topElem,
const Dune::cpgrid::Entity< 0 > &  bottomElem,
std::vector< double > &  lgrCOORD 
)

Processes and sets the coordinates for all four pillars of a given "(i,j) column of cells".

This function calls setPillarCoordinates for each of the four pillars (i,j), (i+1,j), (i,j+1), and (i+1,j+1), assigning the correct top and bottom coordinates from the given elements.

Parameters
[in]iColumn index of the current element.
[in]jRow index of the current element.
[in]nxNumber of elements in the x-direction.
[in]topElemReference to the top element.
[in]bottomElemReference to the bottom element.
[out]lgrCOORDReference to the array storing the pillar coordinates.

◆ setPillarCoordinates()

void Opm::setPillarCoordinates ( int  i,
int  j,
int  nx,
int  topCorner,
int  bottomCorner,
int  positionIdx,
const Dune::cpgrid::Entity< 0 > &  topElem,
const Dune::cpgrid::Entity< 0 > &  bottomElem,
std::vector< double > &  lgrCOORD 
)

Sets the coordinates for a pillar.

This function calculates the pillar index based on the given (i, j) position and assigns the top and bottom coordinates from the corresponding element corners.

Parameters
[in]iColumn index of the pillar.
[in]jRow index of the pillar.
[in]nxNumber of elements in the x-direction.
[in]topCornerIndex of the top element corner associated with the pillar.
[in]bottomCornerIndex of the bottom element corner associated with the pillar.
[in]positionIdxTo determine the correct pillar index (0-3).
[in]topElemReference to the top element.
[in]bottomElemReference to the bottom element.
[out]lgrCOORDReference to the array storing the pillar coordinates.