From 1a0cb32c442f66b9a6d743b80dd69e7b33cd2415 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Mon, 13 Mar 2017 14:50:19 +0100 Subject: [PATCH] Adding element generation with cartesian core and global physical size --- CMakeLists.txt | 4 ++ idl/HYBRIDPlugin_Algorithm.idl | 8 ++- src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx | 15 ++++- src/GUI/HYBRIDPluginGUI_HypothesisCreator.h | 2 + src/GUI/HYBRIDPlugin_msg_en.ts | 8 +++ src/GUI/HYBRIDPlugin_msg_fr.ts | 8 +++ src/GUI/HYBRIDPlugin_msg_ja.ts | 8 +++ src/HYBRIDPlugin/HYBRIDPluginBuilder.py | 10 +++- src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx | 55 ++++++++++++++++--- src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx | 12 +++- .../HYBRIDPlugin_Hypothesis_i.cxx | 21 ++++++- .../HYBRIDPlugin_Hypothesis_i.hxx | 3 + 12 files changed, 141 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95fc536..346f4de 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,7 @@ SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME # Specific to HYBRIDPLUGIN: SET(SALOME_HYBRIDPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hybridplugin" CACHE PATH "Install path: SALOME HYBRIDPLUGIN specific data") +SET(SALOME_HYBRIDPLUGIN_INSTALL_TESTS ${SALOME_INSTALL_BINS}) MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS) MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON) @@ -237,6 +238,9 @@ ADD_SUBDIRECTORY(bin) IF(SALOME_BUILD_DOC) ADD_SUBDIRECTORY(doc) ENDIF(SALOME_BUILD_DOC) +IF(SALOME_BUILD_TESTS) + ADD_SUBDIRECTORY(tests) +ENDIF(SALOME_BUILD_TESTS) # Header configuration # ==================== diff --git a/idl/HYBRIDPlugin_Algorithm.idl b/idl/HYBRIDPlugin_Algorithm.idl index 9732ad5..29893d2 100644 --- a/idl/HYBRIDPlugin_Algorithm.idl +++ b/idl/HYBRIDPlugin_Algorithm.idl @@ -121,7 +121,7 @@ module HYBRIDPlugin void SetBoundaryLayersGrowth(in short level) raises (SALOME::SALOME_Exception); short GetBoundaryLayersGrowth(); /*! - * ElementGeneration: 0-Generation_Tetra_Dominant, 1-Generation_Hexa_Dominant. Default is Generation_Tetra_Dominant + * ElementGeneration: 0-Generation_Tetra_Dominant, 1-Generation_Hexa_Dominant, 2-Generation_Cartesian_Core. Default is Generation_Tetra_Dominant */ void SetElementGeneration(in short level) raises (SALOME::SALOME_Exception); short GetElementGeneration(); @@ -149,6 +149,12 @@ module HYBRIDPlugin */ void SetBoundaryLayersProgression(in double BLP) raises (SALOME::SALOME_Exception); double GetBoundaryLayersProgression(); + /*! + * To set core size. + * Default is 0.0 + */ + void SetCoreSize(in double CS) raises (SALOME::SALOME_Exception); + double GetCoreSize(); /*! * To set multinormals angle threshold at opening ridges. * Default is 30.0 diff --git a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx index f34c87e..6ffdef7 100644 --- a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx @@ -445,9 +445,14 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame() aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 ); QStringList typesElementGeneration; - typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" ); + typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" ) << tr( "HYBRID_GENERATION_CARTESIAN_CORE" ); myElementGenerationCombo->addItems( typesElementGeneration ); + aStdLayout->addWidget( new QLabel( tr( "HYBRID_CORE_SIZE" ), myStdGroup ), row, 0, 1, 1 ); + myCoreSizeSpin = new SMESHGUI_SpinBox( myStdGroup ); + myCoreSizeSpin->RangeStepAndValidator(0., COORD_MAX, 10., "length_precision"); + aStdLayout->addWidget( myCoreSizeSpin, row++, 1, 1, 1 ); + myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup ); aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 ); @@ -1520,6 +1525,10 @@ void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer ); myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers ); myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression ); + if (data.myCoreSize <= 0) + myCoreSizeSpin->setText(""); + else + myCoreSizeSpin -> setValue( data.myCoreSize ); myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle ); myFaceSelector ->SetListOfIDs( data.myFaceWLIds ); @@ -1748,6 +1757,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData h_data.mySmoothNormals = h->GetSmoothNormals(); h_data.myHeightFirstLayer = h->GetHeightFirstLayer(); h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression(); + h_data.myCoreSize = h->GetCoreSize(); h_data.myMultinormalsAngle = h->GetMultinormalsAngle(); h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers(); h_data.myFaceWLIds = h->GetFacesWithLayers(); @@ -1855,6 +1865,8 @@ bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesi h->SetHeightFirstLayer ( h_data.myHeightFirstLayer ); if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression ) h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression ); + if ( h->GetCoreSize() != h_data.myCoreSize ) + h->SetCoreSize ( h_data.myCoreSize ); if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle ) h->SetMultinormalsAngle ( h_data.myMultinormalsAngle ); if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers ) @@ -1979,6 +1991,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisD h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value(); h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value(); h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value(); + h_data.myCoreSize = myCoreSizeSpin->text().isEmpty() ? 0.0 : myCoreSizeSpin -> value(); h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value(); h_data.myFaceWLIds = myFaceSelector->GetListOfIDs(); diff --git a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h index 0726311..19ae823 100644 --- a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h +++ b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h @@ -161,6 +161,7 @@ typedef struct mySmoothNormals; double myHeightFirstLayer, myBoundaryLayersProgression, + myCoreSize, myMultinormalsAngle; short myNbOfBoundaryLayers; SMESH::long_array_var myFaceWLIds; @@ -272,6 +273,7 @@ private: SMESHGUI_SpinBox* myHeightFirstLayerSpin; QSpinBox* myNbOfBoundaryLayersSpin; SMESHGUI_SpinBox* myBoundaryLayersProgressionSpin; + SMESHGUI_SpinBox* myCoreSizeSpin; SMESHGUI_SpinBox* myMultinormalsAngleSpin; QCheckBox* mySmoothNormalsCheck; diff --git a/src/GUI/HYBRIDPlugin_msg_en.ts b/src/GUI/HYBRIDPlugin_msg_en.ts index bf8f942..77a630a 100644 --- a/src/GUI/HYBRIDPlugin_msg_en.ts +++ b/src/GUI/HYBRIDPlugin_msg_en.ts @@ -66,6 +66,14 @@ downward means inward and upward means outward ... HYBRID_GENERATION_HEXA_DOMINANT Hexahedra dominant + + HYBRID_GENERATION_CARTESIAN_CORE + Cartesian core + + + HYBRID_CORE_SIZE + Core elements size (cartesian core only) + HYBRID_ADD_MULTINORMALS Add extra normals at opening ridges and corners diff --git a/src/GUI/HYBRIDPlugin_msg_fr.ts b/src/GUI/HYBRIDPlugin_msg_fr.ts index 18c76e2..2fa24d4 100755 --- a/src/GUI/HYBRIDPlugin_msg_fr.ts +++ b/src/GUI/HYBRIDPlugin_msg_fr.ts @@ -66,6 +66,14 @@ en conséquence au dessous signifie à l'intérieur et au dessus signifie HYBRID_GENERATION_HEXA_DOMINANT Dominance d'hexaèdres + + HYBRID_GENERATION_CARTESIAN_CORE + Cœur cartésien + + + HYBRID_CORE_SIZE + Taille des éléments du cœur (cœur cartésien uniquement) + HYBRID_ADD_MULTINORMALS Ajout d'extra normales extérieures aux arêtes et coins diff --git a/src/GUI/HYBRIDPlugin_msg_ja.ts b/src/GUI/HYBRIDPlugin_msg_ja.ts index 4f3d84a..ccc5cdc 100644 --- a/src/GUI/HYBRIDPlugin_msg_ja.ts +++ b/src/GUI/HYBRIDPlugin_msg_ja.ts @@ -67,6 +67,14 @@ downward means inward and upward means outward ... HYBRID_GENERATION_HEXA_DOMINANT 主に六面体 + + HYBRID_GENERATION_CARTESIAN_CORE + Cartesian core + + + HYBRID_CORE_SIZE + Core elements size (cartesian core only) + HYBRID_ADD_MULTINORMALS 開いたリッジと角に別の法線を追加 diff --git a/src/HYBRIDPlugin/HYBRIDPluginBuilder.py b/src/HYBRIDPlugin/HYBRIDPluginBuilder.py index a84a91b..574f151 100644 --- a/src/HYBRIDPlugin/HYBRIDPluginBuilder.py +++ b/src/HYBRIDPlugin/HYBRIDPluginBuilder.py @@ -46,7 +46,7 @@ Decrease_Collision_Mode, Stop_Collision_Mode = 0,1 Layer_Growth_Inward, Layer_Growth_Outward = 0,1 # Mesh with element type Tetra Dominant or hexa Dominant in the remaining volume (outside layers). -Generation_Tetra_Dominant, Generation_Hexa_Dominant = 0,1 +Generation_Tetra_Dominant, Generation_Hexa_Dominant, Generation_Cartesian_Core = 0,1,2 #---------------------------- # Mesh algo type identifiers @@ -187,6 +187,7 @@ class HYBRID_Algorithm(Mesh_Algorithm): # @param mode, one of the following values # - Generation_Tetra_Dominant # - Generation_Hexa_Dominant + # - Generation_Cartesian_Core # . # Default is Generation_Tetra_Dominant def SetElementGeneration(self, mode): @@ -221,6 +222,13 @@ class HYBRID_Algorithm(Mesh_Algorithm): self.Parameters().SetBoundaryLayersProgression(boundaryLayersProgression) pass + ## Set core elements size. + # Default is 0.0 + # @param CoreSize double value + def SetCoreSize(self, CoreSize): + self.Parameters().SetCoreSize(CoreSize) + pass + ## To set multinormals angle threshold at opening ridges. # Default is 30.0 # @param multinormalsAngle double value diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 4d2f022..de92a75 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -62,6 +62,7 @@ HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, int studyId, SMESH_G mySmoothNormals(DefaultSmoothNormals()), myHeightFirstLayer(DefaultHeightFirstLayer()), myBoundaryLayersProgression(DefaultBoundaryLayersProgression()), + myCoreSize(DefaultCoreSize()), myMultinormalsAngle(DefaultMultinormalsAngle()), myNbOfBoundaryLayers(DefaultNbOfBoundaryLayers()), _enfVertexList(DefaultHYBRIDEnforcedVertexList()), @@ -391,6 +392,27 @@ double HYBRIDPlugin_Hypothesis::GetBoundaryLayersProgression() const return myBoundaryLayersProgression; } +//======================================================================= +//function : SetCoreSize +//======================================================================= + +void HYBRIDPlugin_Hypothesis::SetCoreSize(double toCoreSize) +{ + if ( myCoreSize != toCoreSize ) { + myCoreSize = toCoreSize; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetCoreSize +//======================================================================= + +double HYBRIDPlugin_Hypothesis::GetCoreSize() const +{ + return myCoreSize; +} + //======================================================================= //function : SetMultinormalsAngle //======================================================================= @@ -425,7 +447,7 @@ void HYBRIDPlugin_Hypothesis::SetNbOfBoundaryLayers(short toNbOfBoundaryLayers) } //======================================================================= -//function : GetMultinormalsAngle +//function : GetCoreSize //======================================================================= short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const @@ -1293,6 +1315,14 @@ double HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersProgression() return 1.0; } +//======================================================================= +//function : DefaultCoreSize +//======================================================================= +double HYBRIDPlugin_Hypothesis::DefaultCoreSize() +{ + return 0.0; +} + //======================================================================= //function : DefaultMultinormalsAngle //======================================================================= @@ -1329,6 +1359,8 @@ std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save) save << (int) myKeepFiles << " "; save << myWorkingDirectory << " "; save << myVerboseLevel << " "; + save << myCoreSize << " "; + if (!myTextOption.empty()) { save << "__OPTIONS_BEGIN__ "; save << myTextOption << " "; @@ -1501,6 +1533,11 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) else load.clear(ios::badbit | load.rdstate()); + isOK = static_cast(load >> d); + if (isOK) + myCoreSize = d; + else + load.clear(ios::badbit | load.rdstate()); std::string separator; bool hasOptions = false; @@ -1784,13 +1821,11 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* bool p_eg = ( hyp && hyp->myTextOption.find("--element_generation ") != std::string::npos ); bool p_cm = ( hyp && hyp->myTextOption.find("--collision_mode ") != std::string::npos ); bool p_am = ( hyp && hyp->myTextOption.find("--add_multinormals ") != std::string::npos ); + bool p_cs = ( hyp && hyp->myTextOption.find("--global_physical_size ") != std::string::npos ); bool p_mat = ( hyp && hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos ); bool p_sn = ( hyp && hyp->myTextOption.find("--smooth_normals ") != std::string::npos ); //missing options : - //- global_physical_size - //- boundary_layer_size_mode - //- boundary_layer_initial_height_on_surface_tags //- boundary_layer_max_element_angle bool nolayers = false; @@ -1862,12 +1897,18 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* } if ( !p_eg && hyp ) { - if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 1 ) { - const char* value[] = { "tetra-dominant" , "hexa-dominant" }; + if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 2 ) { + const char* value[] = { "tetra-dominant" , "hexa-dominant", "cartesian_core" }; cmd << " --element_generation " << value[ hyp->myElementGeneration ]; } } - + + if ( !p_cs && hyp ) { + if ( hyp->myCoreSize >= 0 ) { + cmd << " --global_physical_size " << hyp->myCoreSize; + } + } + if ( !p_cm && hyp ) { if ( hyp->myCollisionMode >= 0 && hyp->myCollisionMode <= 1 ) { const char* value[] = { "decrease" , "stop" }; diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx index 0bbd718..f4953fa 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx @@ -172,9 +172,9 @@ public: void SetBoundaryLayersGrowth(BoundaryLayersGrowth level); BoundaryLayersGrowth GetBoundaryLayersGrowth() const; /*! - * ElementGeneration: 0-Generation_Tetra_Dominant, 1-Generation_Hexa_Dominant. Default is Generation_Tetra_Dominant + * ElementGeneration: 0-Generation_Tetra_Dominant, 1-Generation_Hexa_Dominant, 2-Generation_Cartesian_Core. Default is Generation_Tetra_Dominant */ - enum ElementGeneration { Generation_Tetra_Dominant = 0, Generation_Hexa_Dominant }; + enum ElementGeneration { Generation_Tetra_Dominant = 0, Generation_Hexa_Dominant, Generation_Cartesian_Core }; void SetElementGeneration(ElementGeneration level); ElementGeneration GetElementGeneration() const; /*! @@ -200,6 +200,12 @@ public: */ void SetBoundaryLayersProgression(double BLP); double GetBoundaryLayersProgression() const; + /*! + * Set core elements size. + * Default is 0.0 + */ + void SetCoreSize(double CS); + double GetCoreSize() const; /*! * To set multinormals angle threshold at opening ridges. * Default is 30.0 @@ -380,6 +386,7 @@ public: static short DefaultNbOfBoundaryLayers(); static double DefaultHeightFirstLayer(); static double DefaultBoundaryLayersProgression(); + static double DefaultCoreSize(); static double DefaultMultinormalsAngle(); static THYBRIDEnforcedVertex DefaultHYBRIDEnforcedVertex() {return THYBRIDEnforcedVertex();} @@ -442,6 +449,7 @@ private: bool mySmoothNormals; double myHeightFirstLayer; double myBoundaryLayersProgression; + double myCoreSize; double myMultinormalsAngle; short myNbOfBoundaryLayers; diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx index 0d769f5..3aa6efa 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx @@ -556,7 +556,7 @@ void HYBRIDPlugin_Hypothesis_i::SetElementGeneration(CORBA::Short level) ::HYBRIDPlugin_Hypothesis::ElementGeneration l = (::HYBRIDPlugin_Hypothesis::ElementGeneration) level; if ( l < ::HYBRIDPlugin_Hypothesis::Generation_Tetra_Dominant || - l > ::HYBRIDPlugin_Hypothesis::Generation_Hexa_Dominant ) + l > ::HYBRIDPlugin_Hypothesis::Generation_Cartesian_Core ) THROW_SALOME_CORBA_EXCEPTION( "Invalid ElementGeneration mode",SALOME::BAD_PARAM ); ASSERT(myBaseImpl); @@ -649,6 +649,25 @@ CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersProgression() return this->GetImpl()->GetBoundaryLayersProgression(); } +//======================================================================= +//function : SetCoreSize +//======================================================================= +void HYBRIDPlugin_Hypothesis_i::SetCoreSize(CORBA::Double toCoreSize) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetCoreSize(toCoreSize); + SMESH::TPythonDump() << _this() << ".SetCoreSize( " << toCoreSize << " )"; +} + +//======================================================================= +//function : GetCoreSize +//======================================================================= +CORBA::Double HYBRIDPlugin_Hypothesis_i::GetCoreSize() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetCoreSize(); +} + //======================================================================= //function : SetMultinormalsAngle //======================================================================= diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx index 4733318..858436a 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx @@ -180,6 +180,9 @@ class HYBRIDPLUGIN_EXPORT HYBRIDPlugin_Hypothesis_i: void SetBoundaryLayersProgression(CORBA::Double toBoundaryLayersProgression); CORBA::Double GetBoundaryLayersProgression(); + void SetCoreSize(CORBA::Double toCoreSize); + CORBA::Double GetCoreSize(); + void SetMultinormalsAngle(CORBA::Double toMultinormalsAngle); CORBA::Double GetMultinormalsAngle(); -- 2.30.2