mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
little mpi cleanup, meshing+distribution in one call
This commit is contained in:
parent
4dbf1d2099
commit
7791840a4a
@ -1326,11 +1326,14 @@ FlatArray<int> Ngx_Mesh :: GetDistantProcs (int nodetype, int locnum) const
|
|||||||
switch (nodetype)
|
switch (nodetype)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return mesh->GetParallelTopology().GetDistantPNums(locnum);
|
// return mesh->GetParallelTopology().GetDistantPNums(locnum);
|
||||||
|
return mesh->GetParallelTopology().GetDistantProcs(locnum+PointIndex::BASE);
|
||||||
case 1:
|
case 1:
|
||||||
return mesh->GetParallelTopology().GetDistantEdgeNums(locnum);
|
// return mesh->GetParallelTopology().GetDistantEdgeNums(locnum);
|
||||||
|
return mesh->GetParallelTopology().GetDistantEdgeProcs(locnum);
|
||||||
case 2:
|
case 2:
|
||||||
return mesh->GetParallelTopology().GetDistantFaceNums(locnum);
|
// return mesh->GetParallelTopology().GetDistantFaceNums(locnum);
|
||||||
|
return mesh->GetParallelTopology().GetDistantFaceProcs(locnum);
|
||||||
default:
|
default:
|
||||||
return FlatArray<int>(0, nullptr);
|
return FlatArray<int>(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -1191,6 +1191,7 @@ namespace netgen
|
|||||||
ostream & operator<< (ostream & s, const FaceDescriptor & fd);
|
ostream & operator<< (ostream & s, const FaceDescriptor & fd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EdgeDescriptor
|
class EdgeDescriptor
|
||||||
{
|
{
|
||||||
int tlosurf;
|
int tlosurf;
|
||||||
|
@ -76,18 +76,19 @@ namespace netgen
|
|||||||
|
|
||||||
[[deprecated("Use L2G(pi) instead!")]]
|
[[deprecated("Use L2G(pi) instead!")]]
|
||||||
void SetLoc2Glob_Vert (int locnum, int globnum) { glob_vert[locnum-1] = globnum; }
|
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; }
|
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; }
|
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; }
|
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; }
|
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; }
|
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!")]]
|
[[deprecated("Try to avoid global enumration!")]]
|
||||||
int GetGlobalEdgeNum (int locnum) const { return glob_edge[locnum-1]; }
|
int GetGlobalEdgeNum (int locnum) const { return glob_edge[locnum-1]; }
|
||||||
[[deprecated("Try to avoid global enumration!")]]
|
[[deprecated("Try to avoid global enumration!")]]
|
||||||
|
@ -247,7 +247,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
return res;
|
return res;
|
||||||
}, py::call_guard<py::gil_scoped_release>())
|
}, py::call_guard<py::gil_scoped_release>())
|
||||||
.def("GenerateMesh", [](shared_ptr<OCCGeometry> geo,
|
.def("GenerateMesh", [](shared_ptr<OCCGeometry> geo,
|
||||||
MeshingParameters* pars, py::kwargs kwargs)
|
MeshingParameters* pars, NgMPI_Comm comm, py::kwargs kwargs)
|
||||||
{
|
{
|
||||||
MeshingParameters mp;
|
MeshingParameters mp;
|
||||||
OCCParameters occparam;
|
OCCParameters occparam;
|
||||||
@ -264,14 +264,25 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
}
|
}
|
||||||
geo->SetOCCParameters(occparam);
|
geo->SetOCCParameters(occparam);
|
||||||
auto mesh = make_shared<Mesh>();
|
auto mesh = make_shared<Mesh>();
|
||||||
|
mesh->SetCommunicator(comm);
|
||||||
mesh->SetGeometry(geo);
|
mesh->SetGeometry(geo);
|
||||||
|
|
||||||
|
if (comm.Rank()==0)
|
||||||
|
{
|
||||||
SetGlobalMesh(mesh);
|
SetGlobalMesh(mesh);
|
||||||
auto result = geo->GenerateMesh(mesh, mp);
|
auto result = geo->GenerateMesh(mesh, mp);
|
||||||
if(result != 0)
|
if(result != 0)
|
||||||
throw Exception("Meshing failed!");
|
throw Exception("Meshing failed!");
|
||||||
ng_geometry = geo;
|
ng_geometry = geo;
|
||||||
|
if (comm.Size() > 1)
|
||||||
|
mesh->Distribute();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mesh->SendRecvMesh();
|
||||||
|
}
|
||||||
return mesh;
|
return mesh;
|
||||||
}, py::arg("mp") = nullptr,
|
}, py::arg("mp") = nullptr, py::arg("comm")=NgMPI_Comm{},
|
||||||
py::call_guard<py::gil_scoped_release>(),
|
py::call_guard<py::gil_scoped_release>(),
|
||||||
(meshingparameter_description + occparameter_description).c_str())
|
(meshingparameter_description + occparameter_description).c_str())
|
||||||
.def_property_readonly("shape", [](const OCCGeometry & self) { return self.GetShape(); })
|
.def_property_readonly("shape", [](const OCCGeometry & self) { return self.GetShape(); })
|
||||||
|
Loading…
Reference in New Issue
Block a user