Skip to content

Commit a2cf7a0

Browse files
committed
Remove replaceLgr1CornerByLgr2Corner
1 parent ee459e2 commit a2cf7a0

7 files changed

Lines changed: 228 additions & 706 deletions

File tree

CMakeLists_files.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ list(APPEND TEST_SOURCE_FILES
120120
tests/cpgrid/lgr/lgrs_sharing_faces_test.cpp
121121
tests/cpgrid/lgr/logicalCartesianSize_and_refinement_test.cpp
122122
tests/cpgrid/lgr/nested_refinement_test.cpp
123-
tests/cpgrid/lgr/replace_lgr1_corner_idx_by_lgr2_corner_idx_test.cpp
124123
)
125124

126125
if(USE_OPM_COMMON)

opm/grid/cpgrid/CpGrid.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
20082008
std::vector<Opm::Lgr::CellRefinementBoundaryInfo> cellRefsBoundaryInfo(currentLeafData().size(0)); // if a cell has been refined, then
20092009
// its cell-refinement info is stored in gridCellRefinements[ element.index() ]
20102010

2011-
std::vector<Opm::Lgr::BoundaryInfo> boundaryInfoCellRefs(currentLeafData().size(0)); // if a cell has been refined, then
2011+
std::vector<Opm::Lgr::GridModificationMapping> modificationMapps(currentLeafData().size(0)); // if a cell has been refined, then
20122012

20132013
bool withoutFaults = true;
20142014
// Ignore marked aquifer cells/connections in globalRefine()/adapt(); throw in addLgrsUpdateLeafView()/autoRef().
@@ -2034,7 +2034,7 @@ bool CpGrid::refineAndUpdateGrid(bool throwOnFailure,
20342034
/* Additional parameters */
20352035
cells_per_dim_vec,
20362036
cellRefsBoundaryInfo,
2037-
boundaryInfoCellRefs,
2037+
modificationMapps,
20382038
withoutFaults);
20392039

20402040
#if HAVE_MPI

opm/grid/cpgrid/LgrFaultHelpers.cpp

Lines changed: 97 additions & 105 deletions
Large diffs are not rendered by default.

opm/grid/cpgrid/LgrFaultHelpers.hpp

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct BoundaryFaceInfo
125125
{
126126
int neighborParentCellIndex{}; // to search cell-refinement-CpGridData object
127127

128-
std::set<Dune::FieldVector<double,3>, FieldVectorLess> foundNewVertices{};
128+
std::set<Dune::FieldVector<double,3>, FieldVectorLess> foundNewVertices{};
129129

130130
std::map<Dune::FieldVector<double,3>, int, FieldVectorLess> boundaryVertex_to_vertexIdx{}; // not corrected index yet
131131

@@ -142,14 +142,12 @@ struct BoundaryFaceInfo
142142
std::vector<bool> faceFullyContainedInNeighbor{};
143143
};
144144

145-
struct BoundaryInfo
145+
struct GridModificationMapping
146146
{
147-
std::map<Dune::FieldVector<double,3>, int, FieldVectorLess> newVertex_to_newGridVertexIdx{};
148-
std::vector<std::vector<int>> old_to_new_faceIdxList{}; // if face got replaced for more faces, vector size>1
149-
std::vector<int> new_to_old_faceIdx{}; // if face didn't exist in old grid, invalidIdx = -1
150-
std::vector<std::vector<int>> oldGridFaceIdx_to_newGridFaceIdx{};
151-
std::unordered_map<int, int> newGridFaceIdx_to_oldGridFaceIdx{};// the vanished faces are not included??
152-
std::unordered_map<int, std::vector<int>> vanishedOldGridFaceIdx_to_newGridFaceIndices{};
147+
std::map<Dune::FieldVector<double,3>, int, FieldVectorLess> newGridVertexCoordinates_to_newGridVertexIdx{};
148+
std::vector<int> newGridFaceIdx_to_oldGridFaceIdx{}; // invalidIdx = -1, if face does not exist in old grid
149+
150+
std::vector<std::vector<int>> oldGridFaceIdx_to_newGridFaceIdxList{};
153151
};
154152

155153

@@ -535,9 +533,6 @@ computeFaceOverlapVertices(const Face&
535533
return std::make_optional<std::vector<Dune::FieldVector<double,3>>>(ordered);
536534
}
537535

538-
bool isAtGridBoundary(const Dune::cpgrid::CpGridData& gridData,
539-
const Dune::cpgrid::Entity<0>& element);
540-
541536
std::set<Dune::FieldVector<double,3>,FieldVectorLess>
542537
collectNewVertices(const Dune::cpgrid::CpGridData& parentGridData,
543538
const Dune::cpgrid::Entity<0>& parentElem,
@@ -601,6 +596,47 @@ void computeNewRefinedGeometriesOnSharedCoarseFace(int numFaces1,
601596
std::vector<std::vector<std::pair<int,std::vector<Dune::FieldVector<double,3>>>>>& vanishedCellRef2Face_to_newRefinedFaces,
602597
std::vector<int>& face1FullyContainedInNeighborFace2);
603598

599+
/// Checks whether the specified cell is located at the grid boundary by
600+
/// verifying if any of its faces is connected to only one cell.
601+
bool isAtGridBoundary(const Dune::cpgrid::CpGridData& grid,
602+
const Dune::cpgrid::Entity<0>& element);
603+
604+
/// Builds a map from grid point coordinates to point indices for all points
605+
/// on the cell boundary, including the eight corner points ("cell_to_point")
606+
/// and additional face points resulting from present of multiple faces of the same
607+
/// type (same tag - I,J, or K, same orientation +/-, e.g.: a cell with 2 I+ faces).
608+
std::map<Dune::FieldVector<double,3>, int, FieldVectorLess>
609+
buildExtendedCellPointVertexMap(const Dune::cpgrid::CpGridData& grid,
610+
int cellIndex);
611+
612+
/// Checks whether two 3D vectors have matching coordinates within a given tolerance (1e-12).
613+
bool areClose(const Dune::FieldVector<double,3>& v,
614+
const Dune::FieldVector<double,3>& w);
615+
616+
/// Returns a face index on the specified grid faces so that one of the face vertex coordinates
617+
/// match those of the target vertex.
618+
std::optional<int> findVertexIdxInFaces(const Dune::cpgrid::CpGridData& grid,
619+
const std::vector<int>& candidateFaces,
620+
const Dune::FieldVector<double,3>& targetVertex);
621+
622+
/// Returns the index of the vertex on the specified face whose coordinates
623+
/// match the specified target vertex.
624+
std::optional<int> findMatchingVertexIdx(const Dune::cpgrid::CpGridData& grid,
625+
int faceIndex,
626+
const Dune::FieldVector<double,3>& targetVertex);
627+
628+
/// Returns the coordinates of all vertices defining a face.
629+
std::vector<Dune::FieldVector<double,3>> getFaceVertexCoordinates(const Dune::cpgrid::CpGridData& gridData,
630+
int faceIdx);
631+
632+
/// Returns the face index on the specified target grid faces
633+
/// whose vertex coordinates match those of the specified source face.
634+
std::optional<int> findMatchingFaceIdx(const Dune::cpgrid::CpGridData& targetGrid,
635+
const std::vector<int>& candidateFaces,
636+
const Dune::cpgrid::CpGridData& sourceGrid,
637+
int sourceFaceIdx);
638+
639+
604640
void addVertices(int& grid1_numVertices,
605641
const Dune::cpgrid::CpGridData& grid1,
606642
const std::map<Dune::FieldVector<double,3>, int, FieldVectorLess>& parentGrid_vertex_to_vertexIdx,
@@ -632,57 +668,31 @@ void addFaces(int
632668
std::unordered_map<int,int>& correctedGrid1BoundaryVertexIdx_to_grid2FaceIdx,
633669
const std::vector<int>& gridData1Face_fullyContainedIn_gridData2Face);
634670

635-
void addFaces(int grid1_numFaces,
636-
const Dune::cpgrid::CpGridData& grid1,
637-
const std::map<int,BoundaryFaceInfo>& boundaryFacesInfo,
638-
const std::map<Dune::FieldVector<double,3>, int, FieldVectorLess>& newVertex_to_correctedGrid1VertexIdx,
639-
GeomData& correctedGrid1GeomData,
640-
std::vector<std::vector<int>>& old_to_new_faceIdxList,
641-
std::vector<int>& new_to_old_faceIdx);
642-
643-
void addCells(GeomData& geomData,
644-
const Dune::cpgrid::CpGridData& gridData);
671+
void populateFaceData(int oldGridNumFaces,
672+
const Dune::cpgrid::CpGridData& oldGrid,
673+
const std::map<int,BoundaryFaceInfo>& boundaryFacesInfo,
674+
std::vector<int>& oldGridFaceIdx_to_parentFaceIdx,
675+
GridModificationMapping& modificationMap,
676+
GeomData& newGridGeomData);
645677

646-
std::vector<int> extendedCellToPoint(const Dune::cpgrid::CpGridData& gridData,
647-
int elemIdx);
678+
/// Populates cell geometry data, cell-to-point connectivity, and inverse
679+
/// face-to-cell relations using cells from the specified source grid.
680+
void populateCellData(const Dune::cpgrid::CpGridData& sourceGrid,
681+
GeomData& geomData);
648682

649-
std::map<Dune::FieldVector<double,3>, int, FieldVectorLess> extendedCellToPointVertexMap(const Dune::cpgrid::CpGridData& gridData,
650-
int elemIdx);
651-
652-
///
653-
/// @param cellRefGrids Shared pointers to the refinement grid data.
654-
/// CpGridData is intentionally non-copyable, so the grid data is passed by
655-
/// shared pointer rather than by value. This avoids unnecessary copies while
656-
/// allowing the function to access existing grid data without taking ownership of it.
657-
//BoundaryInfo
658-
std::pair<std::shared_ptr<Dune::cpgrid::CpGridData>,BoundaryInfo>
683+
std::pair<std::shared_ptr<Dune::cpgrid::CpGridData>, GridModificationMapping>
659684
makeCellRefinementNeighborsAware(const Dune::cpgrid::Entity<0>& parentCell,
660-
const std::vector<std::shared_ptr<Dune::cpgrid::CpGridData>>& cellRefs, // to get neighbor information
661-
const Dune::cpgrid::CpGridData& parentGrid,
662-
const Dune::cpgrid::CpGridData& cellRefGrid,
663-
CellRefinementBoundaryInfo& cellRefGridBoundaryInfo,
664-
std::vector<std::vector<std::pair<int, std::vector<int>>>>& faceInMarkedElemAndRefinedFaces);
685+
const std::vector<std::shared_ptr<Dune::cpgrid::CpGridData>>& cellRefs, // to get neighbor information
686+
const Dune::cpgrid::CpGridData& parentGrid,
687+
const Dune::cpgrid::CpGridData& cellRefGrid,
688+
CellRefinementBoundaryInfo& cellRefGridBoundaryInfo,
689+
std::vector<std::vector<std::pair<int, std::vector<int>>>>& faceInMarkedElemAndRefinedFaces);
665690

666691
void makeCellRefinementsNeighborsAware(std::vector<std::shared_ptr<Dune::cpgrid::CpGridData>>& cellRefs, // to get neighbor information
667692
std::vector<CellRefinementBoundaryInfo>& cellRefsBoundaryInfo,
668693
const Dune::cpgrid::CpGridData& parentGrid,
669694
std::vector<std::vector<std::pair<int, std::vector<int>>>>& faceInMarkedElemAndRefinedFaces,
670-
std::vector<BoundaryInfo>& boundaryInfoCellRefs);
671-
672-
std::optional<int> getNeighborCellRefVertexIdx(const Dune::cpgrid::CpGridData& neighborCellRef,
673-
const std::vector<int>& faceList,
674-
const Dune::FieldVector<double,3>& vertex);
675-
676-
677-
/// Returns the coordinates of all vertices defining a face.
678-
std::vector<Dune::FieldVector<double,3>> getFaceVertexCoordinates(const Dune::cpgrid::CpGridData& gridData,
679-
int faceIdx);
680-
/// Searches the candidate faces in the target grid for one whose vertex
681-
/// coordinates match those of the specified source face.
682-
std::optional<int> findMatchingFaceIdx(const Dune::cpgrid::CpGridData& targetGrid,
683-
const std::vector<int>& candidateFaces,
684-
const Dune::cpgrid::CpGridData& sourceGrid,
685-
int sourceFaceIdx);
695+
std::vector<GridModificationMapping>& modificationMapps);
686696

687697
} // namespace Lgr
688698
} // namespace Opm

0 commit comments

Comments
 (0)