From 304ce7364a65d5844a58ffee1c59617f55176d5b Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sun, 14 Jul 2024 20:38:36 +0200 Subject: [PATCH] mpi-send of 0D-elements --- libsrc/meshing/meshclass.cpp | 27 +++++++++++++++++++++++++++ libsrc/meshing/meshtype.cpp | 29 +++++++++++++++++++++++++++++ libsrc/meshing/meshtype.hpp | 10 +++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 85106adb..287066cd 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -1810,6 +1810,33 @@ namespace netgen archive & copy_el1d; } + + // sending 0D elements + auto copy_el0d (pointelements); + for (auto & el : copy_el0d) + { + auto & pi = el.pnum; + if (pi != PointIndex(PointIndex::INVALID)) + pi = globnum[pi]; + } + + if (comm.Rank() > 0) + comm.Send(copy_el0d, 0, 200); + else + { + Array el0di; + for (int j = 1; j < comm.Size(); j++) + { + comm.Recv(el0di, j, 200); + for (auto & el : el0di) + copy_el0d += el; + } + archive & copy_el0d; + } + + + + if (comm.Rank() == 0) { archive & facedecoding; diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index f5dcfbe1..87c63384 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -144,6 +144,35 @@ namespace netgen #endif +#ifdef PARALLEL + NG_MPI_Datatype Element0d :: MyGetMPIType() + { + static NG_MPI_Datatype type = NG_MPI_DATATYPE_NULL; + static NG_MPI_Datatype htype = NG_MPI_DATATYPE_NULL; + if (type == NG_MPI_DATATYPE_NULL) + { + Element0d hel; + int blocklen[] = { 1, 1 }; + NG_MPI_Aint displ[] = + { (char*)&hel.pnum - (char*)&hel, + (char*)&hel.index - (char*)&hel, + }; + NG_MPI_Datatype types[] = { + GetMPIType(hel.pnum), GetMPIType(hel.index) + }; + NG_MPI_Type_create_struct (2, blocklen, displ, types, &htype); + NG_MPI_Type_commit ( &htype ); + NG_MPI_Aint lb, ext; + NG_MPI_Type_get_extent (htype, &lb, &ext); + // *testout << "lb = " << lb << endl; + // *testout << "ext = " << ext << endl; + ext = sizeof (Element0d); + NG_MPI_Type_create_resized (htype, lb, ext, &type); + NG_MPI_Type_commit ( &type ); + } + return type; + } +#endif void Element0d :: DoArchive (Archive & ar) { diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index bf044082..5186572d 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1163,7 +1163,12 @@ namespace netgen int index; Element0d () = default; Element0d (PointIndex _pnum, int _index) - : pnum(_pnum), index(_index) { ; } + : pnum(_pnum), index(_index) { ; } + +#ifdef PARALLEL + static NG_MPI_Datatype MyGetMPIType(); +#endif + void DoArchive (Archive & ar); }; @@ -1672,6 +1677,9 @@ namespace ngcore template <> struct MPI_typetrait { static NG_MPI_Datatype MPIType () { return netgen::Segment::MyGetMPIType(); } }; + template <> struct MPI_typetrait { + static NG_MPI_Datatype MPIType () { return netgen::Element0d::MyGetMPIType(); } + }; } #endif