little mpi cleanup, meshing+distribution in one call

This commit is contained in:
Joachim Schoeberl 2022-03-15 09:13:01 +01:00
parent 4dbf1d2099
commit 7791840a4a
4 changed files with 32 additions and 16 deletions

View File

@ -1326,11 +1326,14 @@ FlatArray<int> Ngx_Mesh :: GetDistantProcs (int nodetype, int locnum) const
switch (nodetype)
{
case 0:
return mesh->GetParallelTopology().GetDistantPNums(locnum);
// return mesh->GetParallelTopology().GetDistantPNums(locnum);
return mesh->GetParallelTopology().GetDistantProcs(locnum+PointIndex::BASE);
case 1:
return mesh->GetParallelTopology().GetDistantEdgeNums(locnum);
// return mesh->GetParallelTopology().GetDistantEdgeNums(locnum);
return mesh->GetParallelTopology().GetDistantEdgeProcs(locnum);
case 2:
return mesh->GetParallelTopology().GetDistantFaceNums(locnum);
// return mesh->GetParallelTopology().GetDistantFaceNums(locnum);
return mesh->GetParallelTopology().GetDistantFaceProcs(locnum);
default:
return FlatArray<int>(0, nullptr);
}

View File

@ -1190,6 +1190,7 @@ namespace netgen
ostream & operator<< (ostream & s, const FaceDescriptor & fd);
class EdgeDescriptor
{

View File

@ -76,18 +76,19 @@ namespace netgen
[[deprecated("Use L2G(pi) instead!")]]
void SetLoc2Glob_Vert (int locnum, int globnum) { glob_vert[locnum-1] = globnum; }
[[deprecated("Try to avoid global enumration!")]]
// [[deprecated("Try to avoid global enumration!")]]
void SetLoc2Glob_Edge (int locnum, int globnum) { glob_edge[locnum-1] = globnum; }
[[deprecated("Try to avoid global enumration!")]]
// [[deprecated("Try to avoid global enumration!")]]
void SetLoc2Glob_Face (int locnum, int globnum) { glob_face[locnum-1] = globnum; }
[[deprecated("Try to avoid global enumration!")]]
// [[deprecated("Try to avoid global enumration!")]]
void SetLoc2Glob_VolEl (int locnum, int globnum) { glob_el[locnum-1] = globnum; }
[[deprecated("Try to avoid global enumration!")]]
// [[deprecated("Try to avoid global enumration!")]]
void SetLoc2Glob_SurfEl (int locnum, int globnum) { glob_surfel[locnum-1] = globnum; }
[[deprecated("Try to avoid global enumration!")]]
// [[deprecated("Try to avoid global enumration!")]]
void SetLoc2Glob_Segm (int locnum, int globnum) { glob_segm[locnum-1] = globnum; }
int GetGlobalPNum (int locnum) const { return glob_vert[locnum-1]; }
// [[deprecated("Try to avoid global enumration!")]]
int GetGlobalPNum (PointIndex locnum) const { return glob_vert[locnum-PointIndex::BASE]; }
[[deprecated("Try to avoid global enumration!")]]
int GetGlobalEdgeNum (int locnum) const { return glob_edge[locnum-1]; }
[[deprecated("Try to avoid global enumration!")]]

View File

@ -247,7 +247,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
return res;
}, py::call_guard<py::gil_scoped_release>())
.def("GenerateMesh", [](shared_ptr<OCCGeometry> geo,
MeshingParameters* pars, py::kwargs kwargs)
MeshingParameters* pars, NgMPI_Comm comm, py::kwargs kwargs)
{
MeshingParameters mp;
OCCParameters occparam;
@ -264,14 +264,25 @@ DLL_HEADER void ExportNgOCC(py::module &m)
}
geo->SetOCCParameters(occparam);
auto mesh = make_shared<Mesh>();
mesh->SetCommunicator(comm);
mesh->SetGeometry(geo);
SetGlobalMesh(mesh);
auto result = geo->GenerateMesh(mesh, mp);
if(result != 0)
throw Exception("Meshing failed!");
ng_geometry = geo;
if (comm.Rank()==0)
{
SetGlobalMesh(mesh);
auto result = geo->GenerateMesh(mesh, mp);
if(result != 0)
throw Exception("Meshing failed!");
ng_geometry = geo;
if (comm.Size() > 1)
mesh->Distribute();
}
else
{
mesh->SendRecvMesh();
}
return mesh;
}, py::arg("mp") = nullptr,
}, py::arg("mp") = nullptr, py::arg("comm")=NgMPI_Comm{},
py::call_guard<py::gil_scoped_release>(),
(meshingparameter_description + occparameter_description).c_str())
.def_property_readonly("shape", [](const OCCGeometry & self) { return self.GetShape(); })