separat metis-partitioning call, pickling partition number of mesh elements

This commit is contained in:
Joachim Schoeberl 2021-06-08 13:48:27 +02:00
parent ca6d6e8ca7
commit aa3f778d06
5 changed files with 26 additions and 5 deletions

View File

@ -1528,6 +1528,16 @@ namespace netgen
archive & *ident; archive & *ident;
// cout << "archive, ngsversion = " << archive.GetVersion("netgen") << endl;
if(archive.GetVersion("netgen") >= "v6.2.2103-1")
{
// cout << "do the partition" << endl;
archive.NeedsVersion("netgen", "v6.2.2103-1");
archive & vol_partition & surf_partition & seg_partition;
}
// else
// cout << "no partition" << endl;
archive.Shallow(geometry); archive.Shallow(geometry);
archive & *curvedelems; archive & *curvedelems;

View File

@ -900,7 +900,7 @@ namespace netgen
// void FindExchangeFaces (); // void FindExchangeFaces ();
/// use metis to decompose master mesh /// use metis to decompose master mesh
void ParallelMetis (); // NgArray<int> & neloc ); void ParallelMetis (int nproc); // NgArray<int> & neloc );
void ParallelMetis (NgArray<int> & volume_weights, NgArray<int> & surface_weights, void ParallelMetis (NgArray<int> & volume_weights, NgArray<int> & surface_weights,
NgArray<int> & segment_weights); NgArray<int> & segment_weights);

View File

@ -1250,7 +1250,9 @@ namespace netgen
if (id != 0 || ntasks == 1 ) return; if (id != 0 || ntasks == 1 ) return;
#ifdef METIS #ifdef METIS
ParallelMetis (); if (vol_partition.Size() < GetNE() || surf_partition.Size() < GetNSE() ||
seg_partition.Size() < GetNSeg())
ParallelMetis (comm.Size());
#else #else
for (ElementIndex ei = 0; ei < GetNE(); ei++) for (ElementIndex ei = 0; ei < GetNE(); ei++)
(*this)[ei].SetPartition(ntasks * ei/GetNE() + 1); (*this)[ei].SetPartition(ntasks * ei/GetNE() + 1);
@ -1269,7 +1271,7 @@ namespace netgen
#ifdef METIS5 #ifdef METIS5
void Mesh :: ParallelMetis ( ) void Mesh :: ParallelMetis (int nproc)
{ {
PrintMessage (3, "call metis 5 ..."); PrintMessage (3, "call metis 5 ...");
@ -1304,7 +1306,7 @@ namespace netgen
eptr.Append (eind.Size()); eptr.Append (eind.Size());
NgArray<idx_t> epart(ne), npart(nn); NgArray<idx_t> epart(ne), npart(nn);
idxtype nparts = GetCommunicator().Size()-1; idxtype nparts = nproc-1; // GetCommunicator().Size()-1;
vol_partition.SetSize(GetNE()); vol_partition.SetSize(GetNE());
surf_partition.SetSize(GetNSE()); surf_partition.SetSize(GetNSE());
@ -1329,9 +1331,14 @@ namespace netgen
idxtype edgecut; idxtype edgecut;
idxtype ncommon = 3; idxtype ncommon = 3;
PrintMessage (3, "metis start");
static Timer tm("metis library");
tm.Start();
METIS_PartMeshDual (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &ncommon, &nparts, METIS_PartMeshDual (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &ncommon, &nparts,
NULL, NULL, NULL, NULL,
&edgecut, &epart[0], &npart[0]); &edgecut, &epart[0], &npart[0]);
tm.Stop();
/* /*
METIS_PartMeshNodal (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &nparts, METIS_PartMeshNodal (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &nparts,

View File

@ -644,6 +644,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
.def_property_readonly("_timestamp", &Mesh::GetTimeStamp) .def_property_readonly("_timestamp", &Mesh::GetTimeStamp)
.def_property_readonly("ne", [](Mesh& m) { return m.GetNE(); }) .def_property_readonly("ne", [](Mesh& m) { return m.GetNE(); })
.def("Partition", [](shared_ptr<Mesh> self, int numproc) {
self->ParallelMetis(numproc);
}, py::arg("numproc"))
.def("Distribute", [](shared_ptr<Mesh> self, NgMPI_Comm comm) { .def("Distribute", [](shared_ptr<Mesh> self, NgMPI_Comm comm) {
self->SetCommunicator(comm); self->SetCommunicator(comm);
if(comm.Size()==1) return self; if(comm.Size()==1) return self;

View File

@ -2383,7 +2383,7 @@ namespace netgen
int nparts = atoi (argv[1]); int nparts = atoi (argv[1]);
ntasks = nparts+1; ntasks = nparts+1;
cout << "calling metis ... " << flush; cout << "calling metis ... " << flush;
mesh->ParallelMetis(); mesh->ParallelMetis(ntasks);
cout << "done" << endl; cout << "done" << endl;
ntasks = 1; ntasks = 1;