From 0fe20c9deee3fec0e3ed0129a9ac87ef8552123c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Sat, 29 Aug 2020 20:56:29 +0200 Subject: [PATCH] set ParallelTop functions --- libsrc/meshing/curvedelems.cpp | 20 ++++++------ libsrc/meshing/parallelmesh.cpp | 12 ++++--- libsrc/meshing/paralleltop.cpp | 20 +++++++++--- libsrc/meshing/paralleltop.hpp | 55 ++++++++++++++++++++++++--------- 4 files changed, 74 insertions(+), 33 deletions(-) diff --git a/libsrc/meshing/curvedelems.cpp b/libsrc/meshing/curvedelems.cpp index 43628d3e..91f3c473 100644 --- a/libsrc/meshing/curvedelems.cpp +++ b/libsrc/meshing/curvedelems.cpp @@ -645,10 +645,10 @@ namespace netgen if (ntasks > 1 && working) { for (int e = 0; e < edgeorder.Size(); e++) - for (int proc : partop.GetDistantEdgeNums(e)) + for (int proc : partop.GetDistantEdgeProcs(e)) send_orders.Add (proc, edgeorder[e]); for (int f = 0; f < faceorder.Size(); f++) - for (int proc : partop.GetDistantFaceNums(f)) + for (int proc : partop.GetDistantFaceProcs(f)) send_orders.Add (proc, faceorder[f]); } @@ -660,10 +660,10 @@ namespace netgen NgArray cnt(ntasks); cnt = 0; for (int e = 0; e < edgeorder.Size(); e++) - for (auto proc : partop.GetDistantEdgeNums(e)) + for (auto proc : partop.GetDistantEdgeProcs(e)) edgeorder[e] = max(edgeorder[e], recv_orders[proc][cnt[proc]++]); for (int f = 0; f < faceorder.Size(); f++) - for (auto proc : partop.GetDistantFaceNums(f)) + for (auto proc : partop.GetDistantFaceProcs(f)) faceorder[f] = max(faceorder[f], recv_orders[proc][cnt[proc]++]); } #endif @@ -751,7 +751,7 @@ namespace netgen TABLE senddata(ntasks), recvdata(ntasks); if (working) for (int e = 0; e < nedges; e++) - for (int proc : partop.GetDistantEdgeNums(e)) + for (int proc : partop.GetDistantEdgeProcs(e)) { senddata.Add (proc, surfnr[e]); if (surfnr[e] != -1) @@ -771,7 +771,7 @@ namespace netgen cnt = 0; if (working) for (int e = 0; e < nedges; e++) - for (int proc : partop.GetDistantEdgeNums(e)) + for (int proc : partop.GetDistantEdgeProcs(e)) { int surfnr1 = recvdata[proc][cnt[proc]++]; if (surfnr1 != -1) @@ -946,7 +946,7 @@ namespace netgen TABLE senddata(ntasks), recvdata(ntasks); if (working) for (int e = 0; e < nedges; e++) - for (int proc : partop.GetDistantEdgeNums(e)) + for (int proc : partop.GetDistantEdgeProcs(e)) { senddata.Add (proc, use_edge[e]); if (use_edge[e]) @@ -972,7 +972,7 @@ namespace netgen cnt = 0; if (working) for (int e = 0; e < edge_surfnr1.Size(); e++) - for (int proc : partop.GetDistantEdgeNums(e)) + for (int proc : partop.GetDistantEdgeProcs(e)) { int get_edge = int(recvdata[proc][cnt[proc]++]); if (get_edge) @@ -1148,7 +1148,7 @@ namespace netgen if (ntasks > 1 && working) { for (int f = 0; f < nfaces; f++) - for (int proc : partop.GetDistantFaceNums(f)) + for (int proc : partop.GetDistantFaceProcs(f)) send_surfnr.Add (proc, surfnr[f]); } @@ -1160,7 +1160,7 @@ namespace netgen NgArray cnt(ntasks); cnt = 0; for (int f = 0; f < nfaces; f++) - for (int proc : partop.GetDistantFaceNums(f)) + for (int proc : partop.GetDistantFaceProcs(f)) surfnr[f] = max(surfnr[f], recv_surfnr[proc][cnt[proc]++]); } #endif diff --git a/libsrc/meshing/parallelmesh.cpp b/libsrc/meshing/parallelmesh.cpp index 62f482c1..8f060a1b 100644 --- a/libsrc/meshing/parallelmesh.cpp +++ b/libsrc/meshing/parallelmesh.cpp @@ -278,7 +278,8 @@ namespace netgen vert_flag[vertex] = dest; num_verts_on_proc[dest]++; num_procs_on_vert[vertex]++; - GetParallelTopology().SetDistantPNum (dest, vertex); + // GetParallelTopology().SetDistantPNum (dest, vertex); + GetParallelTopology().AddDistantProc (PointIndex(vertex), dest); } }; countit(vertex, dest); @@ -870,7 +871,8 @@ namespace netgen for (int vert = 0; vert < numvert; vert++) { int globvert = verts[vert] + IndexBASE(); - paralleltop->SetLoc2Glob_Vert ( vert+1, globvert ); + // paralleltop->SetLoc2Glob_Vert ( vert+1, globvert ); + paralleltop->L2G (PointIndex(vert+PointIndex::BASE)) = globvert; glob2loc_vert_ht.Set (globvert, vert+1); } @@ -902,16 +904,18 @@ namespace netgen } } - Array dist_pnums; + Array dist_pnums; comm.Recv (dist_pnums, 0, MPI_TAG_MESH+1); for (int hi = 0; hi < dist_pnums.Size(); hi += 3) paralleltop -> - SetDistantPNum (dist_pnums[hi+1], dist_pnums[hi]); // , dist_pnums[hi+2]); + // SetDistantPNum (dist_pnums[hi+1], dist_pnums[hi]); // , dist_pnums[hi+2]); + AddDistantProc (PointIndex(dist_pnums[hi]), dist_pnums[hi+1]); NgProfiler::StopTimer (timer_pts); *testout << "got " << numvert << " vertices" << endl; + { Array elarray; comm.Recv (elarray, 0, MPI_TAG_MESH+2); diff --git a/libsrc/meshing/paralleltop.cpp b/libsrc/meshing/paralleltop.cpp index 5cf4044a..08698e5d 100644 --- a/libsrc/meshing/paralleltop.cpp +++ b/libsrc/meshing/paralleltop.cpp @@ -211,12 +211,18 @@ namespace netgen // *testout << "l " << i << " globi "<< glob_vert[i] << " dist = " << loc2distvert[i] << endl; } + /* for (size_t i = 0; i+1 < glob_vert.Size(); i++) if (glob_vert[i] > glob_vert[i+1]) cout << "wrong ordering of globvert" << endl; + */ + if (glob_vert.Size() > 1) + for (auto i : Range(glob_vert).Modify(0,-1)) + if (glob_vert[i] > glob_vert[i+1]) + cout << "wrong ordering of globvert" << endl; } - + /* void ParallelMeshTopology :: SetDistantFaceNum (int dest, int locnum) { for ( int i = 0; i < loc2distface[locnum-1].Size(); i+=1 ) @@ -241,7 +247,8 @@ namespace netgen return; loc2distedge.Add (locnum-1, dest); } - + */ + void ParallelMeshTopology :: SetNV_Loc2Glob (int anv) { glob_vert.SetSize(anv); @@ -379,6 +386,7 @@ namespace netgen is_updated = true; } + void ParallelMeshTopology :: IdentifyVerticesAfterRefinement() { static Timer t("ParallelTopology::UpdateCoarseGrid"); RegionTimer r(t); @@ -511,7 +519,8 @@ namespace netgen // if (es == re && !IsExchangeVert(dest, pi)) if (es == re && !GetDistantProcs(pi).Contains(dest)) { - SetDistantPNum(dest, pi); + // SetDistantPNum(dest, pi); + AddDistantProc (pi, dest); changed = true; } } @@ -694,7 +703,8 @@ namespace netgen INDEX_2 re(ex2loc[recvarray[ii]], ex2loc[recvarray[ii+1]]); if (vert2edge.Used(re)) - SetDistantEdgeNum(dest, vert2edge.Get(re)); + // SetDistantEdgeNum(dest, vert2edge.Get(re)); + AddDistantEdgeProc(vert2edge.Get(re)-1, dest); } } @@ -799,7 +809,7 @@ namespace netgen ex2loc[recvarray[ii+1]], ex2loc[recvarray[ii+2]]); if (vert2face.Used(re)) - SetDistantFaceNum(dest, vert2face.Get(re)); + AddDistantFaceProc(vert2face.Get(re)-1, dest); } } diff --git a/libsrc/meshing/paralleltop.hpp b/libsrc/meshing/paralleltop.hpp index 90befebe..f6826328 100644 --- a/libsrc/meshing/paralleltop.hpp +++ b/libsrc/meshing/paralleltop.hpp @@ -16,9 +16,11 @@ namespace netgen */ DynamicTable loc2distvert; - TABLE loc2distedge, loc2distface; + DynamicTable loc2distedge, loc2distface; Array glob_vert; + + // will get rid of them NgArray glob_edge, glob_face; NgArray glob_el, glob_surfel, glob_segm; @@ -35,9 +37,21 @@ namespace netgen void UpdateCoarseGrid(); void UpdateCoarseGridGlobal(); void IdentifyVerticesAfterRefinement(); - // bool DoCoarseUpdate() const { return !coarseupdate; } + void EnumeratePointsGlobally (); + + void AddDistantProc (PointIndex pi, int proc) { loc2distvert.AddUnique (pi-PointIndex::BASE, proc); } + void AddDistantFaceProc (int edge, int proc) { loc2distface.AddUnique (edge, proc); } + void AddDistantEdgeProc (int face, int proc) { loc2distedge.AddUnique (face, proc); } + + FlatArray GetDistantProcs (PointIndex pi) const { return loc2distvert[pi-PointIndex::BASE]; } + FlatArray GetDistantFaceProcs (int locnum) const { return loc2distface[locnum]; } + FlatArray GetDistantEdgeProcs (int locnum) const { return loc2distedge[locnum]; } + + auto & L2G (PointIndex pi) { return glob_vert[pi-PointIndex::BASE]; } + auto L2G (PointIndex pi) const { return glob_vert[pi-PointIndex::BASE]; } + /// set number of local vertices, reset sizes of loc2dist_vert, isexchangevert... void SetNV (int anv); @@ -46,6 +60,21 @@ namespace netgen void SetNSE (int anse); void SetNSegm (int anseg); + [[deprecated("Use AddDistantFaceProc instead!")]] + void SetDistantFaceNum (int dest, int locnum) { loc2distface.AddUnique (locnum-1, dest); } + [[deprecated("Use AddDistantProc instead!")]] + void SetDistantPNum (int dest, int locnum) { loc2distvert.AddUnique (locnum-1, dest); } + [[deprecated("Use AddDistantEdgeProc instead!")]] + void SetDistantEdgeNum (int dest, int locnum) { loc2distedge.AddUnique (locnum-1, dest); } + + [[deprecated("Use GetDistantFaceProcx instead!")]] + FlatArray GetDistantFaceNums (int locnum) const { return loc2distface[locnum]; } + [[deprecated("Use GetDistantEdgeProcx instead!")]] + FlatArray GetDistantEdgeNums (int locnum) const { return loc2distedge[locnum]; } + + + + [[deprecated("Use L2G(pi) instead!")]] void SetLoc2Glob_Vert (int locnum, int globnum) { glob_vert[locnum-1] = globnum; } [[deprecated("Try to avoid global enumration!")]] void SetLoc2Glob_Edge (int locnum, int globnum) { glob_edge[locnum-1] = globnum; } @@ -68,12 +97,7 @@ namespace netgen [[deprecated("Try to avoid global enumration!")]] int GetGlobalSElNum (int locnum) const { return glob_surfel[locnum-1]; } - - void EnumeratePointsGlobally (); - void SetDistantFaceNum (int dest, int locnum); - void SetDistantPNum (int dest, int locnum); - void SetDistantEdgeNum (int dest, int locnum); [[deprecated("Use GetDistantPNums(locnum).Size() instead!")]] int GetNDistantPNums (int locpnum) const { return loc2distvert[locpnum-1].Size(); } @@ -101,7 +125,11 @@ namespace netgen [[deprecated("Use GetDistantFaceNums(locnum) -> FlatArray instead!")]] void GetDistantFaceNums (int locfacenum, NgArray & distfacenums ) const { - distfacenums = loc2distface[locfacenum-1]; + // distfacenums = loc2distface[locfacenum-1]; + auto loc = loc2distface[locfacenum-1]; + distfacenums.SetSize (loc.Size()); + for (int i = 0; i < loc.Size(); i++) + distfacenums[i] = loc[i]; } [[deprecated("Use GetDistantEdgeNums(locnum) -> FlatArray instead!")]] @@ -114,17 +142,16 @@ namespace netgen [[deprecated("Use GetDistantEdgeNums(locnum) -> FlatArray instead!")]] void GetDistantEdgeNums (int locedgenum, NgArray & distedgenums ) const { - distedgenums = loc2distedge[locedgenum-1]; + // distedgenums = loc2distedge[locedgenum-1]; + auto loc = loc2distedge[locedgenum-1]; + distedgenums.SetSize (loc.Size()); + for (int i = 0; i < loc.Size(); i++) + distedgenums[i] = loc[i]; } [[deprecated("Use GetDistantProcs(..)!")]] FlatArray GetDistantPNums (int locnum) const { return loc2distvert[locnum]; } - FlatArray GetDistantFaceNums (int locnum) const { return loc2distface[locnum]; } - FlatArray GetDistantEdgeNums (int locnum) const { return loc2distedge[locnum]; } - FlatArray GetDistantProcs (PointIndex pi) const { return loc2distvert[pi-PointIndex::BASE]; } - auto & L2G (PointIndex pi) { return glob_vert[pi-PointIndex::BASE]; } - auto L2G (PointIndex pi) const { return glob_vert[pi-PointIndex::BASE]; } [[deprecated("Use GetDistantProcs(..).Contains instead!")]]