Salome HOME
Fix some tests regressions
authoreap <eap@opencascade.com>
Tue, 21 Aug 2018 12:06:54 +0000 (15:06 +0300)
committereap <eap@opencascade.com>
Tue, 21 Aug 2018 12:06:54 +0000 (15:06 +0300)
+ time optimization of ex12_grid17partition.py

src/SMESHDS/SMESHDS_SubMesh.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_SWIG/StdMeshersBuilder.py
src/SMESH_SWIG/ex12_grid17partition.py

index 26c9ec1287225d59a1c242ff9f876e8f9b9a33c6..cc5b6f7d3285d19dfbe9aa1948a3ec2f6bf99a69 100644 (file)
@@ -142,8 +142,20 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * elem )
 
     const SMDS_MeshElement* & elem1st = my1stElemNode[ ind1st( elem->GetType() )];
     if ( elem1st == elem )
 
     const SMDS_MeshElement* & elem1st = my1stElemNode[ ind1st( elem->GetType() )];
     if ( elem1st == elem )
-      elem1st = 0;
-
+    {
+      if ( myNbElements > 0 )
+      {
+        SMDS_ElemIteratorPtr it = myParent->shapeElementsIterator( myIndex, 1, elem1st );
+        if ( it->more() )
+          elem1st = it->next();
+        else
+          throw SALOME_Exception(LOCALIZED("invalid myNbElements"));
+      }
+      else
+      {
+        elem1st = 0;
+      }
+    }
     return true;
   }
   return false;
     return true;
   }
   return false;
@@ -192,8 +204,21 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
 
     const SMDS_MeshElement* & node1st = my1stElemNode[ ind1st( SMDSAbs_Node )];
     if ( node1st == N )
 
     const SMDS_MeshElement* & node1st = my1stElemNode[ ind1st( SMDSAbs_Node )];
     if ( node1st == N )
-      node1st = 0;
-
+    {
+      if ( myNbNodes > 0 )
+      {
+        SMDS_NodeIteratorPtr it =
+          myParent->shapeNodesIterator( myIndex, 1, static_cast< PNode >( node1st ));
+        if ( it->more() )
+          node1st = it->next();
+        else
+          throw SALOME_Exception(LOCALIZED("invalid myNbNodes"));
+      }
+      else
+      {
+        node1st = 0;
+      }
+    }
     return true;
   }
   return false;
     return true;
   }
   return false;
@@ -309,9 +334,9 @@ SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const
     return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
 
   const SMDS_MeshElement* const * elem1st = & my1stElemNode[ ind1st( SMDSAbs_All )];
     return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
 
   const SMDS_MeshElement* const * elem1st = & my1stElemNode[ ind1st( SMDSAbs_All )];
-  if ( myNbElements == 1 )
+  if ( myNbElements < 2 )
   {
   {
-    return boost::make_shared< EArrayIterator >( elem1st, elem1st+1 );
+    return boost::make_shared< EArrayIterator >( elem1st, elem1st + myNbElements );
   }
 
   return myParent->shapeElementsIterator( myIndex, myNbElements, *elem1st );
   }
 
   return myParent->shapeElementsIterator( myIndex, myNbElements, *elem1st );
@@ -329,9 +354,9 @@ SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const
 
   PNode const * node1st =
     reinterpret_cast< PNode const* >( & my1stElemNode[ ind1st( SMDSAbs_Node )] );
 
   PNode const * node1st =
     reinterpret_cast< PNode const* >( & my1stElemNode[ ind1st( SMDSAbs_Node )] );
-  if ( myNbNodes == 1 )
+  if ( myNbNodes < 2 )
   {
   {
-    return boost::make_shared< NArrayIterator >( node1st, node1st+1 );
+    return boost::make_shared< NArrayIterator >( node1st, node1st + myNbNodes );
   }
 
   return myParent->shapeNodesIterator( myIndex, myNbNodes, *node1st );
   }
 
   return myParent->shapeNodesIterator( myIndex, myNbNodes, *node1st );
@@ -459,6 +484,7 @@ void SMESHDS_SubMesh::Clear()
   myNbElements = 0;
   myNbNodes = 0;
   my1stElemNode[0] = my1stElemNode[1] = 0;
   myNbElements = 0;
   myNbNodes = 0;
   my1stElemNode[0] = my1stElemNode[1] = 0;
+
   if ( NbSubMeshes() > 0 )
   {
     SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
   if ( NbSubMeshes() > 0 )
   {
     SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
index e6ebe05e91a43b03b87159ff1fbf7cdd2afd3ffd..f994b82f0762ac67efd7c632710618cb0685a379 100644 (file)
@@ -4965,8 +4965,7 @@ void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent )
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" );
 
   // Clear study contexts data
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" );
 
   // Clear study contexts data
-  delete myStudyContext;
-  myStudyContext = 0;
+  myStudyContext->Clear();
 
   // remove the tmp files meshes are loaded from
   SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD( theComponent );
 
   // remove the tmp files meshes are loaded from
   SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD( theComponent );
index 2360fd4d17ea482d0307e8326fd7871056dfebac..21f55355e872ef23cfced32efb58fe5750dc2458 100644 (file)
@@ -79,6 +79,8 @@ public:
   void        mapOldToNew( const int oldId, const int newId );
   // get old id by a new one
   int         getOldId( const int newId );
   void        mapOldToNew( const int oldId, const int newId );
   // get old id by a new one
   int         getOldId( const int newId );
+  // clear data
+  void        Clear();
 
 private:
   // get next free object identifier
 
 private:
   // get next free object identifier
index 9e54cbd4987608a54c71dc274445d5e902abe857..af0dab97fab64a4cc027fd240a971dfe08a331d6 100644 (file)
@@ -1401,3 +1401,14 @@ int StudyContext::getOldId( const int newId )
   }
   return 0;
 }
   }
   return 0;
 }
+
+//=======================================================================
+//function : Clear
+//purpose  : clear data
+//=======================================================================
+
+void StudyContext::Clear()
+{
+  mapIdToIOR.Clear();
+  mapIdToId.Clear();
+}
index 26433141c5f6d7dac968a62cd3c2922451d6a1b9..4b2999f26a63cd3d37ae097aa3146efd0b884f7c 100644 (file)
@@ -458,7 +458,7 @@ class StdMeshersBuilder_Segment(Mesh_Algorithm):
         hyp.SetFineness( fineness )
         return hyp
 
         hyp.SetFineness( fineness )
         return hyp
 
-    def LengthNearVertex(self, length, vertex=0, UseExisting=0):
+    def LengthNearVertex(self, length, vertex=-1, UseExisting=0):
         """
         Defines "SegmentLengthAroundVertex" hypothesis
 
         """
         Defines "SegmentLengthAroundVertex" hypothesis
 
index 02e468333657748d8a6c002f9ffac984ea8e6564..49dc696b4d95dbc20f44d70a77aab2c34be05fa5 100644 (file)
@@ -33,10 +33,13 @@ import SMESH, SALOMEDS
 from salome.smesh import smeshBuilder
 smesh =  smeshBuilder.New()
 
 from salome.smesh import smeshBuilder
 smesh =  smeshBuilder.New()
 
+import time
+t1= time.time()
+
 # Geometry
 # ========
 
 # Geometry
 # ========
 
-# grid compound of 17 x 17 elements
+# grid compound of 3 x 3 elements
 # an element is compound of 3 concentric cylinders
 # an element is centered in a square of the grid
 
 # an element is compound of 3 concentric cylinders
 # an element is centered in a square of the grid
 
@@ -56,7 +59,7 @@ g_rayon1 = 20
 g_rayon2 = 30
 g_rayon3 = 40
 
 g_rayon2 = 30
 g_rayon3 = 40
 
-g_grid = 17
+g_grid = 3
 
 g_trim = 1000
 
 
 g_trim = 1000
 
@@ -120,6 +123,8 @@ piece = geompy.MakeMultiTranslation2D(c_element, geompy.MakeVectorDXDYDZ(1, 0, 0
 
 piece_id = geompy.addToStudy(piece, "ex12_grid17partition")
 
 
 piece_id = geompy.addToStudy(piece, "ex12_grid17partition")
 
+t2= time.time()
+
 # Meshing
 # =======
 
 # Meshing
 # =======
 
@@ -140,6 +145,11 @@ hexa.Hexahedron()
 
 hexa.Compute()
 
 
 hexa.Compute()
 
+t3= time.time()
+
+print ("time geom",t2-t1)
+print ("time mesh",t3-t2 )
+
 # Update object browser
 # ---------------------
 
 # Update object browser
 # ---------------------