opm-grid
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  LevelCartesianIndexMapper
class  LevelCartesianIndexMapper< Dune::CpGrid >
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  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  LookUpCartesianData
 LookUpCartesianData - To search field properties of leaf grid view elements via CartesianIndex (cartesianMapper). More...
class  MinpvProcessor
 Transform a corner-point grid ZCORN field to account for MINPV processing. More...
class  LevelCartesianIndexMapper< Dune::PolyhedralGrid< dim, dimworld, coord_t > >
class  ElementChunks
 Class to simplify creating parallel yet performant threaded loops over a grid. More...
struct  iterator_range_pod
struct  iterator_range
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...
struct  PoisonIterator
class  SparseTable
 A SparseTable stores a table with rows of varying size as efficiently as possible. More...
class  VelocityInterpolationInterface
 Abstract interface for velocity interpolation method classes. 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  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".
bool isNameInTheList (const std::vector< std::string > &lgr_parent_grid_names, const std::string &grid_name)
 Check whether a grid name exists in a list of parent grid names.
std::vector< int > getLgrDataIndicesByParentGrid (const std::vector< std::string > &lgr_parent_grid_names, const std::string &parent_grid_name)
 Group LGRs by their parent grid, identified through indices.
std::tuple< std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::string > > filterLgrDataPerParentGridName (const std::vector< std::array< int, 3 > > &cells_per_dim_vec, const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec, const std::vector< std::string > &lgr_name_vec, const std::vector< std::string > &lgr_parent_grid_name_vec, const std::string &parent_grid_name)
 Retrieve LGR data associated with a specific parent grid.
bool areParentGridsAvailableBeforeTheirLgrs (const std::map< std::string, int > &existing_grid_names, const std::vector< std::string > &new_lgr_names, const std::vector< std::string > &new_lgrs_parent_grid_names)
 Check whether each parent grid exists before its child LGRs.
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.

Variables

template<class>
constexpr bool always_false_v = false

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.

◆ areParentGridsAvailableBeforeTheirLgrs()

bool Opm::areParentGridsAvailableBeforeTheirLgrs ( const std::map< std::string, int > & existing_grid_names,
const std::vector< std::string > & new_lgr_names,
const std::vector< std::string > & new_lgrs_parent_grid_names )

Check whether each parent grid exists before its child LGRs.

Ensures that a parent grid is either already present in the set of existing grids or appears earlier in the list of new LGRs, before its children.

Parameters
[in]existing_grid_namesMap of existing grid names.
[in]new_lgr_namesNames of new LGRs to be created.
[in]new_lgrs_parent_grid_namesCorresponding parent grid names for each LGR.
Returns
true if all parent grids exist before their child LGRs, false otherwise.

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

◆ filterLgrDataPerParentGridName()

std::tuple< std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::string > > Opm::filterLgrDataPerParentGridName ( const std::vector< std::array< int, 3 > > & cells_per_dim_vec,
const std::vector< std::array< int, 3 > > & startIJK_vec,
const std::vector< std::array< int, 3 > > & endIJK_vec,
const std::vector< std::string > & lgr_name_vec,
const std::vector< std::string > & lgr_parent_grid_name_vec,
const std::string & parent_grid_name )

Retrieve LGR data associated with a specific parent grid.

Filters LGR information (cell refinements, block bounds, and LGR names) based on the given parent grid name.

Parameters
[in]cells_per_dim_vecVector of triplets specifying the number of refined cells in each dimension for each patch.
[in]startIJK_vecVector of triplets specifying the starting Cartesian indices of each patch.
[in]endIJK_vecVector of triplets specifying the ending Cartesian indices of each patch.
[in]lgr_name_vecVector of LGR/level names.
[in]lgr_parent_grid_name_vecVector of parent grid names corresponding to each LGR.
[in]parent_grid_nameParent grid name to filter by.
Returns
A tuple containing:
  • Vector of cell refinement triplets (cells per dimension),
  • Vector of starting index triplets,
  • Vector of ending index triplets,
  • Vector of LGR names, all restricted to the specified parent grid.

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

◆ getLgrDataIndicesByParentGrid()

std::vector< int > Opm::getLgrDataIndicesByParentGrid ( const std::vector< std::string > & lgr_parent_grid_names,
const std::string & parent_grid_name )

Group LGRs by their parent grid, identified through indices.

Parameters
[in]lgr_parent_grid_namesList of parent grid names (std::string) used for refinement.
[in]parent_grid_nameParent grid name to match.
Returns
A vector of indices corresponding to LGRs associated with the given parent grid. These indices can be used to access LGR data and trigger refinement.

◆ 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

◆ isNameInTheList()

bool Opm::isNameInTheList ( const std::vector< std::string > & lgr_parent_grid_names,
const std::string & grid_name )

Check whether a grid name exists in a list of parent grid names.

Parameters
[in]lgr_parent_grid_namesList of parent grid names (std::string) used for refinement.
[in]grid_nameGrid name to search for.
Returns
true if grid_name is found in lgr_parent_grid_names, false otherwise.

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