Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ list(APPEND MAIN_SOURCE_FILES
opm/grid/cpgrid/GridHelpers.cpp
opm/grid/cpgrid/Iterators.cpp
opm/grid/cpgrid/Indexsets.cpp
opm/grid/cpgrid/LgrFaultHelpers.cpp
opm/grid/cpgrid/LgrHelpers.cpp
opm/grid/cpgrid/LgrOutputHelpers.cpp
opm/grid/cpgrid/NestedRefinementUtilities.cpp
Expand Down Expand Up @@ -112,14 +113,13 @@ list(APPEND TEST_SOURCE_FILES
tests/cpgrid/lgr/addLgrs_in_allActiveCartesianGrid_test.cpp
tests/cpgrid/lgr/addLgrsOnDistributedGrid_test.cpp
tests/cpgrid/lgr/autoRefine_test.cpp
tests/cpgrid/lgr/faults_and_lgrs_test.cpp
tests/cpgrid/lgr/global_refine_test.cpp
tests/cpgrid/lgr/id_entity_entityrep_test.cpp
tests/cpgrid/lgr/level_and_grid_cartesianIndexMappers_test.cpp
tests/cpgrid/lgr/lgrs_sharing_faces_test.cpp
tests/cpgrid/lgr/logicalCartesianSize_and_refinement_test.cpp
tests/cpgrid/lgr/nested_refinement_test.cpp
tests/cpgrid/lgr/replace_lgr1_corner_idx_by_lgr2_corner_idx_test.cpp
tests/cpgrid/lgr/replace_lgr1_face_idx_by_lgr2_face_idx_test.cpp
)

if(USE_OPM_COMMON)
Expand Down Expand Up @@ -211,6 +211,7 @@ list(APPEND PUBLIC_HEADER_FILES
opm/grid/cpgrid/Indexsets.hpp
opm/grid/cpgrid/Intersection.hpp
opm/grid/cpgrid/Iterators.hpp
opm/grid/cpgrid/LgrFaultHelpers.hpp
opm/grid/cpgrid/LgrHelpers.hpp
opm/grid/cpgrid/LgrOutputHelpers.hpp
opm/grid/cpgrid/ElementMarkHandle.hpp
Expand Down
36 changes: 23 additions & 13 deletions opm/grid/cpgrid/CpGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,8 +2004,13 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
// In entry 'level cell index', we store 'leafview cell index', or -1 when the cell vanished.
preAdapt_level_to_leaf_cells_vec[preAdaptLevel].resize(data[preAdaptLevel]->size(0), -1);
}

std::vector<Opm::Lgr::CellRefinementBoundaryInfo> cellRefsBoundaryInfo(currentLeafData().size(0)); // if a cell has been refined, then
// its cell-refinement info is stored in gridCellRefinements[ element.index() ]

bool withoutFaults = true;
// Ignore marked aquifer cells/connections in globalRefine()/adapt(); throw in addLgrsUpdateLeafView()/autoRef().
Opm::Lgr::filterMarkedAquiferCellsAndConnections(*this, throwOnFailure);
Opm::Lgr::filterMarkedAquiferCellsAndConnections(*this, throwOnFailure);
Opm::Lgr::refineAndProvideMarkedRefinedRelations( *this,
/* Marked elements parameters */
markedElem_to_itsLgr,
Expand All @@ -2025,7 +2030,9 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
cell_count,
preAdapt_level_to_leaf_cells_vec,
/* Additional parameters */
cells_per_dim_vec);
cells_per_dim_vec,
cellRefsBoundaryInfo,
withoutFaults);

#if HAVE_MPI
auto global_markedElem_count = comm().sum(markedElem_count);
Expand Down Expand Up @@ -2095,7 +2102,9 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
assignRefinedLevel,
cornerInMarkedElemWithEquivRefinedCorner,
faceInMarkedElemAndRefinedFaces,
cells_per_dim_vec);
cells_per_dim_vec,
cellRefsBoundaryInfo,
withoutFaults);

// --- Adapted corners and PreAdapt corners relations ---
std::map<std::array<int,2>,int> elemLgrAndElemLgrCorner_to_adaptedCorner;
Expand All @@ -2114,7 +2123,9 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
cornerInMarkedElemWithEquivRefinedCorner,
vanishedRefinedCorner_to_itsLastAppearance,
faceInMarkedElemAndRefinedFaces,
cells_per_dim_vec);
cells_per_dim_vec,
cellRefsBoundaryInfo,
withoutFaults);

// FACES
// Stablish relationships between PreAdapt faces and refined or adapted ones ---
Expand All @@ -2131,22 +2142,21 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
markedElem_to_itsLgr,
assignRefinedLevel,
faceInMarkedElemAndRefinedFaces,
cells_per_dim_vec);
cellRefsBoundaryInfo);

// --- Adapted faces and PreAdapt faces relations ---
std::map< std::array<int,2>, int > elemLgrAndElemLgrFace_to_adaptedFace;
std::unordered_map< int, std::array<int,2> > adaptedFace_to_elemLgrAndElemLgrFace;
// Integer to count adapted faces (mixed between faces from pre-refined-leaf faces not involved in LGRs and new-born refined faces).
int face_count = 0;
Opm::Lgr::identifyLeafGridFaces(currentLeafData(),
preAdaptMaxLevel,
elemLgrAndElemLgrFace_to_adaptedFace,
adaptedFace_to_elemLgrAndElemLgrFace,
face_count,
markedElem_to_itsLgr,
assignRefinedLevel,
faceInMarkedElemAndRefinedFaces,
cells_per_dim_vec);
cellRefsBoundaryInfo);

// Set refined level grids geometries
// --- Refined corners ---
Expand All @@ -2167,7 +2177,10 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
markedElem_to_itsLgr,
preAdaptMaxLevel,
cornerInMarkedElemWithEquivRefinedCorner,
markedElemAndEquivRefinedCorn_to_corner);
markedElemAndEquivRefinedCorn_to_corner,
cellRefsBoundaryInfo,
faceInMarkedElemAndRefinedFaces,
currentLeafData());
// --- Refined cells ---
Opm::Lgr::populateRefinedCells(currentLeafData(),
refined_cells_vec,
Expand All @@ -2183,11 +2196,10 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner,
vanishedRefinedCorner_to_itsLastAppearance,
markedElem_to_itsLgr,
assignRefinedLevel,
preAdaptMaxLevel,
markedElemAndEquivRefinedCorn_to_corner,
cornerInMarkedElemWithEquivRefinedCorner,
cells_per_dim_vec);
cellRefsBoundaryInfo);

// Update leaf grid geometries
// --- Adapted corners ---
Expand Down Expand Up @@ -2226,11 +2238,9 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
elemLgrAndElemLgrCorner_to_adaptedCorner,
vanishedRefinedCorner_to_itsLastAppearance,
markedElem_to_itsLgr,
assignRefinedLevel,
markedElemAndEquivRefinedCorn_to_corner,
cornerInMarkedElemWithEquivRefinedCorner,
cells_per_dim_vec,
preAdaptMaxLevel);
cellRefsBoundaryInfo);

for (int level = 0; level < levels; ++level) {
const int refinedLevelGridIdx = level + preAdaptMaxLevel +1;
Expand Down
Loading