mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 22:20:35 +05:00
release GIL in expensive functions
This commit is contained in:
parent
8107052e79
commit
96f9e01aba
@ -642,7 +642,7 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails!
|
|||||||
cout << "Caught NgException: " << ex.What() << endl;
|
cout << "Caught NgException: " << ex.What() << endl;
|
||||||
}
|
}
|
||||||
return dummy;
|
return dummy;
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
;
|
;
|
||||||
|
|
||||||
m.def("Save", FunctionPointer
|
m.def("Save", FunctionPointer
|
||||||
@ -658,7 +658,7 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails!
|
|||||||
*outfile << endl << endl << "endmesh" << endl << endl;
|
*outfile << endl << endl << "endmesh" << endl << endl;
|
||||||
geom.SaveToMeshFile (*outfile);
|
geom.SaveToMeshFile (*outfile);
|
||||||
delete outfile;
|
delete outfile;
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -669,7 +669,7 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails!
|
|||||||
ZRefinementOptions opt;
|
ZRefinementOptions opt;
|
||||||
opt.minref = 5;
|
opt.minref = 5;
|
||||||
ZRefinement (mesh, &geom, opt);
|
ZRefinement (mesh, &geom, opt);
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,9 +540,9 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
ng_geometry = make_shared<NetgenGeometry>();
|
ng_geometry = make_shared<NetgenGeometry>();
|
||||||
self.SetGeometry(ng_geometry);
|
self.SetGeometry(ng_geometry);
|
||||||
delete infile;
|
delete infile;
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
// static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load))
|
// static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load))
|
||||||
.def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save))
|
.def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save),py::call_guard<py::gil_scoped_release>())
|
||||||
.def("Export",
|
.def("Export",
|
||||||
[] (Mesh & self, string filename, string format)
|
[] (Mesh & self, string filename, string format)
|
||||||
{
|
{
|
||||||
@ -557,7 +557,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
throw NgException (err);
|
throw NgException (err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
py::arg("filename"), py::arg("format"))
|
py::arg("filename"), py::arg("format"),py::call_guard<py::gil_scoped_release>())
|
||||||
|
|
||||||
.def_property("dim", &Mesh::GetDimension, &Mesh::SetDimension)
|
.def_property("dim", &Mesh::GetDimension, &Mesh::SetDimension)
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
.def ("Compress", FunctionPointer ([](Mesh & self)
|
.def ("Compress", FunctionPointer ([](Mesh & self)
|
||||||
{
|
{
|
||||||
return self.Compress ();
|
return self.Compress ();
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
|
|
||||||
|
|
||||||
.def ("SetBCName", &Mesh::SetBCName)
|
.def ("SetBCName", &Mesh::SetBCName)
|
||||||
@ -674,16 +674,19 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
cout << "generate vol mesh" << endl;
|
cout << "generate vol mesh" << endl;
|
||||||
|
|
||||||
MeshingParameters mp;
|
MeshingParameters mp;
|
||||||
|
{
|
||||||
|
py::gil_scoped_acquire acquire;
|
||||||
if (py::extract<MeshingParameters>(pymp).check())
|
if (py::extract<MeshingParameters>(pymp).check())
|
||||||
mp = py::extract<MeshingParameters>(pymp)();
|
mp = py::extract<MeshingParameters>(pymp)();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mp.optsteps3d = 5;
|
mp.optsteps3d = 5;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
MeshVolume (mp, self);
|
MeshVolume (mp, self);
|
||||||
OptimizeVolume (mp, self);
|
OptimizeVolume (mp, self);
|
||||||
},
|
},
|
||||||
py::arg("mp")=NGDummyArgument())
|
py::arg("mp")=NGDummyArgument(),py::call_guard<py::gil_scoped_release>())
|
||||||
|
|
||||||
.def ("OptimizeVolumeMesh", FunctionPointer
|
.def ("OptimizeVolumeMesh", FunctionPointer
|
||||||
([](Mesh & self)
|
([](Mesh & self)
|
||||||
@ -691,7 +694,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
MeshingParameters mp;
|
MeshingParameters mp;
|
||||||
mp.optsteps3d = 5;
|
mp.optsteps3d = 5;
|
||||||
OptimizeVolume (mp, self);
|
OptimizeVolume (mp, self);
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
|
|
||||||
.def ("Refine", FunctionPointer
|
.def ("Refine", FunctionPointer
|
||||||
([](Mesh & self)
|
([](Mesh & self)
|
||||||
@ -700,7 +703,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
self.GetGeometry()->GetRefinement().Refine(self);
|
self.GetGeometry()->GetRefinement().Refine(self);
|
||||||
else
|
else
|
||||||
Refinement().Refine(self);
|
Refinement().Refine(self);
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
|
|
||||||
.def ("SecondOrder", FunctionPointer
|
.def ("SecondOrder", FunctionPointer
|
||||||
([](Mesh & self)
|
([](Mesh & self)
|
||||||
@ -725,7 +728,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
}))
|
}))
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.def ("BuildSearchTree", &Mesh::BuildElementSearchTree)
|
.def ("BuildSearchTree", &Mesh::BuildElementSearchTree,py::call_guard<py::gil_scoped_release>())
|
||||||
|
|
||||||
.def ("BoundaryLayer", FunctionPointer
|
.def ("BoundaryLayer", FunctionPointer
|
||||||
([](Mesh & self, int bc, py::list thicknesses, int volnr, py::list materials)
|
([](Mesh & self, int bc, py::list thicknesses, int volnr, py::list materials)
|
||||||
|
@ -29,7 +29,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
|
|
||||||
self.HealGeometry();
|
self.HealGeometry();
|
||||||
self.BuildFMap();
|
self.BuildFMap();
|
||||||
},py::arg("tolerance")=1e-3, py::arg("fixsmalledges")=true, py::arg("fixspotstripfaces")=true, py::arg("sewfaces")=true, py::arg("makesolids")=true, py::arg("splitpartitions")=false,R"raw_string(Heal the OCCGeometry.)raw_string")
|
},py::arg("tolerance")=1e-3, py::arg("fixsmalledges")=true, py::arg("fixspotstripfaces")=true, py::arg("sewfaces")=true, py::arg("makesolids")=true, py::arg("splitpartitions")=false,R"raw_string(Heal the OCCGeometry.)raw_string",py::call_guard<py::gil_scoped_release>())
|
||||||
;
|
;
|
||||||
m.def("LoadOCCGeometry",FunctionPointer([] (const string & filename)
|
m.def("LoadOCCGeometry",FunctionPointer([] (const string & filename)
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
OCCGeometry * instance = new OCCGeometry();
|
OCCGeometry * instance = new OCCGeometry();
|
||||||
instance = LoadOCC_STEP(filename.c_str());
|
instance = LoadOCC_STEP(filename.c_str());
|
||||||
return shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
return shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
||||||
}));
|
}),py::call_guard<py::gil_scoped_release>());
|
||||||
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<OCCGeometry> geo, MeshingParameters ¶m)
|
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<OCCGeometry> geo, MeshingParameters ¶m)
|
||||||
{
|
{
|
||||||
auto mesh = make_shared<Mesh>();
|
auto mesh = make_shared<Mesh>();
|
||||||
@ -55,7 +55,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
cout << "Caught NgException: " << ex.What() << endl;
|
cout << "Caught NgException: " << ex.What() << endl;
|
||||||
}
|
}
|
||||||
return mesh;
|
return mesh;
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ DLL_HEADER void ExportSTL(py::module & m)
|
|||||||
{
|
{
|
||||||
ifstream ist(filename);
|
ifstream ist(filename);
|
||||||
return shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
return shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
||||||
}));
|
}),py::call_guard<py::gil_scoped_release>());
|
||||||
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<STLGeometry> geo, MeshingParameters ¶m)
|
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<STLGeometry> geo, MeshingParameters ¶m)
|
||||||
{
|
{
|
||||||
auto mesh = make_shared<Mesh>();
|
auto mesh = make_shared<Mesh>();
|
||||||
@ -41,7 +41,7 @@ DLL_HEADER void ExportSTL(py::module & m)
|
|||||||
cout << "Caught NgException: " << ex.What() << endl;
|
cout << "Caught NgException: " << ex.What() << endl;
|
||||||
}
|
}
|
||||||
return mesh;
|
return mesh;
|
||||||
}))
|
}),py::call_guard<py::gil_scoped_release>())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user