From 1aecb09c15462724ab10751ef9348c24f2f134a9 Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Mon, 24 Oct 2022 16:26:57 +0200 Subject: [PATCH] Corrections for parallel smesh Was crashing one of the testbase NRT_GRIDS_SMESH_BUGS_08_I1. Issue was that input info must be sorted to ensure the same number of volumes in one process. Also ensure that netgen::mparam parameters are all initialised. --- src/NETGENPlugin/NETGENPlugin_Mesher.cxx | 6 ++++++ src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx | 8 ++++++-- src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx | 2 +- src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx | 2 +- src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 44535f2..2d9ff3b 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -599,6 +599,8 @@ void NETGENPlugin_Mesher::SetDefaultParameters() _fineness = NETGENPlugin_Hypothesis::GetDefaultFineness(); mparams.uselocalh = NETGENPlugin_Hypothesis::GetDefaultSurfaceCurvature(); netgen::merge_solids = NETGENPlugin_Hypothesis::GetDefaultFuseEdges(); + // Unused argument but set 0 to initialise it + mparams.elementorder = 0; #ifdef NETGEN_V6 @@ -612,6 +614,7 @@ void NETGENPlugin_Mesher::SetDefaultParameters() #endif } + //============================================================================= /*! * Pass parameters to NETGEN @@ -4496,6 +4499,9 @@ int NETGENPlugin_NetgenLibWrapper::GenerateMesh( netgen::OCCGeometry& occgeo, if ( !ngMesh ) ngMesh = new netgen::Mesh; + // To dump mparam + // netgen::mparam.Print(std::cerr); + #ifdef NETGEN_V6 ngMesh->SetGeometry( shared_ptr( &occgeo, &NOOP_Deleter )); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx index d4712aa..8435688 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx @@ -218,7 +218,7 @@ bool NETGENPlugin_NETGEN_3D::getSurfaceElements( SMESH_ProxyMesh::Ptr proxyMesh, NETGENPlugin_Internals &internals, SMESH_MesherHelper &helper, - std::map>& listElements + std::map, TIDCompare>& listElements ) { SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); @@ -309,6 +309,8 @@ bool NETGENPlugin_NETGEN_3D::computeFillNgMesh( SMESH::Controls::TSequenceOfXYZ nodesCoords; // maps nodes to ng ID + // map must be sorted by ID to ensure that we will have the same number of + // 3D element if we recompute typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap; typedef TNodeToIDMap::value_type TN2ID; TNodeToIDMap nodeToNetgenID; @@ -338,7 +340,9 @@ bool NETGENPlugin_NETGEN_3D::computeFillNgMesh( proxyMesh.reset( Adaptor ); } - std::map> listElements; + // map must be sorted by ID to ensure that we will have the same number of + // 3D element if we recompute + std::map, TIDCompare> listElements; bool ret = getSurfaceElements(aMesh, aShape, proxyMesh, internals, helper, listElements); if(ret) return ret; diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx index af98746..f7ebf13 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx @@ -107,7 +107,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo SMESH_ProxyMesh::Ptr proxyMesh, NETGENPlugin_Internals &internals, SMESH_MesherHelper &helper, - std::map>& listElements); + std::map, TIDCompare>& listElements); bool compute(SMESH_Mesh& mesh, SMESH_MesherHelper& helper, diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx index 1ea0ad7..39b809b 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx @@ -322,7 +322,7 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements( SMESH_ProxyMesh::Ptr proxyMesh, NETGENPlugin_Internals &internals, SMESH_MesherHelper &helper, - std::map>& listElements + std::map, TIDCompare>& listElements ) { // To remove compilation warnings diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx index 0a6a6fc..dc7919d 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx @@ -72,7 +72,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_ SMESH_ProxyMesh::Ptr proxyMesh, NETGENPlugin_Internals &internals, SMESH_MesherHelper &helper, - std::map>& listElements + std::map, TIDCompare>& listElements ) override; std::string _element_orientation_file="";