Salome HOME
023544: SMESH's performance issues (note 22293) uhz/V8_5_BR_w_min_of_memory_usage_and_fixes
authoreap <eap@opencascade.com>
Mon, 16 Apr 2018 12:04:33 +0000 (15:04 +0300)
committereap <eap@opencascade.com>
Mon, 16 Apr 2018 12:04:33 +0000 (15:04 +0300)
doc/salome/examples/defining_hypotheses_ex13.py
src/SMDS/SMDS_Mesh.cxx

index 339cd200d4e62d56127d5036b2838726dbfdb5b8..5fa5e53442f2c836f2b1f160362caaa368320e42 100644 (file)
@@ -25,15 +25,18 @@ radial_Quad_algo = mesh.Quadrangle(algo=smeshBuilder.RADIAL_QUAD)
 
 # The Radial Quadrange algorithm can work without any hypothesis
 # In this case it uses "Default Nb of Segments" preferences parameter to discretize edges
+# So by default there will be 15 segments in both radial and circular directions
 mesh.Compute()
 
 # The Radial Quadrange uses global or local 1d hypotheses if it does
 # not have its own hypotheses.
 # Define global hypotheses to discretize radial edges and a local one for circular edge
+# So that there will be 5 radial layers and 10 circular segments
 global_Nb_Segments = mesh.Segment().NumberOfSegments(5)
 local_Nb_Segments  = mesh.Segment(circle).NumberOfSegments(10)
 mesh.Compute()
 
 # Define own parameters of Radial Quadrange algorithm
+# The number of radial layers will be 4
 radial_Quad_algo.NumberOfLayers( 4 )
 mesh.Compute()
index 1d7ba140b7005d9644b21af7cd56d99a6eac3bb0..43a48eb37f23095e4f666dd64df2ed7c84a93487 100644 (file)
@@ -2916,9 +2916,10 @@ void SMDS_Mesh::CompactMesh()
     for ( ; holder != myElemHolders.end(); ++holder )
       (*holder)->beforeCompacting();
   }
+  int oldCellSize = myCellFactory->GetMaxID();
 
   // remove "holes" in SMDS numeration
-  std::vector<int> idNodesOldToNew, idCellsNewToOld;
+  std::vector<int> idNodesOldToNew, idCellsNewToOld, idCellsOldToNew;
   myNodeFactory->Compact( idNodesOldToNew );
   myCellFactory->Compact( idCellsNewToOld );
 
@@ -2927,10 +2928,22 @@ void SMDS_Mesh::CompactMesh()
   int newCellSize = myCellFactory->NbUsedElements();
   myGrid->compactGrid( idNodesOldToNew, newNodeSize, idCellsNewToOld, newCellSize );
 
+  if ( idsChange && !myElemHolders.empty() )
+  {
+    // idCellsNewToOld -> idCellsOldToNew
+    idCellsOldToNew.resize( oldCellSize, oldCellSize );
+    for ( size_t iNew = 0; iNew < idCellsNewToOld.size(); ++iNew )
+    {
+      if ( idCellsNewToOld[ iNew ] >= (int) idCellsOldToNew.size() )
+        idCellsOldToNew.resize( ( 1 + idCellsNewToOld[ iNew ]) * 1.5, oldCellSize );
+      idCellsOldToNew[ idCellsNewToOld[ iNew ]] = iNew;
+    }
+  }
+
   std::set< SMDS_ElementHolder* >::iterator holder = myElemHolders.begin();
   for ( ; holder != myElemHolders.end(); ++holder )
     if ( idsChange )
-      (*holder)->restoreElements( idNodesOldToNew, idCellsNewToOld );
+      (*holder)->restoreElements( idNodesOldToNew, idCellsOldToNew );
     else
       (*holder)->compact();