mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
handle 2 ranks case
This commit is contained in:
parent
8a165ef8f1
commit
9500f8d8f2
@ -1073,29 +1073,45 @@ namespace netgen
|
||||
Array<idx_t> epart(ne), npart(nn);
|
||||
|
||||
idxtype nparts = MyMPI_GetNTasks(GetCommunicator())-1;
|
||||
idxtype edgecut;
|
||||
|
||||
idxtype ncommon = 3;
|
||||
METIS_PartMeshDual (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &ncommon, &nparts,
|
||||
NULL, NULL,
|
||||
&edgecut, &epart[0], &npart[0]);
|
||||
|
||||
/*
|
||||
METIS_PartMeshNodal (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &nparts,
|
||||
NULL, NULL,
|
||||
&edgecut, &epart[0], &npart[0]);
|
||||
*/
|
||||
PrintMessage (3, "metis complete");
|
||||
// cout << "done" << endl;
|
||||
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(epart[i] + 1);
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
|
||||
if (nparts == 1)
|
||||
{
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(1);
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(1);
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(1);
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
idxtype edgecut;
|
||||
|
||||
idxtype ncommon = 3;
|
||||
METIS_PartMeshDual (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &ncommon, &nparts,
|
||||
NULL, NULL,
|
||||
&edgecut, &epart[0], &npart[0]);
|
||||
|
||||
/*
|
||||
METIS_PartMeshNodal (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &nparts,
|
||||
NULL, NULL,
|
||||
&edgecut, &epart[0], &npart[0]);
|
||||
*/
|
||||
PrintMessage (3, "metis complete");
|
||||
// cout << "done" << endl;
|
||||
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(epart[i] + 1);
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
|
||||
}
|
||||
|
||||
|
||||
// surface elements attached to volume elements
|
||||
Array<bool, PointIndex::BASE> boundarypoints (GetNP());
|
||||
boundarypoints = false;
|
||||
@ -1370,6 +1386,19 @@ namespace netgen
|
||||
Array<idx_t> epart(ne), npart(nn);
|
||||
|
||||
idxtype nparts = MyMPI_GetNTasks(GetCommunicator())-1;
|
||||
|
||||
if (nparts == 1)
|
||||
{
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(1);
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(1);
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
idxtype edgecut;
|
||||
|
||||
|
||||
|
@ -525,8 +525,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
MPI_Comm comm = pycomm!=nullptr ? pycomm->comm : self->GetCommunicator();
|
||||
self->SetCommunicator(comm);
|
||||
if(MyMPI_GetNTasks(comm)==1) return self;
|
||||
if(MyMPI_GetNTasks(comm)==2) throw NgException("Sorry, cannot handle communicators with NP=2!");
|
||||
cout << " rank " << MyMPI_GetId(comm) << " of " << MyMPI_GetNTasks(comm) << " called Distribute " << endl;
|
||||
// if(MyMPI_GetNTasks(comm)==2) throw NgException("Sorry, cannot handle communicators with NP=2!");
|
||||
// cout << " rank " << MyMPI_GetId(comm) << " of " << MyMPI_GetNTasks(comm) << " called Distribute " << endl;
|
||||
if(MyMPI_GetId(comm)==0) self->Distribute();
|
||||
else self->SendRecvMesh();
|
||||
return self;
|
||||
|
Loading…
Reference in New Issue
Block a user