36 #ifndef _GHOSTHANDLER_HPP_ 37 #define _GHOSTHANDLER_HPP_ 42 #include <EpetraExt_HDF5.h> 45 #include <lifev/core/LifeV.hpp> 46 #include <lifev/core/util/LifeChronoManager.hpp> 47 #include <lifev/core/array/MapEpetra.hpp> 48 #include <lifev/core/mesh/NeighborMarker.hpp> 50 #ifdef HAVE_LIFEV_DEBUG 74 template <
typename MeshType>
155 ASSERT ( !M_pointPointNeighborsList.empty(),
"M_pointPointNeighborsList is empty" );
162 ASSERT ( !M_pointEdgeNeighborsList.empty(),
"M_pointEdgeNeighborsList is empty" );
169 ASSERT ( !M_pointElementNeighborsList.empty(),
"M_pointElementNeighborsList is empty" );
314 void showMe (
bool const verbose =
false, std::ostream& out = std::cout );
344 #ifdef LIFEV_GHOSTHANDLER_DEBUG 350 template <
typename MeshType>
361 #ifdef LIFEV_GHOSTHANDLER_DEBUG 367 template <
typename MeshType>
381 #ifdef LIFEV_GHOSTHANDLER_DEBUG 387 template <
typename MeshType>
397 #ifdef LIFEV_GHOSTHANDLER_DEBUG 403 template <
typename MeshType>
406 if ( (neighborType & POINT_NEIGHBORS) != 0 )
408 this->createPointPointNeighborsList();
410 if ( (neighborType & RIDGE_NEIGHBORS) != 0 )
412 this->createPointEdgeNeighborsList();
414 if ( (neighborType & ELEMENT_NEIGHBORS) != 0 )
416 this->createPointElementNeighborsList();
420 template <
typename MeshType>
427 template <
typename MeshType>
430 if ( (neighborType & POINT_NEIGHBORS) != 0 )
434 if ( (neighborType & RIDGE_NEIGHBORS) != 0 )
438 if ( (neighborType & ELEMENT_NEIGHBORS) != 0 )
587 template <
typename MeshType>
595 for ( UInt ie = 0; ie < M_fullMesh->numEdges(); ie++ )
597 ID id0 = M_fullMesh->edge ( ie ).point ( 0 ).id();
598 ID id1 = M_fullMesh->edge ( ie ).point ( 1 ).id();
600 ASSERT ( M_fullMesh->point ( id0 ).id() == id0 && M_fullMesh->point ( id1 ).id() == id1,
601 "the mesh has been reordered, the point must be found" );
604 M_fullMesh->point ( id0 ).pointNeighbors().insert ( id1 );
605 M_fullMesh->point ( id1 ).pointNeighbors().insert ( id0 );
609 for ( UInt ip = 0; ip < M_localMesh->numPoints(); ip++ )
611 M_localMesh->point ( ip ).pointNeighbors() = M_fullMesh->point ( M_localMesh->point ( ip ).id() ).pointNeighbors();
615 template <
typename MeshType>
618 M_pointPointNeighborsList.resize ( M_fullMesh->numGlobalPoints() );
621 for ( UInt ie = 0; ie < M_fullMesh->numEdges(); ie++ )
623 ID id0 = M_fullMesh->edge ( ie ).point ( 0 ).id();
624 ID id1 = M_fullMesh->edge ( ie ).point ( 1 ).id();
626 ASSERT ( M_fullMesh->point ( id0 ).id() == id0 && M_fullMesh->point ( id1 ).id() == id1,
627 "the mesh has been reordered, the point must be found" );
629 M_pointPointNeighborsList[ id0 ].insert ( id1 );
630 M_pointPointNeighborsList[ id1 ].insert ( id0 );
633 #ifdef LIFEV_GHOSTHANDLER_DEBUG 634 M_debugOut <<
"M_pointPointNeighborsList on proc " << M_me << std::endl;
635 for ( UInt i = 0; i < M_pointPointNeighborsList.size(); i++ )
637 M_debugOut << i <<
": ";
638 for ( neighbors_Type::const_iterator it = M_pointPointNeighborsList[ i ].begin();
639 it != M_pointPointNeighborsList[ i ].end(); ++it )
641 M_debugOut << *it <<
" ";
643 M_debugOut << std::endl;
653 for ( UInt i = 0; i < markerIDList.size(); ++i)
654 if ( pointMarker == markerIDList[i] )
663 template <
typename MeshType>
666 M_pointPointNeighborsList.resize ( M_fullMesh->numGlobalPoints() );
669 for ( UInt ie = 0; ie < M_fullMesh->numEdges(); ie++ )
671 ID id0 = M_fullMesh->edge ( ie ).point ( 0 ).id();
672 ID id1 = M_fullMesh->edge ( ie ).point ( 1 ).id();
674 ASSERT ( M_fullMesh->point ( id0 ).id() == id0 && M_fullMesh->point ( id1 ).id() == id1,
675 "the mesh has been reordered, the point must be found" );
677 if ( isInside (M_fullMesh->edge ( ie ).point ( 1 ).markerID(), flags) )
679 M_pointPointNeighborsList[ id0 ].insert ( id1 );
682 if ( isInside (M_fullMesh->edge ( ie ).point ( 0 ).markerID(), flags) )
684 M_pointPointNeighborsList[ id1 ].insert ( id0 );
695 template <
typename MeshType>
702 neighbors =
this->pointPointNeighborsList() [ globalID ];
704 for (
UInt i = 0; i < nCircles - 1; ++i)
706 for (neighbors_Type::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
708 newEntries =
this->pointPointNeighborsList() [*it];
709 for (neighbors_Type::iterator ii = newEntries.begin(); ii != newEntries.end(); ++ii)
711 newNeighbors.insert (*ii);
715 for (neighbors_Type::iterator it = newNeighbors.begin(); it != newNeighbors.end(); ++it)
717 neighbors.insert(*it);
725 template <
typename MeshType>
731 bool isInside =
true;
735 neighbors =
this->pointPointNeighborsList() [globalID];
737 typename mesh_Type::point_Type
const& p = M_fullMesh->point (globalID);
741 for (neighbors_Type::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
743 newEntries =
this->pointPointNeighborsList() [*it];
744 for (neighbors_Type::iterator ii = newEntries.begin(); ii != newEntries.end(); ++ii)
746 typename mesh_Type::point_Type
const& n = M_fullMesh->point (*ii);
747 d = std::sqrt ( ( n.x() - p.x() ) * ( n.x() - p.x() ) +
748 ( n.y() - p.y() ) * ( n.y() - p.y() ) +
749 ( n.z() - p.z() ) * ( n.z() - p.z() ) );
752 newNeighbors.insert (*ii);
757 neighbors = newNeighbors;
759 if (neighbors.size() == mysize)
764 mysize = neighbors.size();
772 template <
typename MeshType>
775 M_pointEdgeNeighborsList.resize ( M_fullMesh->numGlobalPoints() );
778 for ( UInt ie = 0; ie < M_fullMesh->numEdges(); ie++ )
780 ID id0 = M_fullMesh->edge ( ie ).point ( 0 ).id();
781 ID id1 = M_fullMesh->edge ( ie ).point ( 1 ).id();
783 ASSERT ( M_fullMesh->point ( id0 ).id() == id0 && M_fullMesh->point ( id1 ).id() == id1,
784 "the mesh has been reordered, the point must be found" );
786 M_pointEdgeNeighborsList[ id0 ].insert ( ie );
787 M_pointEdgeNeighborsList[ id1 ].insert ( ie );
790 #ifdef LIFEV_GHOSTHANDLER_DEBUG 791 M_debugOut <<
"M_pointEdgeNeighborsList on proc " << M_me << std::endl;
792 for ( UInt i = 0; i < M_pointEdgeNeighborsList.size(); i++ )
794 M_debugOut << i <<
": ";
795 for ( neighbors_Type::const_iterator it = M_pointEdgeNeighborsList[ i ].begin();
796 it != M_pointEdgeNeighborsList[ i ].end(); ++it )
798 M_debugOut << *it <<
" ";
800 M_debugOut << std::endl;
805 template <
typename MeshType>
808 M_pointElementNeighborsList.resize ( M_fullMesh->numGlobalPoints() );
810 for ( UInt ie = 0; ie < M_fullMesh->numElements(); ie++ )
812 ASSERT ( M_fullMesh->element ( ie ).id() == ie,
813 "the mesh has been reordered, the point must be found" );
815 for ( UInt k = 0; k < mesh_Type::element_Type::S_numPoints; k++ )
817 ID id ( M_fullMesh->element ( ie ).point ( k ).id() );
818 M_pointElementNeighborsList[ id ].insert ( ie );
823 template <
typename MeshType>
829 return *M_ghostMapOnPoints;
834 std::cout <<
" GH- ghostMapOnPoints()" << std::endl;
838 if ( M_localMesh->point ( 0 ).pointNeighbors().empty() )
842 std::cerr <<
"the pointNeighbors are empty, will be generated now" << std::endl;
844 this->createPointNeighbors();
848 M_ghostMapOnPoints.reset (
new map_Type() );
849 map_Type& ghostMap ( *M_ghostMapOnPoints );
852 ghostMap.setMap ( M_map->map ( Unique ), Unique );
856 std::set<Int> myGlobalElementsSet;
860 for ( UInt k = 0; k < M_localMesh->numPoints(); k++ )
863 for (
typename mesh_Type::PointMarker::neighborConstIterator_Type neighborIt = M_localMesh->point ( k ).pointNeighbors().begin();
864 neighborIt != M_localMesh->point ( k ).pointNeighbors().end(); ++neighborIt )
866 myGlobalElementsSet.insert ( *neighborIt );
870 std::vector<Int> myGlobalElements ( myGlobalElementsSet.begin(), myGlobalElementsSet.end() );
873 map_Type::
mapPtr_Type repeatedMap (
new Epetra_Map ( -1, myGlobalElements.size(), &myGlobalElements[0], 0, *M_comm ) );
876 return *M_ghostMapOnPoints;
879 template <
typename MeshType>
885 return *M_ghostMapOnPoints;
890 std::cout <<
" GH- ghostMapOnPoints( UInt )" << std::endl;
894 if ( M_pointPointNeighborsList.empty() )
898 std::cerr <<
"the pointPointNeighborsList is empty, will be generated now" << std::endl;
900 this->createPointPointNeighborsList();
904 M_ghostMapOnPoints.reset (
new map_Type() );
905 map_Type& ghostMap ( *M_ghostMapOnPoints );
908 ghostMap.setMap ( M_map->map ( Unique ), Unique );
912 std::set<Int> myGlobalElementsSet, myOriginalElementsSet;;
915 pointer = M_map->map ( Repeated )->MyGlobalElements();
916 for ( Int ii = 0; ii < M_map->map ( Repeated )->NumMyElements(); ++ii, ++pointer )
918 myOriginalElementsSet.insert ( *pointer );
925 for (
UInt i = 0; i < overlap; i++ )
928 for ( std::set<Int>::const_iterator pointIt = myOriginalElementsSet.begin();
929 pointIt != myOriginalElementsSet.end(); ++pointIt )
932 for ( neighbors_Type::const_iterator neighborIt = M_pointPointNeighborsList[ *pointIt ].begin();
933 neighborIt != M_pointPointNeighborsList[ *pointIt ].end(); ++neighborIt )
935 myGlobalElementsSet.insert ( *neighborIt );
938 myOriginalElementsSet = myGlobalElementsSet;
941 std::vector<Int> myGlobalElements ( myGlobalElementsSet.begin(), myGlobalElementsSet.end() );
944 map_Type::
mapPtr_Type repeatedMap (
new Epetra_Map ( -1, myGlobalElements.size(), &myGlobalElements[0], 0, *M_comm ) );
947 return *M_ghostMapOnPoints;
950 template <
typename MeshType>
956 return *M_ghostMapOnEdges;
961 std::cout <<
" GH- ghostMapOnEdges()" << std::endl;
965 if ( M_pointEdgeNeighborsList.empty() )
969 std::cerr <<
"the pointEdgeNeighborsList is empty, will be generated now" << std::endl;
971 this->createPointEdgeNeighborsList();
976 mapData.unique.reserve ( M_localMesh->numEdges() );
977 mapData.repeated.reserve ( M_localMesh->numEdges() );
979 for ( ID ie = 0; ie < M_localMesh->numEdges(); ie++ )
981 mapData.repeated.push_back ( M_localMesh->edge ( ie ).id() );
982 if ( M_localMesh->edge ( ie ).isOwned() )
984 mapData.unique.push_back ( M_localMesh->edge ( ie ).id() );
988 M_ghostMapOnEdges.reset (
new map_Type ( mapData, M_comm ) );
992 map_Type& ghostMap ( *M_ghostMapOnEdges );
994 std::set<Int> myGlobalElementsSet;
995 std::set<Int> addedElementsSet;
997 for ( UInt k ( 0 ); k < mapData.repeated.size(); k++ )
999 typename mesh_Type::edge_Type
const& edge = M_fullMesh->edge ( mapData.repeated[ k ] );
1000 for ( UInt edgePoint = 0; edgePoint < mesh_Type::edge_Type::S_numPoints; edgePoint++ )
1002 addedElementsSet.insert ( edge.point ( edgePoint ).id() );
1005 ( mapData.repeated.begin(), mapData.repeated.end() );
1012 for (
UInt i = 0; i < overlap; i++ )
1015 for ( std::set<Int>::const_iterator pointIt = addedElementsSet.begin();
1016 pointIt != addedElementsSet.end(); ++pointIt )
1019 for ( neighbors_Type::const_iterator neighborIt = M_pointEdgeNeighborsList[ *pointIt ].begin();
1020 neighborIt != M_pointEdgeNeighborsList[ *pointIt ].end(); ++neighborIt )
1022 std::pair<std::set<Int>::iterator,
bool> isInserted = myGlobalElementsSet.insert ( *neighborIt );
1023 if ( isInserted.second )
1025 typename mesh_Type::EdgeType
const& edge = M_fullMesh->edge ( *neighborIt );
1026 for ( UInt edgePoint = 0; edgePoint < mesh_Type::EdgeType::S_numPoints; edgePoint++ )
1030 addedElementsSet.insert ( edge.point ( edgePoint ).id() );
1037 mapData.repeated.assign ( myGlobalElementsSet.begin(), myGlobalElementsSet.end() );
1040 mapData.repeated.size(),
1041 &mapData.repeated[0],
1047 return *M_ghostMapOnEdges;
1050 template <
typename MeshType>
1056 return *M_ghostMapOnElementsFV;
1061 std::cout <<
" GH- ghostMapOnElementsFV()" << std::endl;
1065 M_ghostMapOnElementsFV.reset (
new map_Type() );
1066 map_Type& ghostMap ( *M_ghostMapOnElementsFV );
1069 ghostMap.setMap ( M_map->map ( Unique ), Unique );
1076 pointer = M_map->map ( Repeated )->MyGlobalElements();
1077 for ( Int ii = 0; ii < M_map->map ( Repeated )->NumMyElements(); ++ii, ++pointer )
1079 map.insert ( *pointer );
1083 typedef typename mesh_Type::facet_Type
const* facetPtr_Type;
1084 std::vector<facetPtr_Type>
1085 facetsOnSubdInt = M_localMesh->facetList().extractElementsWithFlag (
1086 EntityFlags::SUBDOMAIN_INTERFACE, &Flag::testOneSet );
1087 for (
typename std::vector<facetPtr_Type>::const_iterator facetIt = facetsOnSubdInt.begin();
1088 facetIt != facetsOnSubdInt.end(); ++facetIt )
1090 map.insert ( (*facetIt)->secondAdjacentElementIdentity() );
1094 std::vector<Int> myGlobalElements ( map.begin(), map.end() );
1097 map_Type::
mapPtr_Type repeatedMap (
new Epetra_Map ( -1, myGlobalElements.size(), &myGlobalElements[0], 0, *M_comm ) );
1100 return *M_ghostMapOnElementsFV;
1103 template <
typename MeshType>
1109 return *M_ghostMapOnElementsFE;
1114 std::cout <<
" GH- ghostMapOnElementsFE()" << std::endl;
1118 if ( M_pointElementNeighborsList.empty() )
1122 std::cerr <<
"the pointElementNeighborsList is empty, will be generated now" << std::endl;
1124 this->createPointElementNeighborsList();
1128 M_ghostMapOnElementsFE.reset (
new map_Type() );
1129 map_Type& ghostMap ( *M_ghostMapOnElementsFE );
1132 ghostMap.setMap ( M_map->map ( Unique ), Unique );
1136 std::set<Int> myGlobalElementsSet;
1139 pointer = M_map->map ( Repeated )->MyGlobalElements();
1140 for ( Int ii = 0; ii < M_map->map ( Repeated )->NumMyElements(); ++ii, ++pointer )
1142 myGlobalElementsSet.insert ( *pointer );
1146 typedef typename mesh_Type::point_Type
const* pointPtr_Type;
1147 std::vector<pointPtr_Type>
1148 pointsOnSubdInt = M_localMesh->pointList.extractElementsWithFlag (
1149 EntityFlags::SUBDOMAIN_INTERFACE, &Flag::testOneSet );
1151 std::vector<ID> pointIDOnSubdInt ( pointsOnSubdInt.size() );
1152 for ( UInt i = 0; i < pointsOnSubdInt.size(); i++)
1154 pointIDOnSubdInt[i] = pointsOnSubdInt[i]->id();
1157 std::vector<ID> addedPoints;
1159 for (
UInt n = 0; n < overlap; n++ )
1161 for ( std::vector<ID>::const_iterator globalId = pointIDOnSubdInt.begin();
1162 globalId != pointIDOnSubdInt.end(); ++globalId )
1165 for ( neighbors_Type::const_iterator neighborIt = M_pointElementNeighborsList[ *globalId ].begin();
1166 neighborIt != M_pointElementNeighborsList[ *globalId ].end(); ++neighborIt )
1168 std::pair<std::set<Int>::iterator,
bool> isInserted = myGlobalElementsSet.insert ( *neighborIt );
1169 if ( isInserted.second )
1171 typename mesh_Type::element_Type
const& elem = M_fullMesh->element ( *neighborIt );
1172 for ( UInt elemPoint = 0; elemPoint < mesh_Type::element_Type::S_numPoints; elemPoint++ )
1175 addedPoints.push_back ( elem.point ( elemPoint ).id() );
1182 pointIDOnSubdInt = addedPoints;
1187 std::vector<Int> myGlobalElements ( myGlobalElementsSet.begin(), myGlobalElementsSet.end() );
1190 map_Type::
mapPtr_Type repeatedMap (
new Epetra_Map ( -1, myGlobalElements.size(), &myGlobalElements[0], 0, *M_comm ) );
1193 return *M_ghostMapOnElementsFE;
1196 template <
typename MeshType>
1203 std::cout <<
" GH- ghostMapOnElementsP1( graph )" << std::endl;
1206 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1207 LifeChronoManager<> timeMgr ( M_comm );
1209 timeMgr.add (
"point-element ngbr list", &timeNL );
1213 if ( M_pointElementNeighborsList.empty() )
1217 std::cerr <<
"the pointElementNeighborsList is empty, will be generated now" << std::endl;
1219 this->createPointElementNeighborsList();
1221 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1225 std::vector<
int>& myElems = (*elemGraph) [M_me];
1227 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1229 M_debugOut <<
"own elements on proc " << M_me << std::endl;
1230 for ( UInt i = 0; i < myElems.size(); i++ )
1232 M_debugOut << myElems[ i ] << std::endl;
1236 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1238 timeMgr.add (
"point graph", &timePG );
1245 std::set<
int> localPointsSet;
1246 for ( UInt e = 0; e < (*elemGraph) [ M_me ].size(); e++ )
1249 for ( UInt k = 0; k < mesh_Type::element_Type::S_numPoints; k++ )
1251 const ID& pointID = M_fullMesh->element ( (*elemGraph) [ M_me ][ e ] ).point ( k ).id();
1252 localPointsSet.insert ( pointID );
1255 pointGraph[ M_me ].assign ( localPointsSet.begin(), localPointsSet.end() );
1257 std::vector<Int> pointGraphSize ( M_comm->NumProc(), -1 );
1258 pointGraphSize[ M_me ] = pointGraph[ M_me ].size();
1259 for ( UInt p = 0; p <
static_cast<UInt> ( M_comm->NumProc() ); p++ )
1261 M_comm->Broadcast ( &pointGraphSize[ p ], 1, p );
1264 for ( UInt p = 0; p <
static_cast<UInt> ( M_comm->NumProc() ); p++ )
1266 pointGraph[ p ].resize ( pointGraphSize[ p ] );
1270 for ( UInt p = 0; p <
static_cast<UInt> ( M_comm->NumProc() ); p++ )
1272 M_comm->Broadcast ( &pointGraph[p][0], pointGraph[p].size(), p );
1275 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1279 std::vector<
int>
const& myPoints = pointGraph[ M_me ];
1281 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1282 M_debugOut <<
"own points on proc " << M_me << std::endl;
1283 for ( UInt i = 0; i < myPoints.size(); i++ )
1285 M_debugOut << myPoints[ i ] << std::endl;
1289 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1291 timeMgr.add (
"find SUBD_INT", &timeSI );
1295 std::vector<
bool> isInPartition ( M_fullMesh->numElements(),
false );
1296 for ( UInt e = 0; e < myElems.size(); e++ )
1298 isInPartition[ myElems[ e ] ] =
true;
1302 std::set<Int> mySubdIntPoints;
1303 for ( UInt k = 0; k < myPoints.size(); k++ )
1305 int const& currentPoint = myPoints[ k ];
1307 if ( pointPID[ currentPoint ] ==
static_cast<Int>(M_me) )
1310 for ( neighbors_Type::const_iterator neighborIt = M_pointElementNeighborsList[ currentPoint ].begin();
1311 neighborIt != M_pointElementNeighborsList[ currentPoint ].end(); ++neighborIt )
1314 if ( !isInPartition[ *neighborIt ] )
1316 mySubdIntPoints.insert ( currentPoint );
1322 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1326 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1327 M_debugOut <<
"own SUBDOMAIN_INTERFACE points on proc " << M_me << std::endl;
1328 for ( std::set<Int>::const_iterator i = mySubdIntPoints.begin(); i != mySubdIntPoints.end(); ++i )
1330 M_debugOut << *i << std::endl;
1334 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1336 timeMgr.add (
"overlapping points", &timeOP );
1340 std::vector<
int> workingPoints ( mySubdIntPoints.begin(), mySubdIntPoints.end() );
1341 std::set<
int> newPoints;
1342 std::set<
int> augmentedElemsSet ( myElems.begin(), myElems.end() );
1344 for (
UInt o = 0; o < overlap; o++ )
1347 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1348 M_debugOut <<
"workingPoints" << std::endl;
1349 for ( UInt i = 0; i < workingPoints.size(); i++ )
1351 M_debugOut << workingPoints[ i ] << std::endl;
1354 for ( UInt k = 0; k < workingPoints.size(); k++ )
1356 const int& currentPoint = workingPoints[ k ];
1358 for ( neighbors_Type::const_iterator neighborIt = M_pointElementNeighborsList[ currentPoint ].begin();
1359 neighborIt != M_pointElementNeighborsList[ currentPoint ].end(); ++neighborIt )
1361 std::pair<std::set<Int>::iterator,
bool> isInserted = augmentedElemsSet.insert ( *neighborIt );
1362 if ( isInserted.second )
1366 for ( UInt j = 0; j < mesh_Type::element_Type::S_numPoints; j++ )
1368 newPoints.insert ( M_fullMesh->element ( *neighborIt ).point ( j ).id() );
1374 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1375 M_debugOut <<
"augmentedElemsSet" << std::endl;
1376 for ( std::set<Int>::const_iterator i = augmentedElemsSet.begin(); i != augmentedElemsSet.end(); ++i )
1378 M_debugOut << *i << std::endl;
1382 for ( UInt k = 0; k < workingPoints.size(); k++ )
1384 newPoints.erase ( newPoints.find ( workingPoints[ k ] ) );
1387 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1388 M_debugOut <<
"newPoints" << std::endl;
1389 for ( std::set<
int>::const_iterator i = newPoints.begin(); i != newPoints.end(); ++i )
1391 M_debugOut << *i << std::endl;
1395 if ( o + 1 < overlap )
1397 workingPoints.assign ( newPoints.begin(), newPoints.end() );
1400 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1405 myElems.assign ( augmentedElemsSet.begin(), augmentedElemsSet.end() );
1407 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1412 template <
typename MeshType>
1420 std::cout <<
" GH- ghostMapOnElementsP1( graph )" << std::endl;
1423 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1424 LifeChronoManager<> timeMgr ( M_comm );
1426 timeMgr.add (
"node-element ngbr list", &timeNL );
1430 if ( M_pointElementNeighborsList.empty() )
1434 std::cerr <<
"the pointElementNeighborsList is empty, will be generated now" << std::endl;
1436 this->createPointElementNeighborsList();
1438 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1442 std::vector<
int>& myElems = * (elemGraph->at (partIndex) );
1444 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1446 M_debugOut <<
"own elements on proc " << partIndex << std::endl;
1447 for ( UInt i = 0; i < myElems.size(); i++ )
1449 M_debugOut << myElems[ i ] << std::endl;
1453 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1455 timeMgr.add (
"point graph", &timePG );
1460 Int numParts = elemGraph->size();
1463 std::set<
int> localPointsSet;
1464 for ( UInt e = 0; e < elemGraph->at (partIndex)->size(); e++ )
1467 for ( UInt k = 0; k < mesh_Type::element_Type::S_numPoints; k++ )
1469 const ID& pointID = M_fullMesh->element ( elemGraph->at (partIndex)->at (e) ).point ( k ).id();
1470 localPointsSet.insert ( pointID );
1473 pointGraph[ partIndex ].assign ( localPointsSet.begin(), localPointsSet.end() );
1475 std::vector<Int> pointGraphSize ( numParts, -1 );
1476 pointGraphSize[ partIndex ] = pointGraph[ partIndex ].size();
1477 if (M_comm->NumProc() > 1)
1479 for ( UInt p = 0; p <
static_cast<UInt> ( M_comm->NumProc() ); p++ )
1481 M_comm->Broadcast ( &pointGraphSize[ p ], 1, p );
1484 for ( UInt p = 0; p <
static_cast<UInt> ( M_comm->NumProc() ); p++ )
1486 pointGraph[ p ].resize ( pointGraphSize[ p ] );
1490 for ( UInt p = 0; p <
static_cast<UInt> ( M_comm->NumProc() ); p++ )
1492 M_comm->Broadcast ( &pointGraph[p][0], pointGraph[p].size(), p );
1496 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1500 std::vector<
int>
const& myPoints = pointGraph[ partIndex ];
1502 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1503 M_debugOut <<
"own points on proc " << partIndex << std::endl;
1504 for ( UInt i = 0; i < myPoints.size(); i++ )
1506 M_debugOut << myPoints[ i ] << std::endl;
1510 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1512 timeMgr.add (
"find SUBD_INT", &timeSI );
1516 std::vector<
bool> isInPartition ( M_fullMesh->numElements(),
false );
1517 for ( UInt e = 0; e < myElems.size(); e++ )
1519 isInPartition[ myElems[ e ] ] =
true;
1523 std::set<Int> mySubdIntPoints;
1524 for ( UInt k = 0; k < myPoints.size(); k++ )
1526 int const& currentPoint = myPoints[ k ];
1528 if ( pointPID[ currentPoint ] ==
static_cast<Int>(partIndex) )
1531 for ( neighbors_Type::const_iterator neighborIt = M_pointElementNeighborsList[ currentPoint ].begin();
1532 neighborIt != M_pointElementNeighborsList[ currentPoint ].end(); ++neighborIt )
1535 if ( !isInPartition[ *neighborIt ] )
1537 mySubdIntPoints.insert ( currentPoint );
1543 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1547 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1548 M_debugOut <<
"own SUBDOMAIN_INTERFACE points on proc " << partIndex << std::endl;
1549 for ( std::set<Int>::const_iterator i = mySubdIntPoints.begin(); i != mySubdIntPoints.end(); ++i )
1551 M_debugOut << *i << std::endl;
1555 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1557 timeMgr.add (
"overlapping points", &timeOP );
1561 std::vector<
int> workingPoints ( mySubdIntPoints.begin(), mySubdIntPoints.end() );
1562 std::set<
int> newPoints;
1563 std::set<
int> augmentedElemsSet ( myElems.begin(), myElems.end() );
1565 for (
UInt o = 0; o < overlap; o++ )
1568 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1569 M_debugOut <<
"workingPoints" << std::endl;
1570 for ( UInt i = 0; i < workingPoints.size(); i++ )
1572 M_debugOut << workingPoints[ i ] << std::endl;
1575 for ( UInt k = 0; k < workingPoints.size(); k++ )
1577 const int& currentPoint = workingPoints[ k ];
1579 for ( neighbors_Type::const_iterator neighborIt = M_pointElementNeighborsList[ currentPoint ].begin();
1580 neighborIt != M_pointElementNeighborsList[ currentPoint ].end(); ++neighborIt )
1582 std::pair<std::set<Int>::iterator,
bool> isInserted = augmentedElemsSet.insert ( *neighborIt );
1583 if ( isInserted.second )
1587 for ( UInt j = 0; j < mesh_Type::element_Type::S_numPoints; j++ )
1589 newPoints.insert ( M_fullMesh->element ( *neighborIt ).point ( j ).id() );
1595 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1596 M_debugOut <<
"augmentedElemsSet" << std::endl;
1597 for ( std::set<Int>::const_iterator i = augmentedElemsSet.begin(); i != augmentedElemsSet.end(); ++i )
1599 M_debugOut << *i << std::endl;
1603 for ( UInt k = 0; k < workingPoints.size(); k++ )
1605 newPoints.erase ( newPoints.find ( workingPoints[ k ] ) );
1608 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1609 M_debugOut <<
"newPoints" << std::endl;
1610 for ( std::set<
int>::const_iterator i = newPoints.begin(); i != newPoints.end(); ++i )
1612 M_debugOut << *i << std::endl;
1616 if ( o + 1 < overlap )
1618 workingPoints.assign ( newPoints.begin(), newPoints.end() );
1621 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1626 myElems.assign ( augmentedElemsSet.begin(), augmentedElemsSet.end() );
1628 #ifdef LIFEV_GHOSTHANDLER_DEBUG 1633 template <
typename MeshType>
1636 out <<
"GhostHandler::showMe()" << std::endl;
1637 out <<
"M_pointPointNeighborsMap" << std::endl;
1638 for ( UInt i = 0; i < M_pointPointNeighborsList.size(); i++ )
1641 for ( neighbors_Type::const_iterator nIt = M_pointPointNeighborsList[ i ].begin();
1642 nIt != M_pointPointNeighborsList[ i ].end(); ++nIt )
1648 out <<
"M_pointElementNeighborsMap" << std::endl;
1649 for ( UInt i = 0; i < M_pointPointNeighborsList.size(); i++ )
1652 for ( neighbors_Type::const_iterator nIt = M_pointPointNeighborsList[ i ].begin();
1653 nIt != M_pointPointNeighborsList[ i ].end(); ++nIt )
GhostHandler(meshPtr_Type fullMesh, commPtr_Type const &comm)
Constructor.
~GhostHandler()
Destructor.
void clean(NeighborType const neighborType=ALL_NEIGHBORS)
Clean up neighbor lists.
mapPtr_Type M_ghostMapOnElementsFV
std::vector< markerID_Type > markerIDList_Type
neighborList_Type M_pointEdgeNeighborsList
std::vector< Int > idList_Type
GhostHandler(meshPtr_Type fullMesh, meshPtr_Type localMesh, mapPtr_Type map, commPtr_Type const &comm)
Constructor.
NeighborType const RIDGE_NEIGHBORS
neighborList_Type const & pointElementNeighborsList()
List of element neighbors to a point (identified by the global ID)
commPtr_Type const M_comm
std::shared_ptr< comm_Type > commPtr_Type
neighbors_Type neighborsWithinRadius(UInt globalID, Real radius)
Create neighbors to a given point within a specified radius.
std::bitset< 4 > NeighborType
mapPtr_Type M_ghostMapOnElementsFE
void extendGraphFE(graphPtr_Type elemGraph, idList_Type const &pointPID, UInt overlap)
Extend the subdomains graph of the given overlap.
NeighborType const POINT_NEIGHBORS
neighborList_Type M_pointPointNeighborsList
void createPointEdgeNeighborsList()
Create the list of edge neighbors to the points.
std::shared_ptr< mesh_Type > meshPtr_Type
void setVerbose(const bool &verbose)
Set verbosity.
int32_type Int
Generic integer data.
ID markerID_Type
markerID_Type is the type used to store the geometric entity marker IDs
mapPtr_Type M_ghostMapOnPoints
void updateInverseJacobian(const UInt &iQuadPt)
void setMap(mapPtr_Type map, MapEpetraType mapType)
set the internal Epetra_Maps
void createPointNeighbors()
Create point neighbors to points and store them in the NeighborMarker.
void release()
Release pointers to full and local mesh.
std::vector< idList_Type > graph_Type
map_Type & ghostMapOnElementsFE(UInt overlap)
Create an overlapped map on elements for Finite Elements.
NeighborType const ALL_NEIGHBORS
neighbors_Type circleNeighbors(UInt globalID, UInt nCircles=1)
Create neighbors to a given point, with a specified number of generations.
Epetra_Import const & importer()
Getter for the Epetra_Import.
void createPointPointNeighborsList(markerIDListSigned_Type const &flags)
Create the list of point neighbors to points that are in the given list of MarkerIDs.
std::shared_ptr< idList_Type > idListPtr_Type
NeighborType const FACET_NEIGHBORS
std::vector< int > markerIDListSigned_Type
std::shared_ptr< graph_Type > graphPtr_Type
bool isInside(markerID_Type const &pointMarker, std::vector< int > const &markerIDList)
mesh_Type const & localMesh()
Local mesh getter.
std::shared_ptr< map_Type > mapPtr_Type
map_Type const & map()
Standard map getter.
std::shared_ptr< map_Type > mapPtr_Type
void setUpNeighbors(NeighborType const neighborType=ALL_NEIGHBORS)
Initialize neighbors list.
neighborList_Type const & pointPointNeighborsList()
List of point neighbors to a point (identified by the global ID)
double Real
Generic real data.
neighborList_Type const & pointEdgeNeighborsList()
List of edge neighbors to a point (identified by the global ID)
GhostHandler(commPtr_Type const &comm)
Constructor.
mesh_Type const & fullMesh()
Full mesh getter.
std::unordered_set< ID > neighbors_Type
void createPointElementNeighborsList()
Create the list of element neighbors to the points.
map_Type & ghostMapOnPoints(UInt overlap)
Create an overlapped map on points.
std::shared_ptr< vertexPartition_Type > vertexPartitionPtr_Type
void extendGraphFE(const vertexPartitionPtr_Type &elemGraph, idList_Type const &pointPID, UInt overlap, UInt partIndex)
Extend the subdomains graph of the given overlap.
map_Type & ghostMapOnEdges(UInt overlap)
Create an overlapped map on edges.
void setComm(commPtr_Type const &commPtr)
Set the communicator.
void showMe(bool const verbose=false, std::ostream &out=std::cout)
showMe method
void createPointPointNeighborsList()
Create the list of point neighbors to points.
mapPtr_Type M_ghostMapOnEdges
map_Type & ghostMapOnPoints()
Create an overlapped map on points.
std::vector< neighbors_Type > neighborList_Type
void importFromHDF5(std::string const &fileName="ghostmap")
Import neighbor lists to an hdf5 file.
NeighborType const ELEMENT_NEIGHBORS
neighborList_Type M_pointElementNeighborsList
uint32_type UInt
generic unsigned integer (used mainly for addressing)
std::vector< idListPtr_Type > vertexPartition_Type
map_Type & ghostMapOnElementsFV()
Create an overlapped map on elements for Finite Volumes.