@@ -683,34 +683,37 @@ void addVertices(int&
683683
684684
685685
686- void addVertices (int & grid1_numVertices,
687- const Dune::cpgrid::CpGridData& grid1,
686+ void addVertices (const Dune::cpgrid::CpGridData& oldGrid,
688687 const std::map<int ,BoundaryFaceInfo>& parentCellFace_to_boundaryFaceInfo,
689- GeomData& correctedGrid1GeomData,
690- std::map<Dune::FieldVector<double ,3 >, int , FieldVectorLess>& newVertex_to_correctedGrid1VertexIdx)
688+ GeomData& newGridGeomData,
689+ std::map<Dune::FieldVector<double ,3 >, int , FieldVectorLess>& newVertex_to_newGridVertexIdx,
690+ std::unordered_map<int , int >& newGridBoundaryVertex_to_parentFace,
691+ std::vector<bool >& newGridBoundaryVertexCoincidesWithParentVertex);
691692{
692- const auto & grid_vertices = *(grid1. getGeometry (). geomVector (std::integral_constant< int , 3 >()) );
693- Dune::cpgrid::EntityVariableBase<Dune::cpgrid::Geometry< 0 ,3 >>& correctedGrid1_vertices =
694- *(correctedGrid1GeomData .geometries .geomVector (std::integral_constant<int ,3 >()));
693+ int numVertices = oldGrid. size ( 3 );
694+ const auto & oldGridvertices = *(oldGrid. getGeometry (). geomVector (std::integral_constant< int ,3 >()));
695+ Dune::cpgrid::EntityVariableBase<Dune::cpgrid::Geometry< 0 , 3 >>& newGridVertices = *(newGridGeomData .geometries .geomVector (std::integral_constant<int ,3 >()));
695696
696697 for (const auto & [parentFace, boundInfo] : parentCellFace_to_boundaryFaceInfo) {
697- correctedGrid1_vertices .resize (grid1_numVertices + boundInfo.foundNewVertices .size ());
698+ newGridVertices .resize (numVertices + boundInfo.foundNewVertices .size ());
698699 }
699700
700- // add the "original " vertices (the aware- parent-cell-face are includeed here)
701- for (int i = 0 ; i < grid1.size (3 ); ++i) { /* * Check here if we're adding too many?? */
702- correctedGrid1_vertices [i] = grid_vertices .get (i);
701+ // add the "old " vertices (the parent-cell-face-aware are includeed here)
702+ for (int i = 0 ; i < grid1.size (3 ); ++i) {
703+ newGridVertices [i] = oldGridVertices .get (i);
703704 }
704705
705706 for (const auto & [parentFace, boundInfo] : parentCellFace_to_boundaryFaceInfo) {
706- for (const auto & vertex : boundInfo.foundNewVertices ) { /* *Do we also need to check grid1_vertex_to_vertexIdx?? */
707+ for (const auto & vertex : boundInfo.foundNewVertices ) {
707708
708- newVertex_to_correctedGrid1VertexIdx[vertex] = grid1_numVertices;
709- correctedGrid1_vertices[grid1_numVertices] = Dune::cpgrid::Geometry<0 , 3 >(vertex);
709+ newVertex_to_newGridVertexIdx[vertex] = numVertices;
710+ newGridVertices[grid1_numVertices] = Dune::cpgrid::Geometry<0 , 3 >(vertex);
711+ newGridBoundaryVertex_to_parentFace[numVertices] = parentFace;
710712
711- ++grid1_numVertices ;
713+ ++numVertices ;
712714 }
713715 }
716+ newGridBoundaryVertexCoincidesWithParentVertex.size (numVertices, false ); // false is used to initialized the new entries, old entries stay the same
714717}
715718
716719
@@ -905,49 +908,41 @@ void addFaces(int
905908 }
906909}
907910
908- void addFaces (int grid1_numFaces ,
909- const Dune::cpgrid::CpGridData& grid1 ,
911+ void addFaces (int oldGridNumFaces ,
912+ const Dune::cpgrid::CpGridData& oldGrid ,
910913 const std::map<int ,BoundaryFaceInfo>& boundaryFacesInfo,
911- const std::map<Dune::FieldVector<double ,3 >, int , FieldVectorLess>& newVertex_to_correctedGrid1VertexIdx,
912- GeomData& correctedGrid1GeomData,
913- std::vector<std::vector<int >>& grid1FaceIdx_to_correctedGrid1FaceIdx,
914- std::unordered_map<int , int >& correctedGrid1FaceIdx_to_grid1FaceIdx,
915- std::unordered_map<int , std::vector<int >>& grid1VanishedFaceIdx_to_correctedGrid1FaceIndices)
914+ const std::map<Dune::FieldVector<double ,3 >, int , FieldVectorLess>& newVertex_to_newGridVertexIdx,
915+ GeomData& newGridGeomData,
916+ std::vector<std::vector<int >>& oldGridFaceIdx_to_newGridFaceIdx,
917+ std::unordered_map<int , int >& newGrid1FaceIdx_to_oldGridFaceIdx,
918+ std::unordered_map<int , std::vector<int >>& oldGridVanishedFaceIdx_to_newGridFaceIndices,
919+ std::vector<int >& oldGridBoundaryFace_to_parentFace)
916920{
917- // BoundaryFaceInfo
918- // int neighborParentCellIndex{}; // to search cell-refinement-CpGridData object
919- // std::set<Dune::FieldVector<double,3>, FieldVectorLess> foundNewVertices{};
920- // std::map<Dune::FieldVector<double,3>, int, FieldVectorLess> boundaryVertex_to_vertexIdx <-> grid1_vertex_to_vertexIdx // not corrected index yet
921- // std::map<int,std::vector<std::vector<Dune::FieldVector<double,3>>>> overlapFaces <-> overlapFaces1
922- // std::vector<std::vector<std::pair<int,std::vector<Dune::FieldVector<double,3>>>>> vanishedCellRefFace_to_newRefinedFaces <-> grid1_vanishedFaceIdx_to_newFaces,
923- // std::vector<int> neighborFaceFullyContainedInCellRefFace{}; // face1 index in celRef1 that contains face2
924-
925921 int invalidIdx = -1 ;
926- grid1FaceIdx_to_correctedGrid1FaceIdx .resize (grid1_numFaces );
922+ oldGridFaceIdx_to_newGridFaceIdx .resize (oldGridNumFaces );
927923
928- Dune::cpgrid::EntityVariableBase<Dune::cpgrid::Geometry<2 ,3 >>& correctedGrid1_faces =
929- *(correctedGrid1GeomData.geometries .geomVector (std::integral_constant<int ,1 >()));
930- Dune::cpgrid::EntityVariableBase<enum face_tag>& mutable_correctedGrid1_face_tags = correctedGrid1GeomData.face_tags ;
931- Dune::cpgrid::EntityVariableBase<Dune::FieldVector<double ,3 >>& mutable_correctedGrid1_face_normals = correctedGrid1GeomData.face_normals ;
924+ Dune::cpgrid::EntityVariableBase<Dune::cpgrid::Geometry<2 ,3 >>& newGridFaces = *(newGridGeomData.geometries .geomVector (std::integral_constant<int ,1 >()));
925+ Dune::cpgrid::EntityVariableBase<enum face_tag>& mutable_newGridFaceTags = newGridGeomData.face_tags ;
926+ Dune::cpgrid::EntityVariableBase<Dune::FieldVector<double ,3 >>& mutable_newGridFaceNormals = newGridGeomData.face_normals ;
932927
933928 // Estimate new size of total number of faces in correctedGridData1
934- int upperBoundFaceSize = grid1_numFaces ; // total faces before correcting the data
929+ int upperBoundFaceSize = oldGridNumFaces ; // total faces before correcting the data
935930 for (const auto & [parentFaceIdx, boundaryFaceInfo] : boundaryFacesInfo) {
936- for (const auto & [grid2_faceIdx , overlapFacesInfo] : boundaryFaceInfo.overlapFaces ) {
931+ for (const auto & [neighborGrid_faceIdx , overlapFacesInfo] : boundaryFaceInfo.overlapFaces ) {
937932 upperBoundFaceSize += overlapFacesInfo.size ();
938933 }
939934 }
940- correctedGrid1_faces .resize (upperBoundFaceSize); // maybe larger than needed
941- mutable_correctedGrid1_face_tags .resize (upperBoundFaceSize);
942- mutable_correctedGrid1_face_normals .resize (upperBoundFaceSize);
935+ newGridFaces .resize (upperBoundFaceSize); // maybe larger than needed
936+ mutable_newGridFaceTags .resize (upperBoundFaceSize);
937+ mutable_newGridFaceNormals .resize (upperBoundFaceSize);
943938
944- std::vector<std::vector<int >> aux_correctedGrid1_face_to_point {};
945- aux_correctedGrid1_face_to_point .resize (upperBoundFaceSize);
939+ std::vector<std::vector<int >> aux_newGrid_face_to_point {};
940+ aux_newGrid_face_to_point .resize (upperBoundFaceSize);
946941
947- int correctedGrid1_num_points = 0 ;
948- int correctedGrid1_face_count = 0 ;
942+ int newGrid_num_points = 0 ;
943+ int newGrid_face_count = 0 ;
949944
950- for (int i = 0 ; i < grid1 .numFaces (); ++i) {
945+ for (int i = 0 ; i < oldGrid .numFaces (); ++i) {
951946 // hanlde inner faces first
952947 // const auto face = Dune::cpgrid::EntityRep<1>(i, true);
953948 const auto faceToCellSize = grid1.faceToCell (i).size ();
@@ -1547,12 +1542,17 @@ void makeCellRefinementsNeighborsAware(const Dune::cpgrid::Entity<0>& parentCell
15471542 int numVertices = cellRefGrid.size (3 );
15481543
15491544 BoundaryInfo boundaryInfo{};
1545+
1546+ // (3) cellRefGridBoundaryInfo.boundaryRefinedFace_to_parentFace NEEDS UPDATE!!! maybe pass it as argument somewhere else??
1547+ // Face index at the boundary of cell refinement grid, to parent face index
15501548
15511549 addVertices (numVertices,
15521550 cellRefGrid,
15531551 boundaryFacesInfo,
15541552 neighborAwareGeomData,
1555- boundaryInfo.newVertex_to_newGridVertexIdx );
1553+ boundaryInfo.newVertex_to_newGridVertexIdx ,
1554+ cellRefGridBoundaryInfo.boundaryRefinedVertex_to_parentFace ,
1555+ cellRefGridBoundaryInfo.boundaryRefinedVertexCoincidesWithParentVertex );
15561556
15571557 std::cout<< numVertices << " numVertices after addition " << std::endl;
15581558
@@ -1564,15 +1564,14 @@ void makeCellRefinementsNeighborsAware(const Dune::cpgrid::Entity<0>& parentCell
15641564 neighborAwareGeomData,
15651565 boundaryInfo.oldGridFaceIdx_to_newGridFaceIdx ,
15661566 boundaryInfo.newGridFaceIdx_to_oldGridFaceIdx ,
1567- boundaryInfo.vanishedOldGridFaceIdx_to_newGridFaceIndices );
1567+ boundaryInfo.vanishedOldGridFaceIdx_to_newGridFaceIndices ,
1568+ cellRefGridBoundaryInfo.boundaryRefinedFace_to_parentFace );
15681569
15691570 std::cout<< numFaces << " numFaces after addition " << std::endl;
15701571
15711572 addCells (neighborAwareGeomData, cellRefGrid);
15721573
1573- updateCellRefinementBoundaryInfo (cellRefGridBoundaryInfo,
1574- // boundaryFacesInfo,
1575- boundaryInfo);
1574+
15761575}
15771576
15781577
0 commit comments