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;
|
||||
}
|
||||
return dummy;
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
;
|
||||
|
||||
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;
|
||||
geom.SaveToMeshFile (*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;
|
||||
opt.minref = 5;
|
||||
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>();
|
||||
self.SetGeometry(ng_geometry);
|
||||
delete infile;
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
// 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",
|
||||
[] (Mesh & self, string filename, string format)
|
||||
{
|
||||
@ -557,7 +557,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
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)
|
||||
|
||||
@ -634,7 +634,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
.def ("Compress", FunctionPointer ([](Mesh & self)
|
||||
{
|
||||
return self.Compress ();
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
|
||||
|
||||
.def ("SetBCName", &Mesh::SetBCName)
|
||||
@ -674,16 +674,19 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
cout << "generate vol mesh" << endl;
|
||||
|
||||
MeshingParameters mp;
|
||||
{
|
||||
py::gil_scoped_acquire acquire;
|
||||
if (py::extract<MeshingParameters>(pymp).check())
|
||||
mp = py::extract<MeshingParameters>(pymp)();
|
||||
else
|
||||
{
|
||||
mp.optsteps3d = 5;
|
||||
}
|
||||
}
|
||||
MeshVolume (mp, self);
|
||||
OptimizeVolume (mp, self);
|
||||
},
|
||||
py::arg("mp")=NGDummyArgument())
|
||||
py::arg("mp")=NGDummyArgument(),py::call_guard<py::gil_scoped_release>())
|
||||
|
||||
.def ("OptimizeVolumeMesh", FunctionPointer
|
||||
([](Mesh & self)
|
||||
@ -691,7 +694,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
MeshingParameters mp;
|
||||
mp.optsteps3d = 5;
|
||||
OptimizeVolume (mp, self);
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
|
||||
.def ("Refine", FunctionPointer
|
||||
([](Mesh & self)
|
||||
@ -700,7 +703,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
self.GetGeometry()->GetRefinement().Refine(self);
|
||||
else
|
||||
Refinement().Refine(self);
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
|
||||
.def ("SecondOrder", FunctionPointer
|
||||
([](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
|
||||
([](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.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)
|
||||
{
|
||||
@ -38,7 +38,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
OCCGeometry * instance = new OCCGeometry();
|
||||
instance = LoadOCC_STEP(filename.c_str());
|
||||
return shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
||||
}));
|
||||
}),py::call_guard<py::gil_scoped_release>());
|
||||
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<OCCGeometry> geo, MeshingParameters ¶m)
|
||||
{
|
||||
auto mesh = make_shared<Mesh>();
|
||||
@ -55,7 +55,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
cout << "Caught NgException: " << ex.What() << endl;
|
||||
}
|
||||
return mesh;
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ DLL_HEADER void ExportSTL(py::module & m)
|
||||
{
|
||||
ifstream ist(filename);
|
||||
return shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
||||
}));
|
||||
}),py::call_guard<py::gil_scoped_release>());
|
||||
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<STLGeometry> geo, MeshingParameters ¶m)
|
||||
{
|
||||
auto mesh = make_shared<Mesh>();
|
||||
@ -41,7 +41,7 @@ DLL_HEADER void ExportSTL(py::module & m)
|
||||
cout << "Caught NgException: " << ex.What() << endl;
|
||||
}
|
||||
return mesh;
|
||||
}))
|
||||
}),py::call_guard<py::gil_scoped_release>())
|
||||
;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user