diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index b390fe7f..ec8759b6 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -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()) ; 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()) ; @@ -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()) ; } diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index f549981c..f12600e0 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -540,9 +540,9 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) ng_geometry = make_shared(); self.SetGeometry(ng_geometry); delete infile; - })) + }),py::call_guard()) // static_cast(&Mesh::Load)) - .def("Save", static_cast(&Mesh::Save)) + .def("Save", static_cast(&Mesh::Save),py::call_guard()) .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()) .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()) .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(pymp).check()) mp = py::extract(pymp)(); else { mp.optsteps3d = 5; } + } MeshVolume (mp, self); OptimizeVolume (mp, self); }, - py::arg("mp")=NGDummyArgument()) + py::arg("mp")=NGDummyArgument(),py::call_guard()) .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()) .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()) .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()) .def ("BoundaryLayer", FunctionPointer ([](Mesh & self, int bc, py::list thicknesses, int volnr, py::list materials) diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index 34df71c0..2c791639 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -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()) ; 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(instance, NOOP_Deleter); - })); + }),py::call_guard()); m.def("GenerateMesh", FunctionPointer([] (shared_ptr geo, MeshingParameters ¶m) { auto mesh = make_shared(); @@ -55,7 +55,7 @@ DLL_HEADER void ExportNgOCC(py::module &m) cout << "Caught NgException: " << ex.What() << endl; } return mesh; - })) + }),py::call_guard()) ; } diff --git a/libsrc/stlgeom/python_stl.cpp b/libsrc/stlgeom/python_stl.cpp index 37d3e1fc..bbb923a9 100644 --- a/libsrc/stlgeom/python_stl.cpp +++ b/libsrc/stlgeom/python_stl.cpp @@ -25,7 +25,7 @@ DLL_HEADER void ExportSTL(py::module & m) { ifstream ist(filename); return shared_ptr(STLGeometry::Load(ist)); - })); + }),py::call_guard()); m.def("GenerateMesh", FunctionPointer([] (shared_ptr geo, MeshingParameters ¶m) { auto mesh = make_shared(); @@ -41,7 +41,7 @@ DLL_HEADER void ExportSTL(py::module & m) cout << "Caught NgException: " << ex.What() << endl; } return mesh; - })) + }),py::call_guard()) ; }