Opm::Lgr Namespace Reference

Functions

void refineAndProvideMarkedRefinedRelations (const Dune::CpGrid &grid, std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, int &markedElem_count, std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, std::map< std::array< int, 2 >, int > &markedElemAndEquivRefinedCorn_to_corner, std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrCell_to_refinedLevelAdRefinedCell, std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell, std::vector< int > &refined_cell_count_vec, const std::vector< int > &assignRefinedLevel, std::vector< std::vector< std::tuple< int, std::vector< int > > > > &preAdapt_parent_to_children_cells_vec, std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCell_to_adaptedCell, std::unordered_map< int, std::array< int, 2 > > &adaptedCell_to_elemLgrAndElemLgrCell, int &cell_count, std::vector< std::vector< int > > &preAdapt_level_to_leaf_cells_vec, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 ------------— Auxiliary methods to support refinement ------------— More...
 
std::tuple< std::vector< std::vector< std::array< int, 2 > > >, std::vector< std::vector< int > >, std::vector< std::array< int, 2 > >, std::vector< int > > defineChildToParentAndIdxInParentCell (const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, const std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell, const std::vector< int > &refined_cell_count_vec, const std::unordered_map< int, std::array< int, 2 > > &adaptedCell_to_elemLgrAndElemLgrCell, const int &cell_count)
 Establish child–parent relations for refined cells: More...
 
std::pair< std::vector< std::vector< int > >, std::vector< std::array< int, 2 > > > defineLevelToLeafAndLeafToLevelCells (const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, const std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrCell_to_refinedLevelAndRefinedCell, const std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell, const std::vector< int > &refined_cell_count_vec, const std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCell_to_adaptedCell, const std::unordered_map< int, std::array< int, 2 > > &adaptedCell_to_elemLgrAndElemLgrCell, const int &cell_count)
 Define index mappings between refined level grids and the leaf (adapted) grid: More...
 
void identifyRefinedCornersPerLevel (const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner, std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedCorner_to_elemLgrAndElemLgrCorner, std::vector< int > &refined_corner_count_vec, std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Define refined corner relations: More...
 
bool isRefinedCornerInInteriorLgr (const std::array< int, 3 > &cells_per_dim, int cornerIdxInLgr)
 Check if a refined corner lies in the interior of a single-cell refinement. More...
 
std::array< int, 3 > getRefinedCornerIJK (const std::array< int, 3 > &cells_per_dim, int cornerIdxInLgr)
 Compute the {i,j,k} index of a refined corner from its linear index in a single-cell refinement. More...
 
bool newRefinedCornerLiesOnEdge (const std::array< int, 3 > &cells_per_dim, int cornerIdxInLgr)
 Check if a refined corner lies on a parent-cell edge. Specifically, on the boundary of the single-cell refinement, but not coinciding with a pre-adapt corner. More...
 
std::array< int, 2 > getParentFacesAssocWithNewRefinedCornLyingOnEdge (const Dune::cpgrid::CpGridData &current_data, const std::array< int, 3 > &cells_per_dim, int cornerIdxInLgr, int elemLgr)
 Get the parent faces that contain the edge on which a new refined corner lies. More...
 
bool isRefinedNewBornCornerOnLgrBoundary (const std::array< int, 3 > &cells_per_dim, int cornerIdxInLgr)
 Check if a refined corner lies on the boundary of the single-cell refinement and is not a pre-adapt (original) corner. More...
 
int getParentFaceWhereNewRefinedCornerLiesOn (const Dune::cpgrid::CpGridData &current_data, const std::array< int, 3 > &cells_per_dim, int cornerIdxInLgr, int elemLgr)
 
int replaceLgr1CornerIdxByLgr2CornerIdx (const std::array< int, 3 > &cells_per_dim_lgr1, int cornerIdxLgr1, const std::array< int, 3 > &cells_per_dim_lgr2)
 Map a refined corner from one single-cell refinement to a neighboring refinement. More...
 
int replaceLgr1CornerIdxByLgr2CornerIdx (const Dune::cpgrid::CpGridData &current_data, const std::array< int, 3 > &cells_per_dim_lgr1, int cornerIdxLgr1, int elemLgr1, int parentFaceLastAppearanceIdx, const std::array< int, 3 > &cells_per_dim_lgr2)
 Map a new refined corner on an edge from one single-cell refinement to a neighboring refinement. More...
 
void identifyLeafGridCorners (const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCorner_to_adaptedCorner, std::unordered_map< int, std::array< int, 2 > > &adaptedCorner_to_elemLgrAndElemLgrCorner, int &corner_count, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Identify corners on the leaf (adapted) grid and establish corner mappings. More...
 
void markVanishedCorner (const std::array< int, 2 > &vanished, const std::array< int, 2 > &lastAppearance, std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance)
 
void processInteriorCorners (int elemIdx, int shiftedLevel, const std::shared_ptr< Dune::cpgrid::CpGridData > &lgr, int &corner_count, std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCorner_to_adaptedCorner, std::unordered_map< int, std::array< int, 2 > > &adaptedCorner_to_elemLgrAndElemLgrCorner, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 
void processEdgeCorners (int elemIdx, int shiftedLevel, const std::shared_ptr< Dune::cpgrid::CpGridData > &lgr, int &corner_count, std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCorner_to_adaptedCorner, std::unordered_map< int, std::array< int, 2 > > &adaptedCorner_to_elemLgrAndElemLgrCorner, std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, const std::vector< int > &assignRefinedLevel, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 
void processBoundaryCorners (int elemIdx, int shiftedLevel, const std::shared_ptr< Dune::cpgrid::CpGridData > &lgr, int &corner_count, std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCorner_to_adaptedCorner, std::unordered_map< int, std::array< int, 2 > > &adaptedCorner_to_elemLgrAndElemLgrCorner, std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, const std::vector< int > &assignRefinedLevel, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 
void insertBidirectional (std::map< std::array< int, 2 >, std::array< int, 2 > > &a_to_b, std::map< std::array< int, 2 >, std::array< int, 2 > > &b_to_a, const std::array< int, 2 > &keyA, const std::array< int, 2 > &keyB, int &counter, bool useFullKeyB=false)
 
void identifyRefinedFacesPerLevel (const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrFace_to_refinedLevelAndRefinedFace, std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedFace_to_elemLgrAndElemLgrFace, std::vector< int > &refined_face_count_vec, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Define mappings between single-cell-refinement faces and refined level faces. More...
 
void identifyLeafGridFaces (const Dune::cpgrid::CpGridData &current_data, int preAdaptMaxLevel, std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrFace_to_adaptedFace, std::unordered_map< int, std::array< int, 2 > > &adaptedFace_to_elemLgrAndElemLgrFace, int &face_count, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Identify faces on the leaf (adapted) grid and establish face mappings. More...
 
std::array< int, 3 > getRefinedFaceIJK (const std::array< int, 3 > &cells_per_dim, int faceIdxInLgr, const std::shared_ptr< Dune::cpgrid::CpGridData > &elemLgr_ptr)
 Compute the {i,j,k} index of a refined face from its linear index in a single-cell refinement. More...
 
bool isRefinedFaceInInteriorLgr (const std::array< int, 3 > &cells_per_dim, int faceIdxInLgr, const std::shared_ptr< Dune::cpgrid::CpGridData > &elemLgr_ptr)
 Check if a refined face lies in the interior of a single-cell refinement. More...
 
bool isRefinedFaceOnLgrBoundary (const std::array< int, 3 > &cells_per_dim, int faceIdxInLgr, const std::shared_ptr< Dune::cpgrid::CpGridData > &elemLgr_ptr)
 Check if a refined face lies on the boundary of a single-cell refinement. More...
 
int getParentFaceWhereNewRefinedFaceLiesOn (const Dune::cpgrid::CpGridData &current_data, const std::array< int, 3 > &cells_per_dim, int faceIdxInLgr, const std::shared_ptr< Dune::cpgrid::CpGridData > &elemLgr_ptr, int elemLgr)
 Get the parent face containing a new refined face. More...
 
void populateRefinedCorners (std::vector< Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 0, 3 > > > &refined_corners_vec, const std::vector< int > &refined_corner_count_vec, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const int &preAdaptMaxLevel, const std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedCorner_to_elemLgrAndElemLgrCorner)
 Define the corners (geometry) for each refined level grid. More...
 
void populateRefinedFaces (std::vector< Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 2, 3 > > > &refined_faces_vec, std::vector< Dune::cpgrid::EntityVariableBase< enum face_tag > > &mutable_refined_face_tags_vec, std::vector< Dune::cpgrid::EntityVariableBase< Dune::FieldVector< double, 3 > > > &mutable_refine_face_normals_vec, std::vector< Opm::SparseTable< int > > &refined_face_to_point_vec, const std::vector< int > &refined_face_count_vec, const std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedFace_to_elemLgrAndElemLgrFace, const std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner, const std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const int &preAdaptMaxLevel, const std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, const std::map< std::array< int, 2 >, int > &markedElemAndEquivRefinedCorn_to_corner)
 Define the faces, face tags, face normarls, and face_to_point_, for each refined level grid. More...
 
void populateRefinedCells (const Dune::cpgrid::CpGridData &current_data, std::vector< Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 3, 3 > > > &refined_cells_vec, std::vector< std::vector< std::array< int, 8 > > > &refined_cell_to_point_vec, std::vector< std::vector< int > > &refined_global_cell_vec, const std::vector< int > &refined_cell_count_vec, std::vector< Dune::cpgrid::OrientedEntityTable< 0, 1 > > &refined_cell_to_face_vec, std::vector< Dune::cpgrid::OrientedEntityTable< 1, 0 > > &refined_face_to_cell_vec, const std::map< std::array< int, 2 >, std::array< int, 2 > > &refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell, const std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrFace_to_refinedLevelAndRefinedFace, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const std::vector< Dune::cpgrid::DefaultGeometryPolicy > &refined_geometries_vec, const std::map< std::array< int, 2 >, std::array< int, 2 > > &elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner, const std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const int &preAdaptMaxLevel, const std::map< std::array< int, 2 >, int > &markedElemAndEquivRefinedCorn_to_corner, const std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Define the cells, cell_to_point_, global_cell_, cell_to_face_, face_to_cell_, for each refined level grid. More...
 
int replaceLgr1FaceIdxByLgr2FaceIdx (const std::array< int, 3 > &cells_per_dim_lgr1, int faceIdxInLgr1, const std::shared_ptr< Dune::cpgrid::CpGridData > &elemLgr1_ptr, const std::array< int, 3 > &cells_per_dim_lgr2)
 Map a refined boundary face from one single-cell refinement to a neighboring refinement. More...
 
void populateLeafGridCorners (const Dune::cpgrid::CpGridData &current_data, Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 0, 3 > > &adapted_corners, const int &corners_count, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::unordered_map< int, std::array< int, 2 > > &adaptedCorner_to_elemLgrAndElemLgrCorner)
 Define the corners (gemotry) for the leaf grid view (or adapted grid). More...
 
void populateLeafGridFaces (const Dune::cpgrid::CpGridData &current_data, Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 2, 3 > > &adapted_faces, Dune::cpgrid::EntityVariableBase< enum face_tag > &mutable_face_tags, Dune::cpgrid::EntityVariableBase< Dune::FieldVector< double, 3 > > &mutable_face_normals, Opm::SparseTable< int > &adapted_face_to_point, const int &face_count, const std::unordered_map< int, std::array< int, 2 > > &adaptedFace_to_elemLgrAndElemLgrFace, const std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCorner_to_adaptedCorner, const std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const std::map< std::array< int, 2 >, int > &markedElemAndEquivRefinedCorn_to_corner, const std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, const std::vector< std::array< int, 3 > > &cells_per_dim_vec, const int &preAdaptMaxLevel)
 Define the faces, face tags, face normarls, and face_to_point_, for the leaf grid view. More...
 
void populateLeafGridCells (const Dune::cpgrid::CpGridData &current_data, Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 3, 3 > > &adapted_cells, std::vector< std::array< int, 8 > > &adapted_cell_to_point, const int &cell_count, Dune::cpgrid::OrientedEntityTable< 0, 1 > &adapted_cell_to_face, Dune::cpgrid::OrientedEntityTable< 1, 0 > &adapted_face_to_cell, const std::unordered_map< int, std::array< int, 2 > > &adaptedCell_to_elemLgrAndElemLgrCell, const std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrFace_to_adaptedFace, const std::vector< std::vector< std::pair< int, std::vector< int > > > > &faceInMarkedElemAndRefinedFaces, const Dune::cpgrid::DefaultGeometryPolicy &adapted_geometries, const std::map< std::array< int, 2 >, int > &elemLgrAndElemLgrCorner_to_adaptedCorner, const std::map< std::array< int, 2 >, std::array< int, 2 > > &vanishedRefinedCorner_to_itsLastAppearance, const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &markedElem_to_itsLgr, const std::vector< int > &assignRefinedLevel, const std::map< std::array< int, 2 >, int > &markedElemAndEquivRefinedCorn_to_corner, const std::vector< std::vector< std::array< int, 2 > > > &cornerInMarkedElemWithEquivRefinedCorner, const std::vector< std::array< int, 3 > > &cells_per_dim_vec, const int &preAdaptMaxLevel)
 Define the cells, cell_to_point_, cell_to_face_, face_to_cell_, for the leaf grid view (or adapted grid). More...
 
template<class T >
void computeOnLgrParents (const Dune::CpGrid &grid, const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec, T func)
 Auxilliary function to compute one or more properties on selected block of parent cells. More...
 
void detectActiveLgrs (const Dune::CpGrid &grid, const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec, std::vector< int > &lgr_with_at_least_one_active_cell)
 Detect active local refinement grids (LGRs) on each process. More...
 
void predictMinCellAndPointGlobalIdPerProcess (const Dune::CpGrid &grid, const std::vector< int > &assignRefinedLevel, const std::vector< std::array< int, 3 > > &cells_per_dim_vec, const std::vector< int > &lgr_with_at_least_one_active_cell, int &min_globalId_cell_in_proc, int &min_globalId_point_in_proc)
 Predict minimum cell and point global ids per process. More...
 
void assignCellIdsAndCandidatePointIds (const Dune::CpGrid &grid, std::vector< std::vector< int > > &localToGlobal_cells_per_level, std::vector< std::vector< int > > &localToGlobal_points_per_level, int min_globalId_cell_in_proc, int min_globalId_point_in_proc, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Assign cell global ids of new born cell from refined level grids. Assign 'candidate' point global ids for points in refined level grids. More...
 
void selectWinnerPointIds (const Dune::CpGrid &grid, std::vector< std::vector< int > > &localToGlobal_points_per_level, const std::vector< std::tuple< int, std::vector< int > > > &parent_to_children, const std::vector< std::array< int, 3 > > &cells_per_dim_vec)
 Select and re-write point global ids. More...
 
void getFirstChildGlobalIds (const Dune::CpGrid &grid, std::vector< int > &parentToFirstChildGlobalIds)
 Retrieves the global ids of the first child for each parent cell in the grid. More...
 
std::array< int, 3 > getIJK (int idx_in_parent_cell, const std::array< int, 3 > &cells_per_dim)
 Extract Cartesian index triplet (i,j,k) given an index between 0 and NXxNYxNZ -1 where NX, NY, and NZ is the total amoung of cells in each direction x-,y-,and z- respectively. More...
 
void validStartEndIJKs (const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec)
 Check startIJK and endIJK of each patch of cells to be refined are valid, i.e. startIJK and endIJK vectors have the same size and, startIJK < endIJK coordenate by coordenate. More...
 
std::array< std::vector< int >, 6 > getBoundaryPatchFaces (const std::array< int, 3 > &startIJK, const std::array< int, 3 > &endIJK, const std::array< int, 3 > &grid_dim)
 Compute patch boundary face indices (Cartesian grid required). More...
 
std::array< int, 3 > getPatchDim (const std::array< int, 3 > &startIJK, const std::array< int, 3 > &endIJK)
 Compute amount of cells in each direction of a patch of cells. (Cartesian grid required). More...
 
bool patchesShareFace (const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec, const std::array< int, 3 > &grid_dim)
 Determine if a finite amount of patches (of cells) share a face. More...
 
int sharedFaceTag (const std::vector< std::array< int, 3 > > &startIJK_2Patches, const std::vector< std::array< int, 3 > > &endIJK_2Patches, const std::array< int, 3 > &grid_dim)
 
std::tuple< bool, std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::string > > filterUndesiredNumberOfSubdivisions (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)
 Filter out LGR entries that do not result in any actual refinement. More...
 
void containsEightDifferentCorners (const std::array< int, 8 > &cell_to_point)
 

Function Documentation

◆ assignCellIdsAndCandidatePointIds()

void Opm::Lgr::assignCellIdsAndCandidatePointIds ( const Dune::CpGrid grid,
std::vector< std::vector< int > > &  localToGlobal_cells_per_level,
std::vector< std::vector< int > > &  localToGlobal_points_per_level,
int  min_globalId_cell_in_proc,
int  min_globalId_point_in_proc,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Assign cell global ids of new born cell from refined level grids. Assign 'candidate' point global ids for points in refined level grids.

Parameters
[out]localToGlobal_cells_per_levelRelation local element.index() to assigned cell global id.
[out]localToGlobal_points_per_levelRelation local point.index() to assigned 'candidate' global id.
[in]min_globalId_cell_in_procMinimum cell global id per process.
[in]min_globalId_point_in_procMinimum point global id per process.
[in]cells_per_dim_vecTotal child cells in each direction (x-,y-, and z-direction) per block of cells.

◆ computeOnLgrParents()

template<class T >
void Opm::Lgr::computeOnLgrParents ( const Dune::CpGrid grid,
const std::vector< std::array< int, 3 > > &  startIJK_vec,
const std::vector< std::array< int, 3 > > &  endIJK_vec,
func 
)

Auxilliary function to compute one or more properties on selected block of parent cells.

Parameters
[in]startIJK_vecVector of ijk values denoting the start of each block of cells selected for refinement.
[in]endIJK_vecVector of ijk values denoting the end of each block of cells selected for refinement.
[in]functionLambda expression/function that computes the desired properties for each parent cell. The full definition needs to be in the header so that the compiler can instantiate it when needed.

References Dune::CpGrid::getIJK().

◆ containsEightDifferentCorners()

void Opm::Lgr::containsEightDifferentCorners ( const std::array< int, 8 > &  cell_to_point)

◆ defineChildToParentAndIdxInParentCell()

std::tuple< std::vector< std::vector< std::array< int, 2 > > >, std::vector< std::vector< int > >, std::vector< std::array< int, 2 > >, std::vector< int > > Opm::Lgr::defineChildToParentAndIdxInParentCell ( const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell,
const std::vector< int > &  refined_cell_count_vec,
const std::unordered_map< int, std::array< int, 2 > > &  adaptedCell_to_elemLgrAndElemLgrCell,
const int &  cell_count 
)

Establish child–parent relations for refined cells:

  • Maps each refined cell (in new refined grids) to its parent cell in the pre-adapt grid(s).
  • Assigns each child cell an index within its parent (-1 if no parent).
Parameters
[in]refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCellMaps (refined level grid, refined cell idx)->(marked element idx, marked-element-refined cell idx).
[in]refined_cell_count_vecNumber of refined cells per refined level grid.
[in]adaptedCell_to_elemLgrAndElemLgrCellMaps adapted cell idx -> (marked element idx, marked-element-refined cell idx).
[in]cell_countTotal number of cells in the adapted (leaf) grid.
Returns
  • refined_child_to_parent_cells_vec : For each refined level grid, maps child cell->{parent level, parent index}, or {−1,−1} if none.
  • refined_cell_to_idxInParentCell_vec: For each refined level grid, child cell’s index within parent (for geometryInFather), -1 if none.
  • adapted_child_to_parent_cell : Maps adapted child cell idx->{parent level, parent index}, or {−1,−1} if none.
  • adapted_cell_to_idxInParentCell : Index of adapted child cell within parent, -1 if none.

◆ defineLevelToLeafAndLeafToLevelCells()

std::pair< std::vector< std::vector< int > >, std::vector< std::array< int, 2 > > > Opm::Lgr::defineLevelToLeafAndLeafToLevelCells ( const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrCell_to_refinedLevelAndRefinedCell,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell,
const std::vector< int > &  refined_cell_count_vec,
const std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCell_to_adaptedCell,
const std::unordered_map< int, std::array< int, 2 > > &  adaptedCell_to_elemLgrAndElemLgrCell,
const int &  cell_count 
)

Define index mappings between refined level grids and the leaf (adapted) grid:

  • level_to_leaf_cells: maps each cell idx in a refined level grid to its leaf cell idx
  • leaf_to_level_cells: maps each leaf cell idx back to its originating level cell idx
Parameters
[in]elemLgrAndElemLgrCell_to_refinedLevelAndRefinedCellMaps (marked element idx, marked-element-refined cell idx) -> (refined level grid, refined cell idx).
[in]refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCellInverse mapping: (refined level grid, refined cell) -> (marked element idx, marked-element-refined cell idx).
[in]refined_cell_count_vecNumber of refined cells per level.
[in]elemLgrAndElemLgrCell_to_adaptedCellMaps (marked element idx, marked-element-refined cell idx) -> leaf (adapted) cell idx.
[in]adaptedCell_to_elemLgrAndElemLgrCellInverse mapping: leaf (adapted) cell -> (marked element idx, marked-element-refined cell idx).
[in]cell_countTotal number of cells in the leaf (adapted) grid.
Returns
  • refined_level_to_leaf_cells_vec : For each refined level grid, maps cell idx -> leaf cell idx
  • leaf_to_level_cells : For each leaf cell, {level grid idx, cell idx in that level}

◆ detectActiveLgrs()

void Opm::Lgr::detectActiveLgrs ( const Dune::CpGrid grid,
const std::vector< std::array< int, 3 > > &  startIJK_vec,
const std::vector< std::array< int, 3 > > &  endIJK_vec,
std::vector< int > &  lgr_with_at_least_one_active_cell 
)

Detect active local refinement grids (LGRs) on each process.

For blocks of cells selected for refinement on a level-zero distributed grid, this function marks which LGRs contain at least one active cell on the current process.

Parameters
[in]startIJK_vecStart indices {i,j,k} of each refinement block.
[in]endIJK_vecEnd indices {i,j,k} of each refinement block.
[out]lgr_with_at_least_one_active_cellFor each level, set to 1 if the LGR contains at least one active cell, 0 otherwise.

◆ filterUndesiredNumberOfSubdivisions()

std::tuple< bool, std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::array< int, 3 > >, std::vector< std::string > > Opm::Lgr::filterUndesiredNumberOfSubdivisions ( 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 
)

Filter out LGR entries that do not result in any actual refinement.

This function removes entries where the number of subdivisions in each direction is 0 (i.e., cells_per_dim is equal to {1, 1, 1}) which would result in no grid refinement.

A warning is logged for each excluded LGR name.

Parameters
[in]startIJK_vecVector of Cartesian triplet indices where each patch starts.
[in]endIJK_vecVector of Cartesian triplet indices where each patch ends.
[in]lgr_name_vecNames (std::string) for the LGRs/levels.
Returns
A tuple containing a bool and the filtered vectors:
  • allUndesired True if all LGRs have cells_per_dim_ = {1,1,1}
  • cells_per_dim_vec
  • startIJK_vec
  • endIJK_vec
  • lgr_name_vec

◆ getBoundaryPatchFaces()

std::array< std::vector< int >, 6 > Opm::Lgr::getBoundaryPatchFaces ( const std::array< int, 3 > &  startIJK,
const std::array< int, 3 > &  endIJK,
const std::array< int, 3 > &  grid_dim 
)

Compute patch boundary face indices (Cartesian grid required).

Parameters
[in]startIJKCartesian triplet index where the patch starts.
[in]endIJKCartesian triplet index where the patch ends. Last cell part of the lgr will be {endijk[0]-1, ... endIJK[2]-1}.
Returns
patch_boundary_faces

◆ getFirstChildGlobalIds()

void Opm::Lgr::getFirstChildGlobalIds ( const Dune::CpGrid grid,
std::vector< int > &  parentToFirstChildGlobalIds 
)

Retrieves the global ids of the first child for each parent cell in the grid.

If a cell has no children, its entry is set to -1, indicating an invalid id.

Parameters
[out]parentToFirstChildGlobalIdsA vector that will be filled with the first child global IDs. The vector is resized to match the number of parent cells.

◆ getIJK()

std::array< int, 3 > Opm::Lgr::getIJK ( int  idx_in_parent_cell,
const std::array< int, 3 > &  cells_per_dim 
)

Extract Cartesian index triplet (i,j,k) given an index between 0 and NXxNYxNZ -1 where NX, NY, and NZ is the total amoung of cells in each direction x-,y-,and z- respectively.

Parameters
[in]idxInteger between 0 and cells_per_dim[0]*cells_per_dim[1]*cells_per_dim[2]-1
[in]cells_per_dim
Returns
Cartesian index triplet.

◆ getParentFacesAssocWithNewRefinedCornLyingOnEdge()

std::array< int, 2 > Opm::Lgr::getParentFacesAssocWithNewRefinedCornLyingOnEdge ( const Dune::cpgrid::CpGridData current_data,
const std::array< int, 3 > &  cells_per_dim,
int  cornerIdxInLgr,
int  elemLgr 
)

Get the parent faces that contain the edge on which a new refined corner lies.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]cornerIdxInLgrCorner index in the single-cell refinement.
[in]elemLgrParent cell index (from the original grid) refined into a single-cell refinement.
Returns
Indices of the two parent faces sharing the edge.

◆ getParentFaceWhereNewRefinedCornerLiesOn()

int Opm::Lgr::getParentFaceWhereNewRefinedCornerLiesOn ( const Dune::cpgrid::CpGridData current_data,
const std::array< int, 3 > &  cells_per_dim,
int  cornerIdxInLgr,
int  elemLgr 
)
Parameters
[in]cells_per_dimNumber of child cells in {x, y, z} directions.
[in]cornerIdxInLgrCorner index in the single-cell refinement.
[in]elemLgrParent cell index (from the original grid) refined into a single-cell refinement.
Returns
Index of the parent face containing the corner.

◆ getParentFaceWhereNewRefinedFaceLiesOn()

int Opm::Lgr::getParentFaceWhereNewRefinedFaceLiesOn ( const Dune::cpgrid::CpGridData current_data,
const std::array< int, 3 > &  cells_per_dim,
int  faceIdxInLgr,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  elemLgr_ptr,
int  elemLgr 
)

Get the parent face containing a new refined face.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]faceIdxInLgrFace index in the single-cell refinement.
[in]elemLgr_ptrPointer to the single-cell refinement grid.
[in]elemLgrParent cell index from the original grid.
Returns
Index of the parent face containing the refined face.

◆ getPatchDim()

std::array< int, 3 > Opm::Lgr::getPatchDim ( const std::array< int, 3 > &  startIJK,
const std::array< int, 3 > &  endIJK 
)

Compute amount of cells in each direction of a patch of cells. (Cartesian grid required).

Parameters
[in]startIJKCartesian triplet index where the patch starts.
[in]endIJKCartesian triplet index where the patch ends. Last patch cell Cartesian triplet is {endijk[0]-1, ... endIJK[2]-1}.
Returns
patch_dim Patch dimension {#cells in x-direction, #cells in y-direction, #cells in z-direction}.

◆ getRefinedCornerIJK()

std::array< int, 3 > Opm::Lgr::getRefinedCornerIJK ( const std::array< int, 3 > &  cells_per_dim,
int  cornerIdxInLgr 
)

Compute the {i,j,k} index of a refined corner from its linear index in a single-cell refinement.

A cell refined into {nx, ny, nz} children has (nx+1)(ny+1)(nz+1) corners. Corners are ordered as: idx = j*(nx+1)(nz+1) + i*(nz+1) + k, with i in [0,nx], j in [0,ny], k in [0,nz]. This function converts cornerIdxInLgr (0..(nx+1)(ny+1)(nz+1)-1) to {i,j,k}.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]cornerIdxInLgrCorner index in the single-cell refinement.
Returns
{i,j,k} index of the corner.

◆ getRefinedFaceIJK()

std::array< int, 3 > Opm::Lgr::getRefinedFaceIJK ( const std::array< int, 3 > &  cells_per_dim,
int  faceIdxInLgr,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  elemLgr_ptr 
)

Compute the {i,j,k} index of a refined face from its linear index in a single-cell refinement.

A single cell refined into {nx, ny, nz} children has ((nx+1)*ny*nz) + (nx*(ny+1)*nz) + (nx*ny*(nz+1)) faces, stored in the order defined by Geometry::refine:

  • K_FACES: (k*nx*ny) + (j*nx) + i
  • I_FACES: (nx*ny*(nz+1)) + (i*ny*nz) + (k*ny) + j
  • J_FACES: (nx*ny*(nz+1)) + ((nx+1)*ny*nz) + (j*nx*nz) + (i*nz) + k
    where i=0..nx-1, j=0..ny-1, k=0..nz-1.
    This function converts faceIdxInLgr to its {i,j,k} index.
Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]faceIdxInLgrFace index in the single-cell refinement.
[in]elemLgr_ptrPointer to the single-cell refinement grid.
Returns
{i,j,k} index of the face

◆ identifyLeafGridCorners()

void Opm::Lgr::identifyLeafGridCorners ( const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCorner_to_adaptedCorner,
std::unordered_map< int, std::array< int, 2 > > &  adaptedCorner_to_elemLgrAndElemLgrCorner,
int &  corner_count,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Identify corners on the leaf (adapted) grid and establish corner mappings.

Maps pre-adapt and refined corners from single-element refinements to the leaf grid, and vice versa.

Parameters
[out]elemLgrAndElemLgrCorner_to_adaptedCorner
Maps (marked element idx, marked-element-refined corner idx) or {-1, corner in original grid} -> leaf grid corner idx.
[out]adaptedCorner_to_elemLgrAndElemLgrCorner
Inverse mapping: leaf grid corner idx -> (marked element idx, marked-element-refined corner idx) or {-1, original corner idx}.
[out]corner_countTotal number of corners in the leaf (adapted) grid.
[in]markedElem_to_itsLgr
[in]assignRefinedLevel
[in]cornerInMarkedElemWithEquivRefinedCorner
[in]vanishedRefinedCorner_to_itsLastAppearance
[in]faceInMarkedElemAndRefinedFaces
[in]cells_per_dim_vec

◆ identifyLeafGridFaces()

void Opm::Lgr::identifyLeafGridFaces ( const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrFace_to_adaptedFace,
std::unordered_map< int, std::array< int, 2 > > &  adaptedFace_to_elemLgrAndElemLgrFace,
int &  face_count,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Identify faces on the leaf (adapted) grid and establish face mappings.

Maps pre-adapt and refined faces from single-element refinements to the leaf grid, and provides the inverse mapping.

Parameters
[out]elemLgrAndElemLgrFace_to_adaptedFaceMaps (marked element idx, marked-element-refined face idx) or {-1, face idx in original grid} -> leaf grid face index.
[out]adaptedFace_to_elemLgrAndElemLgrFaceInverse mapping: leaf grid face -> (marked element idx, marked-element-refined face idx) or {-1, original face idx}.
[out]face_countTotal number of faces in the leaf (adapted) grid.
[in]markedElem_to_itsLgr
[in]assignRefinedLevel
[in]faceInMarkedElemAndRefinedFaces
[in]cells_per_dim_vec

◆ identifyRefinedCornersPerLevel()

void Opm::Lgr::identifyRefinedCornersPerLevel ( const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedCorner_to_elemLgrAndElemLgrCorner,
std::vector< int > &  refined_corner_count_vec,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Define refined corner relations:

  1. Map corners from single marked-element refinements to their refined level grids (and inverse).
  2. Handle corners that appear in multiple single-cell refinements but are stored only once (last appearance kept, earlier ones mapped to it).
Parameters
[out]elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCornerMaps (marked element idx, marked-element-refined corner idx) -> (refined level grid, refined corner idx).
[out]refinedLevelAndRefinedCorner_to_elemLgrAndElemLgrCornerInverse mapping: (refined level grid, refined corner idx) -> (marked element idx, marked-element-refined corner idx).
[out]refined_corner_count_vecNumber of refined corners per refined level grid.
[out]vanishedRefinedCorner_to_itsLastAppearanceFor corners present in multiple refinements: map each earlier occurrence -> its last appearance.
[in]markedElem_to_itsLgr
[in]assignRefinedLevel
[in]cornerInMarkedElemWithEquivRefinedCorner
[in]faceInMarkedElemAndRefinedFaces
[in]cells_per_dim_vec

◆ identifyRefinedFacesPerLevel()

void Opm::Lgr::identifyRefinedFacesPerLevel ( const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrFace_to_refinedLevelAndRefinedFace,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedFace_to_elemLgrAndElemLgrFace,
std::vector< int > &  refined_face_count_vec,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Define mappings between single-cell-refinement faces and refined level faces.

Maps faces from each marked element’s single-cell refinement to its assigned refined level grid, and provides the inverse mapping.

Parameters
[out]elemLgrAndElemLgrFace_to_refinedLevelAndRefinedFace
Maps (marked element idx, marked-element-refined face idx)->(refined level grid, refined face idx).
[out]refinedLevelAndRefinedFace_to_elemLgrAndElemLgrFace
Inverse mapping: (refined level grid, refined face idx)->(marked element idx, marked-element-refined face idx).
[out]refined_face_count_vecNumber of refined faces per refined level grid.
[in]markedElem_to_itsLgr
[in]assignRefinedLevel
[in]faceInMarkedElemAndRefinedFaces
[in]cells_per_dim_vec

◆ insertBidirectional()

void Opm::Lgr::insertBidirectional ( std::map< std::array< int, 2 >, std::array< int, 2 > > &  a_to_b,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  b_to_a,
const std::array< int, 2 > &  keyA,
const std::array< int, 2 > &  keyB,
int &  counter,
bool  useFullKeyB = false 
)

◆ isRefinedCornerInInteriorLgr()

bool Opm::Lgr::isRefinedCornerInInteriorLgr ( const std::array< int, 3 > &  cells_per_dim,
int  cornerIdxInLgr 
)

Check if a refined corner lies in the interior of a single-cell refinement.

Parameters
[in]cells_per_dimNumber of child cells in {x, y, z} directions.
[in]cornerIdxInLgrCorner index within the single-cell refinement.
Returns
true if the corner is interior, false otherwise.

◆ isRefinedFaceInInteriorLgr()

bool Opm::Lgr::isRefinedFaceInInteriorLgr ( const std::array< int, 3 > &  cells_per_dim,
int  faceIdxInLgr,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  elemLgr_ptr 
)

Check if a refined face lies in the interior of a single-cell refinement.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]faceIdxInLgrFace index in the single-cell refinement.
[in]elemLgr_ptrPointer to the single-cell refinement grid.
Returns
true if the face is interior, false otherwise.

◆ isRefinedFaceOnLgrBoundary()

bool Opm::Lgr::isRefinedFaceOnLgrBoundary ( const std::array< int, 3 > &  cells_per_dim,
int  faceIdxInLgr,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  elemLgr_ptr 
)

Check if a refined face lies on the boundary of a single-cell refinement.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]faceIdxInLgrFace index in the single-cell refinement.
[in]elemLgr_ptrPointer to the single-cell refinement grid.
Returns
true if the face is on the boundary, false otherwise.

◆ isRefinedNewBornCornerOnLgrBoundary()

bool Opm::Lgr::isRefinedNewBornCornerOnLgrBoundary ( const std::array< int, 3 > &  cells_per_dim,
int  cornerIdxInLgr 
)

Check if a refined corner lies on the boundary of the single-cell refinement and is not a pre-adapt (original) corner.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]cornerIdxInLgrCorner index in the single-cell refinement.
Returns
true if the corner is on the boundary and new, false otherwise.

◆ markVanishedCorner()

void Opm::Lgr::markVanishedCorner ( const std::array< int, 2 > &  vanished,
const std::array< int, 2 > &  lastAppearance,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance 
)

◆ newRefinedCornerLiesOnEdge()

bool Opm::Lgr::newRefinedCornerLiesOnEdge ( const std::array< int, 3 > &  cells_per_dim,
int  cornerIdxInLgr 
)

Check if a refined corner lies on a parent-cell edge. Specifically, on the boundary of the single-cell refinement, but not coinciding with a pre-adapt corner.

Parameters
[in]cells_per_dimNumber of child cells in {x,y,z} directions.
[in]cornerIdxInLgrCorner index in the single-cell refinement.
Returns
true if the corner is on an edge, false otherwise.

◆ patchesShareFace()

bool Opm::Lgr::patchesShareFace ( const std::vector< std::array< int, 3 > > &  startIJK_vec,
const std::vector< std::array< int, 3 > > &  endIJK_vec,
const std::array< int, 3 > &  grid_dim 
)

Determine if a finite amount of patches (of cells) share a face.

Parameters
[in]startIJK_vecVector of Cartesian triplet indices where each patch starts.
[in]endIJK_vecVector of Cartesian triplet indices where each patch ends. Last patch Cartesian triplet is {endIJK_vec[<patch>][0]-1, ... ,endIJK_vec[<patch>][2]-1}.

◆ populateLeafGridCells()

void Opm::Lgr::populateLeafGridCells ( const Dune::cpgrid::CpGridData current_data,
Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 3, 3 > > &  adapted_cells,
std::vector< std::array< int, 8 > > &  adapted_cell_to_point,
const int &  cell_count,
Dune::cpgrid::OrientedEntityTable< 0, 1 > &  adapted_cell_to_face,
Dune::cpgrid::OrientedEntityTable< 1, 0 > &  adapted_face_to_cell,
const std::unordered_map< int, std::array< int, 2 > > &  adaptedCell_to_elemLgrAndElemLgrCell,
const std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrFace_to_adaptedFace,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const Dune::cpgrid::DefaultGeometryPolicy adapted_geometries,
const std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCorner_to_adaptedCorner,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const std::map< std::array< int, 2 >, int > &  markedElemAndEquivRefinedCorn_to_corner,
const std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec,
const int &  preAdaptMaxLevel 
)

Define the cells, cell_to_point_, cell_to_face_, face_to_cell_, for the leaf grid view (or adapted grid).

◆ populateLeafGridCorners()

void Opm::Lgr::populateLeafGridCorners ( const Dune::cpgrid::CpGridData current_data,
Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 0, 3 > > &  adapted_corners,
const int &  corners_count,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::unordered_map< int, std::array< int, 2 > > &  adaptedCorner_to_elemLgrAndElemLgrCorner 
)

Define the corners (gemotry) for the leaf grid view (or adapted grid).

◆ populateLeafGridFaces()

void Opm::Lgr::populateLeafGridFaces ( const Dune::cpgrid::CpGridData current_data,
Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 2, 3 > > &  adapted_faces,
Dune::cpgrid::EntityVariableBase< enum face_tag > &  mutable_face_tags,
Dune::cpgrid::EntityVariableBase< Dune::FieldVector< double, 3 > > &  mutable_face_normals,
Opm::SparseTable< int > &  adapted_face_to_point,
const int &  face_count,
const std::unordered_map< int, std::array< int, 2 > > &  adaptedFace_to_elemLgrAndElemLgrFace,
const std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCorner_to_adaptedCorner,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const std::map< std::array< int, 2 >, int > &  markedElemAndEquivRefinedCorn_to_corner,
const std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec,
const int &  preAdaptMaxLevel 
)

Define the faces, face tags, face normarls, and face_to_point_, for the leaf grid view.

◆ populateRefinedCells()

void Opm::Lgr::populateRefinedCells ( const Dune::cpgrid::CpGridData current_data,
std::vector< Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 3, 3 > > > &  refined_cells_vec,
std::vector< std::vector< std::array< int, 8 > > > &  refined_cell_to_point_vec,
std::vector< std::vector< int > > &  refined_global_cell_vec,
const std::vector< int > &  refined_cell_count_vec,
std::vector< Dune::cpgrid::OrientedEntityTable< 0, 1 > > &  refined_cell_to_face_vec,
std::vector< Dune::cpgrid::OrientedEntityTable< 1, 0 > > &  refined_face_to_cell_vec,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrFace_to_refinedLevelAndRefinedFace,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< Dune::cpgrid::DefaultGeometryPolicy > &  refined_geometries_vec,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const std::vector< int > &  assignRefinedLevel,
const int &  preAdaptMaxLevel,
const std::map< std::array< int, 2 >, int > &  markedElemAndEquivRefinedCorn_to_corner,
const std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Define the cells, cell_to_point_, global_cell_, cell_to_face_, face_to_cell_, for each refined level grid.

◆ populateRefinedCorners()

void Opm::Lgr::populateRefinedCorners ( std::vector< Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 0, 3 > > > &  refined_corners_vec,
const std::vector< int > &  refined_corner_count_vec,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const int &  preAdaptMaxLevel,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedCorner_to_elemLgrAndElemLgrCorner 
)

Define the corners (geometry) for each refined level grid.

◆ populateRefinedFaces()

void Opm::Lgr::populateRefinedFaces ( std::vector< Dune::cpgrid::EntityVariableBase< Dune::cpgrid::Geometry< 2, 3 > > > &  refined_faces_vec,
std::vector< Dune::cpgrid::EntityVariableBase< enum face_tag > > &  mutable_refined_face_tags_vec,
std::vector< Dune::cpgrid::EntityVariableBase< Dune::FieldVector< double, 3 > > > &  mutable_refine_face_normals_vec,
std::vector< Opm::SparseTable< int > > &  refined_face_to_point_vec,
const std::vector< int > &  refined_face_count_vec,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedFace_to_elemLgrAndElemLgrFace,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner,
const std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
const int &  preAdaptMaxLevel,
const std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
const std::map< std::array< int, 2 >, int > &  markedElemAndEquivRefinedCorn_to_corner 
)

Define the faces, face tags, face normarls, and face_to_point_, for each refined level grid.

◆ predictMinCellAndPointGlobalIdPerProcess()

void Opm::Lgr::predictMinCellAndPointGlobalIdPerProcess ( const Dune::CpGrid grid,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec,
const std::vector< int > &  lgr_with_at_least_one_active_cell,
int &  min_globalId_cell_in_proc,
int &  min_globalId_point_in_proc 
)

Predict minimum cell and point global ids per process.

Predict how many new cells/points (born in refined level grids) need new globalIds, so we can assign unique new ids ( and anticipate the maximum). At this point, the grid is already refined according to the LGR specification.

Parameters
[in]assignRefinedLevelAssign level for the refinement of each marked cell. Example: refined element from LGR1 have level 1, refined element rfom LGR2 have level 2, etc.
[in]cells_per_dim_vecTotal child cells in each direction (x-,y-, and z-direction) per block of cells.
[in]lgr_with_at_least_one_active_cellDetermine if an LGR is not empty in a given process: lgr_with_at_least_one_active_cell[level] = 1 if it contains at least one active cell in the current process, and 0 otherwise.
[out]min_globalId_cell_in_proc
[out]min_globalId_point_in_proc

◆ processBoundaryCorners()

void Opm::Lgr::processBoundaryCorners ( int  elemIdx,
int  shiftedLevel,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  lgr,
int &  corner_count,
std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCorner_to_adaptedCorner,
std::unordered_map< int, std::array< int, 2 > > &  adaptedCorner_to_elemLgrAndElemLgrCorner,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

◆ processEdgeCorners()

void Opm::Lgr::processEdgeCorners ( int  elemIdx,
int  shiftedLevel,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  lgr,
int &  corner_count,
std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCorner_to_adaptedCorner,
std::unordered_map< int, std::array< int, 2 > > &  adaptedCorner_to_elemLgrAndElemLgrCorner,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  vanishedRefinedCorner_to_itsLastAppearance,
const Dune::cpgrid::CpGridData current_data,
int  preAdaptMaxLevel,
const std::vector< int > &  assignRefinedLevel,
const std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

◆ processInteriorCorners()

void Opm::Lgr::processInteriorCorners ( int  elemIdx,
int  shiftedLevel,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  lgr,
int &  corner_count,
std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCorner_to_adaptedCorner,
std::unordered_map< int, std::array< int, 2 > > &  adaptedCorner_to_elemLgrAndElemLgrCorner,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

◆ refineAndProvideMarkedRefinedRelations()

void Opm::Lgr::refineAndProvideMarkedRefinedRelations ( const Dune::CpGrid grid,
std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > &  markedElem_to_itsLgr,
int &  markedElem_count,
std::vector< std::vector< std::array< int, 2 > > > &  cornerInMarkedElemWithEquivRefinedCorner,
std::map< std::array< int, 2 >, int > &  markedElemAndEquivRefinedCorn_to_corner,
std::vector< std::vector< std::pair< int, std::vector< int > > > > &  faceInMarkedElemAndRefinedFaces,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  elemLgrAndElemLgrCell_to_refinedLevelAdRefinedCell,
std::map< std::array< int, 2 >, std::array< int, 2 > > &  refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCell,
std::vector< int > &  refined_cell_count_vec,
const std::vector< int > &  assignRefinedLevel,
std::vector< std::vector< std::tuple< int, std::vector< int > > > > &  preAdapt_parent_to_children_cells_vec,
std::map< std::array< int, 2 >, int > &  elemLgrAndElemLgrCell_to_adaptedCell,
std::unordered_map< int, std::array< int, 2 > > &  adaptedCell_to_elemLgrAndElemLgrCell,
int &  cell_count,
std::vector< std::vector< int > > &  preAdapt_level_to_leaf_cells_vec,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

------------— Auxiliary methods to support refinement ------------—

Refines all marked elements and establishes mappings between original (corners, faces, cells) and their refined/adapted counterparts.

— Marked element data —

Parameters
[out]markedElem_to_itsLgrAuxiliary LGR for each marked element, later used to build refined level grids.
[out]markedElem_countTotal number of marked elements (used in grid info).
[out]cornerInMarkedElemWithEquivRefinedCornerMaps each corner (from starting grid) to the marked elements it belongs to and its equivalent refined corner indices.
[out]markedElemAndEquivRefinedCorn_to_cornerReverse mapping: (marked element idx, marked-element-refined corner idx) -> original corner idx.
[out]faceInMarkedElemAndRefinedFacesFor each original face, stores marked element indices where it appears (<=2) and their refined face indices.

— Refined cell data —

Parameters
[out]elemLgrAndElemLgrCell_to_refinedLevelAdRefinedCellMaps (marked element idx, marked-element-refined cell idx) -> (refined level grid, refined level cell idx).
[out]refinedLevelAndRefinedCell_to_elemLgrAndElemLgrCellInverse mapping: (refined level grid, refined cell idx) -> (marked element idx, merked-element-refined cell idx).
[out]refined_cell_count_vecNumber of refined cells per refined level grid.
[in]assignRefinedLevelFor each element: 0 = not marked, >0 = assigned refined level.
[out]preAdapt_parent_to_children_cells_vecFor each pre-adapt/refine grid cell: children in refined grid, or {-1,{}} if none.

— Adapted cell data —

Parameters
[out]elemLgrAndElemLgrCell_to_adaptedCellMaps (marked element idx, marked-element-refined cell idx) -> leaf/adapted grid cell.
[out]adaptedCell_to_elemLgrAndElemLgrCellInverse mapping: adapted cell idx -> (marked element idx, marked-element-refined cell idx).
[out]cell_countTotal number of cells in adapted (leaf) grid.
[out]preAdapt_level_to_leaf_cells_vecMaps pre-adapt grid cells to adapted cells (−1 if vanished).

— Additional —

Parameters
[in]cells_per_dim_vecRefinement factors per dimension for each refined level grid.

◆ replaceLgr1CornerIdxByLgr2CornerIdx() [1/2]

int Opm::Lgr::replaceLgr1CornerIdxByLgr2CornerIdx ( const Dune::cpgrid::CpGridData current_data,
const std::array< int, 3 > &  cells_per_dim_lgr1,
int  cornerIdxLgr1,
int  elemLgr1,
int  parentFaceLastAppearanceIdx,
const std::array< int, 3 > &  cells_per_dim_lgr2 
)

Map a new refined corner on an edge from one single-cell refinement to a neighboring refinement.

Given a corner index in one refinement, compute its index in a neighboring refinement. The corner lies on an edge and may appear in multiple refinements.

Parameters
[in]cells_per_dim_lgr1Number of child cells in {x,y,z} directions for the first refinement.
[in]cornerIdxLgr1Corner index in the first single-cell refinement.
[in]elemLgr1Parent cell index of the first refinement.
[in]parentFaceLastAppearanceIdxParent face index where the corner appears last.
[in]cells_per_dim_lgr2Number of child cells in {x,y,z} directions for the second refinement.
Returns
Corresponding corner index in the second single-cell refinement.

◆ replaceLgr1CornerIdxByLgr2CornerIdx() [2/2]

int Opm::Lgr::replaceLgr1CornerIdxByLgr2CornerIdx ( const std::array< int, 3 > &  cells_per_dim_lgr1,
int  cornerIdxLgr1,
const std::array< int, 3 > &  cells_per_dim_lgr2 
)

Map a refined corner from one single-cell refinement to a neighboring refinement.

Given a corner index in the first single-cell refinement, compute the corresponding corner index in the second single-cell refinement.

Parameters
[in]cells_per_dim_lgr1Number of child cells in {x,y,z} directions for the first refinement.
[in]cornerIdxLgr1Corner index in the first single-cell refinement.
[in]cells_per_dim_lgr2Number of child cells in {x,y,z} directions for the second refinement.
Returns
Corresponding corner index in the second single-cell refinement.

◆ replaceLgr1FaceIdxByLgr2FaceIdx()

int Opm::Lgr::replaceLgr1FaceIdxByLgr2FaceIdx ( const std::array< int, 3 > &  cells_per_dim_lgr1,
int  faceIdxInLgr1,
const std::shared_ptr< Dune::cpgrid::CpGridData > &  elemLgr1_ptr,
const std::array< int, 3 > &  cells_per_dim_lgr2 
)

Map a refined boundary face from one single-cell refinement to a neighboring refinement.

A refined face on the boundary may appear in up to two single-cell refinements. Given its index in the first refinement, this function computes the corresponding face index in the neighboring refinement.

Parameters
[in]cells_per_dim_lgr1Number of child cells in {x,y,z} directions for the first refinement.
[in]faceIdxInLgr1Face index in the first single-cell refinement.
[in]elemLgr1_ptrPointer to the first single-cell refinement grid.
[in]cells_per_dim_lgr2Number of child cells in {x,y,z} directions for the second refinement.
Returns
Corresponding face index in the second single-cell refinement.

◆ selectWinnerPointIds()

void Opm::Lgr::selectWinnerPointIds ( const Dune::CpGrid grid,
std::vector< std::vector< int > > &  localToGlobal_points_per_level,
const std::vector< std::tuple< int, std::vector< int > > > &  parent_to_children,
const std::vector< std::array< int, 3 > > &  cells_per_dim_vec 
)

Select and re-write point global ids.

After assigning global IDs to points in refined-level grids, a single point may have "multiple unique" global IDs, one in each process to which it belongs. To reduce the unnucesary id assigments, since global IDs must be distinct across the global leaf view and consistent across each refined-level grid, we will rewrite the entries in localToGlobal_points_per_level. Using cell_to_point_ across all refined cells through communication: gathering the 8 corner points of each interior cell and scattering the 8 corner points of overlapping cells, for all child cells of a parent cell in level zero grid.

Parameters
[out]localToGlobal_points_per_levelRelation local point.index() to assigned 'candidate' global id.
[in]parent_to_childrenThe communication step is based on level zero grid, via the relation parent-children-cells.
[in]cells_per_dim_vecTotal child cells in each direction (x-,y-, and z-direction) per block of cells.

◆ sharedFaceTag()

int Opm::Lgr::sharedFaceTag ( const std::vector< std::array< int, 3 > > &  startIJK_2Patches,
const std::vector< std::array< int, 3 > > &  endIJK_2Patches,
const std::array< int, 3 > &  grid_dim 
)

◆ validStartEndIJKs()

void Opm::Lgr::validStartEndIJKs ( const std::vector< std::array< int, 3 > > &  startIJK_vec,
const std::vector< std::array< int, 3 > > &  endIJK_vec 
)

Check startIJK and endIJK of each patch of cells to be refined are valid, i.e. startIJK and endIJK vectors have the same size and, startIJK < endIJK coordenate by coordenate.

Parameters
[in]startIJK_vecVector of Cartesian triplet indices where each patch starts.
[in]endIJK_vecVector of Cartesian triplet indices where each patch ends. Last cell part of the lgr will be {endIJK_vec[patch][0]-1, ..., endIJK_vec[patch][2]-1}.