From 00a1d1a4964bf69d7aeb84d212c318a5a09bd3e1 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Thu, 4 Aug 2022 10:31:33 +0200 Subject: [PATCH 1/3] visualized failed mesh after generatemesh --- libsrc/meshing/meshfunc.cpp | 8 ++++++++ libsrc/occ/python_occ.cpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index 667ac416..d942f111 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -586,6 +586,8 @@ namespace netgen auto md = DivideMesh(mesh3d, mp); + try + { ParallelFor( md.Range(), [&](int i) { if (mp.checkoverlappingboundary) @@ -597,6 +599,12 @@ namespace netgen CloseOpenQuads( md[i] ); MeshDomain(md[i]); }, md.Size()); + } + catch(...) + { + MergeMeshes(mesh3d, md); + return MESHING3_GIVEUP; + } MergeMeshes(mesh3d, md); diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index e0b67031..7a55fc13 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -26,6 +26,7 @@ using namespace netgen; namespace netgen { extern std::shared_ptr ng_geometry; + extern std::shared_ptr mesh; } static string occparameter_description = R"delimiter( @@ -270,6 +271,7 @@ DLL_HEADER void ExportNgOCC(py::module &m) if (comm.Rank()==0) { SetGlobalMesh(mesh); + netgen::mesh = mesh; auto result = geo->GenerateMesh(mesh, mp); if(result != 0) throw Exception("Meshing failed!"); From 4e860f4ca29e0924e020859f6ecfaf88a14f3c5b Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Thu, 4 Aug 2022 14:14:39 +0200 Subject: [PATCH 2/3] set global shared ptr only if meshing fails --- libsrc/occ/python_occ.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index 7a55fc13..f3e876a6 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -271,10 +271,12 @@ DLL_HEADER void ExportNgOCC(py::module &m) if (comm.Rank()==0) { SetGlobalMesh(mesh); - netgen::mesh = mesh; auto result = geo->GenerateMesh(mesh, mp); if(result != 0) - throw Exception("Meshing failed!"); + { + netgen::mesh = mesh; + throw Exception("Meshing failed!"); + } ng_geometry = geo; if (comm.Size() > 1) mesh->Distribute(); From d36a6746b7cacd387163cf244c2de906b6822785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sch=C3=B6berl=2C=20Joachim?= Date: Thu, 4 Aug 2022 14:16:16 +0200 Subject: [PATCH 3/3] Update python_occ.cpp --- libsrc/occ/python_occ.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index f3e876a6..17533c37 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -274,7 +274,7 @@ DLL_HEADER void ExportNgOCC(py::module &m) auto result = geo->GenerateMesh(mesh, mp); if(result != 0) { - netgen::mesh = mesh; + netgen::mesh = mesh; // keep mesh for debugging throw Exception("Meshing failed!"); } ng_geometry = geo;