From 067472c5cf3e6818dedcc1272a459d6825dcbda1 Mon Sep 17 00:00:00 2001 From: Massimiliano Leoni Date: Fri, 21 Jan 2022 18:44:00 +0100 Subject: [PATCH] Implement better check for over-constrained volumes and faces wip --- doc/salome/examples/quality_controls_ex09.py | 4 +- doc/salome/examples/quality_controls_ex10.py | 2 +- .../SMESH/input/over_constrained_faces.rst | 4 +- .../SMESH/input/over_constrained_volumes.rst | 4 +- src/Controls/SMESH_Controls.cxx | 52 +++++++++---------- 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/doc/salome/examples/quality_controls_ex09.py b/doc/salome/examples/quality_controls_ex09.py index 9f4f7dbad..92a8f052f 100644 --- a/doc/salome/examples/quality_controls_ex09.py +++ b/doc/salome/examples/quality_controls_ex09.py @@ -22,6 +22,6 @@ n2 = mesh.AddNode(10,0,0) edge = mesh.AddEdge([n1,n2]) assert( not mesh.GetIdsFromFilter( faceFilter )) -# make faces +# make faces mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 5) -assert( 2 == len( mesh.GetIdsFromFilter( faceFilter ))) +assert( 5 == len( mesh.GetIdsFromFilter( faceFilter ))) diff --git a/doc/salome/examples/quality_controls_ex10.py b/doc/salome/examples/quality_controls_ex10.py index 22e93c9b5..b71b5d6da 100644 --- a/doc/salome/examples/quality_controls_ex10.py +++ b/doc/salome/examples/quality_controls_ex10.py @@ -22,4 +22,4 @@ n2 = mesh.AddNode(10,0,0) edge = mesh.AddEdge([n1,n2]) mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 1) mesh.ExtrusionSweep( mesh.GetElementsByType(SMESH.FACE), smesh.MakeDirStruct(0,0,5), 7) -assert( 2 == len( mesh.GetIdsFromFilter( volumeFilter ))) +assert( 7 == len( mesh.GetIdsFromFilter( volumeFilter ))) diff --git a/doc/salome/gui/SMESH/input/over_constrained_faces.rst b/doc/salome/gui/SMESH/input/over_constrained_faces.rst index 6cae032f2..87af11c52 100644 --- a/doc/salome/gui/SMESH/input/over_constrained_faces.rst +++ b/doc/salome/gui/SMESH/input/over_constrained_faces.rst @@ -4,7 +4,7 @@ Over-constrained faces ********************** -This mesh quality control highlights faces sharing only one border with other faces. +This mesh quality control highlights faces having all their points on the border. .. note:: The highlighted faces are actually over-constrained only if, at the computation time, the boundary conditions on the borders where the nodes are located are all Dirichlet boundary conditions. @@ -15,6 +15,6 @@ This mesh quality control highlights faces sharing only one border with other fa .. centered:: Over-constrained face is displayed in red -**See Also** a sample TUI Script of a :ref:`tui_over_constrained_faces` filter. +**See Also** a sample TUI Script of a :ref:`tui_over_constrained_faces` filter. diff --git a/doc/salome/gui/SMESH/input/over_constrained_volumes.rst b/doc/salome/gui/SMESH/input/over_constrained_volumes.rst index 8edd5a440..e601090e7 100644 --- a/doc/salome/gui/SMESH/input/over_constrained_volumes.rst +++ b/doc/salome/gui/SMESH/input/over_constrained_volumes.rst @@ -4,7 +4,7 @@ Over-constrained volumes ************************ -This mesh quality control highlights volumes sharing only one border with other volumes. +This mesh quality control highlights volumes having all their points on the border. .. note:: @@ -16,4 +16,4 @@ This mesh quality control highlights volumes sharing only one border with other .. centered:: Over-constrained volume is displayed in red. -**See Also** a sample TUI Script of a :ref:`tui_over_constrained_volumes` filter. +**See Also** a sample TUI Script of a :ref:`tui_over_constrained_volumes` filter. diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 1adabb5c6..44d92ef4d 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -2469,16 +2469,22 @@ bool BareBorderFace::IsSatisfy(long theElementId ) bool OverConstrainedVolume::IsSatisfy(long theElementId ) { - // An element is over-constrained if it has N-1 free borders where - // N is the number of edges/faces for a 2D/3D element. - SMDS_VolumeTool myTool; - if ( myTool.Set( myMesh->FindElement(theElementId))) + // An element is over-constrained if all its nodes are on the boundary. + // A node is on the boundary if it is connected to one or more faces. + SMDS_VolumeTool myTool; + if (myTool.Set(myMesh->FindElement(theElementId))) { - int nbSharedFaces = 0; - for ( int iF = 0; iF < myTool.NbFaces(); ++iF ) - if ( !myTool.IsFreeFace( iF ) && ++nbSharedFaces > 1 ) - break; - return ( nbSharedFaces == 1 ); + auto nodes = myTool.GetNodes(); + + for (int i = 0; i < myTool.NbNodes(); ++i) + { + auto node = nodes[i]; + if (node->NbInverseElements(SMDSAbs_Face) == 0) + { + return false; + } + } + return true; } return false; } @@ -2491,29 +2497,19 @@ bool OverConstrainedVolume::IsSatisfy(long theElementId ) bool OverConstrainedFace::IsSatisfy(long theElementId ) { - // An element is over-constrained if it has N-1 free borders where - // N is the number of edges/faces for a 2D/3D element. - if ( const SMDS_MeshElement* face = myMesh->FindElement(theElementId)) - if ( face->GetType() == SMDSAbs_Face ) + // An element is over-constrained if all its nodes are on the boundary. + // A node is on the boundary if it is connected to one or more faces. + if (const SMDS_MeshElement *face = myMesh->FindElement(theElementId)) + if (face->GetType() == SMDSAbs_Face) { - int nbSharedBorders = 0; int nbN = face->NbCornerNodes(); - for ( int i = 0; i < nbN; ++i ) + for (int i = 0; i < nbN; ++i) { - // check if a link is shared by another face - const SMDS_MeshNode* n1 = face->GetNode( i ); - const SMDS_MeshNode* n2 = face->GetNode( (i+1)%nbN ); - SMDS_ElemIteratorPtr fIt = n1->GetInverseElementIterator( SMDSAbs_Face ); - bool isShared = false; - while ( !isShared && fIt->more() ) - { - const SMDS_MeshElement* f = fIt->next(); - isShared = ( f != face && f->GetNodeIndex(n2) != -1 ); - } - if ( isShared && ++nbSharedBorders > 1 ) - break; + const SMDS_MeshNode *n1 = face->GetNode(i); + if (n1->NbInverseElements(SMDSAbs_Edge) == 0) + return false; } - return ( nbSharedBorders == 1 ); + return true; } return false; } -- 2.30.2