From: Afeef Date: Fri, 24 Jun 2022 11:27:07 +0000 (+0200) Subject: Gmsh upgrade 4.8 -> 4.10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a4e31e7d5cfc634f12f91efa9b4f652da50331c3;p=plugins%2Fgmshplugin.git Gmsh upgrade 4.8 -> 4.10 This commit also adds intefaces MeshSizeFromCurvature which is used to control mesh size on curved edges (input [int] # of elements per) 2Pi ). --- diff --git a/idl/GMSHPlugin_Algorithm.idl b/idl/GMSHPlugin_Algorithm.idl index 93eaaea..cd210c5 100644 --- a/idl/GMSHPlugin_Algorithm.idl +++ b/idl/GMSHPlugin_Algorithm.idl @@ -77,6 +77,9 @@ module GMSHPlugin void SetSizeFactor(in double value); double GetSizeFactor(); + + void SetMeshCurvatureSize(in double value); + double GetMeshCurvatureSize(); void SetMaxSize(in double value); double GetMaxSize(); diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx index 5519748..75996a6 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx @@ -44,6 +44,9 @@ GMSHPlugin_Hypothesis::GMSHPlugin_Hypothesis (int hypId, _remeshPara (harmonic), _smouthSteps (1), _sizeFactor (1), +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + _meshCurvatureSize(0), +#endif _minSize (0), _maxSize (1e22), _secondOrder (false), @@ -143,6 +146,17 @@ void GMSHPlugin_Hypothesis::SetUseIncomplElem(bool theUseIncomplElem) } } +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 +void GMSHPlugin_Hypothesis::SetMeshCurvatureSize(double theMeshCurvatureSize) +{ + if (theMeshCurvatureSize != _meshCurvatureSize) + { + _meshCurvatureSize = theMeshCurvatureSize; + NotifySubMeshesHypothesisModification(); + } +} +#endif + void GMSHPlugin_Hypothesis::SetMaxSize(double theSize) { if (theSize != _maxSize) @@ -206,6 +220,9 @@ std::ostream & GMSHPlugin_Hypothesis::SaveTo(std::ostream & save) " " << _remeshPara << " " << _smouthSteps << " " << _sizeFactor << +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + " " << _meshCurvatureSize << +#endif " " << _maxSize << " " << _minSize << " " << (int)_secondOrder << @@ -288,6 +305,14 @@ std::istream & GMSHPlugin_Hypothesis::LoadFrom(std::istream & load) else load.clear(ios::badbit | load.rdstate()); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + isOK = static_cast(load >> val); + if (isOK) + _meshCurvatureSize = val; + else + load.clear(ios::badbit | load.rdstate()); +#endif + isOK = static_cast(load >> val); if (isOK) _maxSize = val; diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx index 7a0a3dc..51a485f 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx @@ -124,6 +124,11 @@ public: void SetUseIncomplElem(bool theUseIncomplElem); bool GetUseIncomplElem() const { return _useIncomplElem; } + +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + void SetMeshCurvatureSize(double theMeshCurvatureSize); + double GetMeshCurvatureSize() const { return _meshCurvatureSize; } +#endif void SetMaxSize(double theSize); double GetMaxSize() const { return _maxSize; } @@ -170,6 +175,9 @@ private: RemeshPara _remeshPara; double _smouthSteps; double _sizeFactor; +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + double _meshCurvatureSize; +#endif double _minSize, _maxSize; bool _secondOrder, _useIncomplElem; bool _is2d; diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx index b8ebfab..1d2e131 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx @@ -67,6 +67,22 @@ CORBA::Double GMSHPlugin_Hypothesis_i::GetMaxSize() return this->GetImpl()->GetMaxSize(); } + +void GMSHPlugin_Hypothesis_i::SetMeshCurvatureSize (CORBA::Double theMeshCurvatureSize) +{ + if ( isToSetParameter( GetMeshCurvatureSize(), theMeshCurvatureSize, METH_SetMeshCurvatureSize )) + { + this->GetImpl()->SetMeshCurvatureSize(theMeshCurvatureSize); + SMESH::TPythonDump() << _this() << ".SetMeshCurvatureSize( " << SMESH::TVar(theMeshCurvatureSize) << " )"; + } +} + +CORBA::Double GMSHPlugin_Hypothesis_i::GetMeshCurvatureSize() +{ + return this->GetImpl()->GetMeshCurvatureSize(); +} + + void GMSHPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue) { if ( isToSetParameter( GetMinSize(), theValue, METH_SetMinSize )) @@ -319,6 +335,7 @@ int GMSHPlugin_Hypothesis_i::getParamIndex(const TCollection_AsciiString& method if ( method == "SetNbSegPerEdge" ) return 2; if ( method == "SetNbSegPerRadius" ) return 3; if ( method == "SetMinSize" ) return nbVars-1; + if ( method == "SetMeshCurvatureSize" ) return 5; return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value } @@ -340,6 +357,7 @@ std::string GMSHPlugin_Hypothesis_i::getMethodOfParameter(const int paramIndex, case 2: return "SetNbSegPerEdge"; case 3: return "SetNbSegPerRadius"; case 4: return "SetMinSize"; + case 5: return "SetMeshCurvatureSize"; } return ""; } diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx index 53b4935..c7823fc 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx @@ -46,6 +46,8 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Hypothesis_i: virtual ~GMSHPlugin_Hypothesis_i(); // Ajout d'un truc + void SetMeshCurvatureSize(CORBA::Double theMeshCurvatureSize); + CORBA::Double GetMeshCurvatureSize(); void SetMaxSize(CORBA::Double theSize); CORBA::Double GetMaxSize(); @@ -113,6 +115,7 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Hypothesis_i: // to remember whether a parameter is already set (issue 0021364) enum SettingMethod { + METH_SetMeshCurvatureSize = 5, METH_SetMaxSize = 1, METH_SetMinSize = 2, METH_SetSecondOrder = 4, diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index 0222b03..2ef4d4f 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -176,6 +176,9 @@ void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp) _remeshPara = hyp->GetRemeshPara(); _smouthSteps = hyp->GetSmouthSteps(); _sizeFactor = hyp->GetSizeFactor(); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + _meshCurvatureSize = hyp->GetMeshCurvatureSize(); +#endif _minSize = hyp->GetMinSize(); _maxSize = hyp->GetMaxSize(); _secondOrder = hyp->GetSecondOrder(); @@ -193,6 +196,9 @@ void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp) _remeshPara = 0; _smouthSteps = 1; _sizeFactor = 1; +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + _meshCurvatureSize = 0; +#endif _minSize = 0; _maxSize = 1e22; _secondOrder = false; @@ -212,8 +218,11 @@ void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp) void GMSHPlugin_Mesher::SetMaxThreadsGmsh() { MESSAGE("GMSHPlugin_Mesher::SetMaxThreadsGmsh"); - if (_compounds.size() > 0) + // compound meshing (_compounds.size() > 0) and quad meshing (_algo2d == 5) will + // not be multi-threaded + if (_compounds.size() > 0 || _algo2d == 5){ _maxThreads = 1; + } else _maxThreads = omp_get_max_threads(); } @@ -280,6 +289,10 @@ void GMSHPlugin_Mesher::SetGmshOptions() //ASSERT(ok); ok = GmshSetOption("Mesh", "Smoothing" , (double)_smouthSteps) ; //ASSERT(ok); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + ok = GmshSetOption("Mesh", "MeshSizeFromCurvature" , _meshCurvatureSize) ; + ASSERT(ok); +#endif #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8 ok = GmshSetOption("Mesh", "MeshSizeFactor" , _sizeFactor) ; ASSERT(ok); diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.hxx b/src/GMSHPlugin/GMSHPlugin_Mesher.hxx index a291d62..b20520a 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.hxx @@ -97,6 +97,9 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3 double _maxThreads; #endif +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + double _meshCurvatureSize; +#endif std::set _compounds; diff --git a/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx b/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx index caa321e..5f850f0 100644 --- a/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx @@ -229,6 +229,14 @@ QFrame* GMSHPluginGUI_HypothesisCreator::buildFrame() aGroupLayout->addWidget( mySizeFactor, row, 1 ); row++; +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + aGroupLayout->addWidget( new QLabel( tr( "GMSH_SIZE_FROM_CURVATURE" ), GroupC1 ), row, 0 ); + myMeshCurvatureSize = new SMESHGUI_SpinBox( GroupC1 ); + myMeshCurvatureSize->RangeStepAndValidator( 0.0, 1e+22, 1.0, "length_precision" ); + aGroupLayout->addWidget( myMeshCurvatureSize, row, 1 ); + row++; +#endif + aGroupLayout->addWidget( new QLabel( tr( "GMSH_MIN_SIZE" ), GroupC1 ), row, 0 ); myMinSize = new SMESHGUI_SpinBox( GroupC1 ); myMinSize->RangeStepAndValidator( 0.0, 1e+22, 1., "length_precision" ); @@ -380,6 +388,12 @@ void GMSHPluginGUI_HypothesisCreator::retrieveParams() const mySizeFactor->setValue( data.mySizeFactor ); else mySizeFactor->setText( data.mySizeFactorVar ); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + if(data.myMeshCurvatureSizeVar.isEmpty()) + myMeshCurvatureSize->setValue( data.myMeshCurvatureSize ); + else + myMeshCurvatureSize->setText( data.myMeshCurvatureSizeVar ); +#endif if(data.myMaxSizeVar.isEmpty()) myMaxSize->setValue( data.myMaxSize ); else @@ -419,6 +433,9 @@ QString GMSHPluginGUI_HypothesisCreator::storeParams() const QString valStr = tr("GMSH_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; "; valStr += tr("GMSH_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; "; +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + valStr += tr("GMSH_SIZE_FROM_CURVATURE") + " = " + QString::number( data.myMeshCurvatureSize ) + "; "; +#endif if ( data.mySecondOrder ) valStr += tr("GMSH_SECOND_ORDER") + "; "; @@ -443,6 +460,10 @@ bool GMSHPluginGUI_HypothesisCreator::readParamsFromHypo( GmshHypothesisData& h_ h_data.myRemeshPara = (int) h->GetRemeshPara(); h_data.mySmouthSteps = h->GetSmouthSteps(); h_data.mySizeFactor = h->GetSizeFactor(); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + h_data.myMeshCurvatureSize = h->GetMeshCurvatureSize(); + h_data.myMeshCurvatureSizeVar = getVariableName("SetMeshCurvatureSize"); +#endif h_data.myMinSize = h->GetMinSize(); h_data.myMaxSize = h->GetMaxSize(); h_data.mySmouthStepsVar = getVariableName("SmouthSteps"); @@ -484,10 +505,16 @@ bool GMSHPluginGUI_HypothesisCreator::storeParamsToHypo( const GmshHypothesisDat h->SetRemeshPara( h_data.myRemeshPara ); h->SetSmouthSteps( h_data.mySmouthSteps ); h->SetSizeFactor( h_data.mySizeFactor ); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + h->SetMeshCurvatureSize( h_data.myMeshCurvatureSize ); +#endif h->SetMinSize( h_data.myMinSize ); h->SetMaxSize( h_data.myMaxSize ); h->SetVarParameter( h_data.mySmouthStepsVar.toLatin1().constData(), "SmouthSteps"); h->SetVarParameter( h_data.mySizeFactorVar.toLatin1().constData(), "SizeFactor"); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + h->SetVarParameter( h_data.myMeshCurvatureSizeVar.toLatin1().constData(), "SetMeshCurvatureSize"); +#endif h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize"); h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize"); h->SetSecondOrder( h_data.mySecondOrder ); @@ -535,6 +562,10 @@ bool GMSHPluginGUI_HypothesisCreator::readParamsFromWidgets( GmshHypothesisData& h_data.myRemeshPara = myRemeshPara->currentIndex(); h_data.mySmouthSteps = mySmouthSteps->value(); h_data.mySizeFactor = mySizeFactor->value(); +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + h_data.myMeshCurvatureSize = myMeshCurvatureSize->value(); + h_data.myMeshCurvatureSizeVar = myMeshCurvatureSize->text(); +#endif h_data.myMinSize = myMinSize->value(); h_data.myMaxSize = myMaxSize->value(); h_data.mySmouthStepsVar = mySmouthSteps->text(); diff --git a/src/GUI/GMSHPluginGUI_HypothesisCreator.h b/src/GUI/GMSHPluginGUI_HypothesisCreator.h index 6d8d7cb..2b022c9 100644 --- a/src/GUI/GMSHPluginGUI_HypothesisCreator.h +++ b/src/GUI/GMSHPluginGUI_HypothesisCreator.h @@ -45,8 +45,13 @@ typedef struct int mySubdivAlgo,myRemeshAlgo,myRemeshPara,mySmouthSteps; bool myUseIncomplElem; bool mySecondOrder; +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + double mySizeFactor,myMaxSize, myMinSize, myMeshCurvatureSize; + QString myMaxSizeVar, myMinSizeVar, mySmouthStepsVar, mySizeFactorVar, myMeshCurvatureSizeVar; +#else double mySizeFactor,myMaxSize, myMinSize; QString myMaxSizeVar, myMinSizeVar, mySmouthStepsVar, mySizeFactorVar; +#endif mutable QString myErrorMsg; } GmshHypothesisData; @@ -95,6 +100,9 @@ private: QComboBox* myRemeshPara; SMESHGUI_SpinBox* mySmouthSteps; SMESHGUI_SpinBox* mySizeFactor; +#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10 + SMESHGUI_SpinBox* myMeshCurvatureSize; +#endif SMESHGUI_SpinBox* myMaxSize; SMESHGUI_SpinBox* myMinSize; QCheckBox* myUseIncomplElem; diff --git a/src/GUI/GMSHPlugin_msg_en.ts b/src/GUI/GMSHPlugin_msg_en.ts index d649a34..75efd4d 100644 --- a/src/GUI/GMSHPlugin_msg_en.ts +++ b/src/GUI/GMSHPlugin_msg_en.ts @@ -19,6 +19,10 @@ GMSH_3D_TITLE Hypothesis Construction + + GMSH_SIZE_FROM_CURVATURE + Elements per 2Pi radians + GMSH_MAX_SIZE Max. Size diff --git a/src/GUI/GMSHPlugin_msg_fr.ts b/src/GUI/GMSHPlugin_msg_fr.ts index fc1376c..656cb48 100644 --- a/src/GUI/GMSHPlugin_msg_fr.ts +++ b/src/GUI/GMSHPlugin_msg_fr.ts @@ -19,6 +19,10 @@ GMSH_3D_TITLE Construction d'une hypothèse + + GMSH_SIZE_FROM_CURVATURE + Eléments par 2Pi radians + GMSH_MAX_SIZE Taille maximale