@@ -367,35 +367,12 @@ CMultiGridGeometry::CMultiGridGeometry(CGeometry **geometry, CConfig *config_con
367367 }
368368
369369 nPointDomain = Index_CoarseCV;
370+ nPoint = nPointDomain;
370371
371- /* --- Check that there are no hanging nodes ---*/
372+ /* --- Check that there are no hanging nodes. Detect isolated points
373+ (only 1 neighbor), and merge their children CV's with the neighbor. ---*/
372374
373- /* --- Find the coarse neighbors of each coarse point. ---*/
374- {
375- /* --- Temporary, CPoint (nodes) then compresses this structure. ---*/
376- vector<vector<unsigned long > > points (fine_grid->GetnPoint ());
377-
378- for (auto iCoarsePoint = 0ul ; iCoarsePoint < nPointDomain; iCoarsePoint++) {
379- /* --- For each child CV (of the fine grid), ---*/
380- for (auto iChildren = 0u ; iChildren < nodes->GetnChildren_CV (iCoarsePoint); iChildren++) {
381- const auto iFinePoint = nodes->GetChildren_CV (iCoarsePoint, iChildren);
382- /* --- loop over the parent CVs (coarse grid) of its (fine) neighbors. ---*/
383- for (auto iFinePoint_Neighbor : fine_grid->nodes ->GetPoints (iFinePoint)) {
384- const auto iParent = fine_grid->nodes ->GetParent_CV (iFinePoint_Neighbor);
385- /* --- If it is not the target coarse point, it is a coarse neighbor. ---*/
386- if (iParent != iCoarsePoint) {
387- /* --- Avoid duplicates. ---*/
388- auto End = points[iCoarsePoint].end ();
389- if (find (points[iCoarsePoint].begin (), End, iParent) == End)
390- points[iCoarsePoint].push_back (iParent);
391- }
392- }
393- }
394- }
395- nodes->SetPoints (points);
396- }
397-
398- /* --- Detect isolated points and merge them with their correct neighbor. ---*/
375+ SetPoint_Connectivity (fine_grid);
399376
400377 for (auto iCoarsePoint = 0ul ; iCoarsePoint < nPointDomain; iCoarsePoint++) {
401378
@@ -516,9 +493,6 @@ CMultiGridGeometry::CMultiGridGeometry(CGeometry **geometry, CConfig *config_con
516493 /* --- Be careful, it is possible that a node changes the agglomeration configuration,
517494 the priority is always when receiving the information. ---*/
518495
519- assert (!fine_grid->nodes ->GetDomain (iPoint_Fine) && " Not a halo." );
520- assert (!fine_grid->nodes ->GetAgglomerate (iPoint_Fine) && " Already agglomerated." );
521-
522496 fine_grid->nodes ->SetParent_CV (iPoint_Fine, iPoint_Coarse);
523497 nodes->SetChildren_CV (iPoint_Coarse, nChildren_MPI[iPoint_Coarse], iPoint_Fine);
524498 nChildren_MPI[iPoint_Coarse]++;
@@ -794,35 +768,34 @@ void CMultiGridGeometry::SetSuitableNeighbors(vector<unsigned long>& Suitable_In
794768
795769}
796770
797- void CMultiGridGeometry::SetPoint_Connectivity (CGeometry *fine_grid) {
798-
799- unsigned long iFinePoint, iParent, iCoarsePoint;
800- unsigned short iChildren;
801-
802- /* --- Set the point surrounding a point ---*/
771+ void CMultiGridGeometry::SetPoint_Connectivity (const CGeometry *fine_grid) {
803772
773+ /* --- Temporary, CPoint (nodes) then compresses this structure. ---*/
804774 vector<vector<unsigned long > > points (nPoint);
805775
806- for (iCoarsePoint = 0 ; iCoarsePoint < nPoint; iCoarsePoint ++) {
807- for (iChildren = 0 ; iChildren < nodes->GetnChildren_CV (iCoarsePoint); iChildren ++) {
808- iFinePoint = nodes->GetChildren_CV (iCoarsePoint, iChildren);
776+ for (auto iCoarsePoint = 0ul ; iCoarsePoint < nPoint; iCoarsePoint++) {
777+ /* --- For each child CV (of the fine grid), ---*/
778+ for (auto iChildren = 0u ; iChildren < nodes->GetnChildren_CV (iCoarsePoint); iChildren++) {
779+ const auto iFinePoint = nodes->GetChildren_CV (iCoarsePoint, iChildren);
780+ /* --- loop over the parent CVs (coarse grid) of its (fine) neighbors. ---*/
809781 for (auto iFinePoint_Neighbor : fine_grid->nodes ->GetPoints (iFinePoint)) {
810- iParent = fine_grid->nodes ->GetParent_CV (iFinePoint_Neighbor);
782+ const auto iParent = fine_grid->nodes ->GetParent_CV (iFinePoint_Neighbor);
783+ /* --- If it is not the target coarse point, it is a coarse neighbor. ---*/
811784 if (iParent != iCoarsePoint) {
785+ /* --- Avoid duplicates. ---*/
812786 auto End = points[iCoarsePoint].end ();
813787 if (find (points[iCoarsePoint].begin (), End, iParent) == End)
814788 points[iCoarsePoint].push_back (iParent);
815789 }
816790 }
817791 }
818- }
819- nodes->SetPoints (points);
820792
821- /* --- Set the number of neighbors variable, this is
822- important for JST and multigrid in parallel ---*/
793+ /* --- Set the number of neighbors variable, this is
794+ important for JST and multigrid in parallel ---*/
795+ nodes->SetnNeighbor (iCoarsePoint, points[iCoarsePoint].size ());
796+ }
823797
824- for (iCoarsePoint = 0 ; iCoarsePoint < nPoint; iCoarsePoint ++)
825- nodes->SetnNeighbor (iCoarsePoint, nodes->GetnPoint (iCoarsePoint));
798+ nodes->SetPoints (points);
826799
827800}
828801
0 commit comments