From eb177ba64551d4218329339113f3e1782ceb6029 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 16 Apr 2018 15:04:33 +0300 Subject: [PATCH] 023544: SMESH's performance issues (note 22293) --- doc/salome/examples/defining_hypotheses_ex13.py | 3 +++ src/SMDS/SMDS_Mesh.cxx | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/salome/examples/defining_hypotheses_ex13.py b/doc/salome/examples/defining_hypotheses_ex13.py index 339cd200d..5fa5e5344 100644 --- a/doc/salome/examples/defining_hypotheses_ex13.py +++ b/doc/salome/examples/defining_hypotheses_ex13.py @@ -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() diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 1d7ba140b..43a48eb37 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -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 idNodesOldToNew, idCellsNewToOld; + std::vector 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(); -- 2.39.2