mpi-send of 0D-elements

This commit is contained in:
Joachim Schoeberl 2024-07-14 20:38:36 +02:00
parent f1e06f0a6d
commit 304ce7364a
3 changed files with 65 additions and 1 deletions

View File

@ -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<Element0d> 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;

View File

@ -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)
{

View File

@ -1164,6 +1164,11 @@ namespace netgen
Element0d () = default;
Element0d (PointIndex _pnum, int _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<netgen::Segment> {
static NG_MPI_Datatype MPIType () { return netgen::Segment::MyGetMPIType(); }
};
template <> struct MPI_typetrait<netgen::Element0d> {
static NG_MPI_Datatype MPIType () { return netgen::Element0d::MyGetMPIType(); }
};
}
#endif