From c25cd061aed7f3a0cdc57d92e0ae6143d30c7d8e Mon Sep 17 00:00:00 2001 From: Florian BRUNET Date: Wed, 8 Apr 2015 17:46:47 +0200 Subject: [PATCH] Change from double to long to handle the max memory size in the hypothesis creator for mg-tetra volume meshing. --- idl/GHS3DPlugin_Algorithm.idl | 8 +++--- src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx | 30 ++++++++++---------- src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx | 16 +++++------ src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx | 8 +++--- src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx | 8 +++--- src/GUI/GHS3DPluginGUI_AdvWidget_QTD.ui | 17 +++++++++-- src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx | 26 ++++++++--------- src/GUI/GHS3DPluginGUI_HypothesisCreator.h | 3 +- 8 files changed, 64 insertions(+), 52 deletions(-) diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index f1a6306..18e7a38 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -82,15 +82,15 @@ module GHS3DPlugin * Maximal size of memory to be used by the algorithm (in Megabytes). * Negative value means not to use this option */ - void SetMaximumMemory(in double MB) raises (SALOME::SALOME_Exception); - double GetMaximumMemory(); + void SetMaximumMemory(in long MB) raises (SALOME::SALOME_Exception); + long GetMaximumMemory(); /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero. * Negative value means not to use this option */ - void SetInitialMemory(in double MB) raises (SALOME::SALOME_Exception); - double GetInitialMemory(); + void SetInitialMemory(in long MB) raises (SALOME::SALOME_Exception); + long GetInitialMemory(); /*! * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium */ diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index f8a7c69..f65da0a 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -136,7 +136,7 @@ bool GHS3DPlugin_Hypothesis::GetToMakeGroupsOfDomains(const GHS3DPlugin_Hypothes //function : SetMaximumMemory //======================================================================= -void GHS3DPlugin_Hypothesis::SetMaximumMemory(double MB) +void GHS3DPlugin_Hypothesis::SetMaximumMemory(long MB) { if ( myMaximumMemory != MB ) { myMaximumMemory = MB; @@ -149,7 +149,7 @@ void GHS3DPlugin_Hypothesis::SetMaximumMemory(double MB) // * automatic memory adjustment mode. Default is zero //======================================================================= -double GHS3DPlugin_Hypothesis::GetMaximumMemory() const +long GHS3DPlugin_Hypothesis::GetMaximumMemory() const { return myMaximumMemory; } @@ -158,7 +158,7 @@ double GHS3DPlugin_Hypothesis::GetMaximumMemory() const //function : SetInitialMemory //======================================================================= -void GHS3DPlugin_Hypothesis::SetInitialMemory(double MB) +void GHS3DPlugin_Hypothesis::SetInitialMemory(long MB) { if ( myInitialMemory != MB ) { myInitialMemory = MB; @@ -170,7 +170,7 @@ void GHS3DPlugin_Hypothesis::SetInitialMemory(double MB) //function : GetInitialMemory //======================================================================= -double GHS3DPlugin_Hypothesis::GetInitialMemory() const +long GHS3DPlugin_Hypothesis::GetInitialMemory() const { return myInitialMemory; } @@ -852,22 +852,22 @@ bool GHS3DPlugin_Hypothesis::DefaultToMakeGroupsOfDomains() #include #endif -double GHS3DPlugin_Hypothesis::DefaultMaximumMemory() +long GHS3DPlugin_Hypothesis::DefaultMaximumMemory() { #ifndef WIN32 struct sysinfo si; - int err = sysinfo( &si ); + long err = sysinfo( &si ); if ( err == 0 ) { - int ramMB = si.totalram * si.mem_unit / 1024 / 1024; + long ramMB = si.totalram * si.mem_unit / 1024 / 1024; return ( 0.7 * ramMB ); } #else // See http://msdn.microsoft.com/en-us/library/aa366589.aspx MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); - int err = GlobalMemoryStatusEx (&statex); + long err = GlobalMemoryStatusEx (&statex); if (err != 0) { - int totMB = + long totMB = statex.ullTotalPhys / 1024 / 1024 + statex.ullTotalPageFile / 1024 / 1024 + statex.ullTotalVirtual / 1024 / 1024; @@ -881,7 +881,7 @@ double GHS3DPlugin_Hypothesis::DefaultMaximumMemory() //function : DefaultInitialMemory //======================================================================= -double GHS3DPlugin_Hypothesis::DefaultInitialMemory() +long GHS3DPlugin_Hypothesis::DefaultInitialMemory() { return DefaultMaximumMemory(); } @@ -1480,20 +1480,20 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h // Default memory is defined at MG-Tetra installation but it may be not enough, // so allow to use about all available memory if ( m ) { - double aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; + long aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; ostringstream tmpMaximumMemory; cmd += " -m "; if ( aMaximumMemory < 0 ) - tmpMaximumMemory << std::fixed << std::setprecision(0) << DefaultMaximumMemory(); + tmpMaximumMemory << DefaultMaximumMemory(); else - tmpMaximumMemory << std::fixed << std::setprecision(0) << aMaximumMemory; + tmpMaximumMemory << aMaximumMemory; cmd += tmpMaximumMemory.str().c_str(); } if ( M && !useBndRecovery ) { - double aInitialMemory = hyp ? hyp->myInitialMemory : -1; + long aInitialMemory = hyp ? hyp->myInitialMemory : -1; cmd += " -M "; if ( aInitialMemory > 0 ) - cmd += aInitialMemory; + cmd += (int)aInitialMemory; else cmd += "100"; } diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index 5f217a4..4db812a 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -134,14 +134,14 @@ public: /*! * Maximal size of memory to be used by the algorithm (in Megabytes) */ - void SetMaximumMemory(double MB); - double GetMaximumMemory() const; + void SetMaximumMemory(long MB); + long GetMaximumMemory() const; /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero */ - void SetInitialMemory(double MB); - double GetInitialMemory() const; + void SetInitialMemory(long MB); + long GetInitialMemory() const; /*! * Optimization level: 0-none, 1-light, 2-medium, 3-standard+, 4-strong. Default is medium */ @@ -289,8 +289,8 @@ public: static bool DefaultMeshHoles(); static bool DefaultToMakeGroupsOfDomains(); - static double DefaultMaximumMemory(); - static double DefaultInitialMemory(); + static long DefaultMaximumMemory(); + static long DefaultInitialMemory(); static short DefaultOptimizationLevel(); static std::string DefaultWorkingDirectory(); static bool DefaultKeepFiles(); @@ -339,8 +339,8 @@ private: bool myToMeshHoles; bool myToMakeGroupsOfDomains; - double myMaximumMemory; - double myInitialMemory; + long myMaximumMemory; + long myInitialMemory; short myOptimizationLevel; bool myKeepFiles; std::string myWorkingDirectory; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx index 49da13b..5e83934 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -115,7 +115,7 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains() //function : SetMaximumMemory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB) +void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ) { if ( MB == 0 ) @@ -129,7 +129,7 @@ void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB) //function : GetMaximumMemory //======================================================================= -CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaximumMemory() +CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory() { ASSERT(myBaseImpl); return this->GetImpl()->GetMaximumMemory(); @@ -139,7 +139,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaximumMemory() //function : SetInitialMemory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB) +void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ) { if ( MB == 0 ) @@ -153,7 +153,7 @@ void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB) //function : GetInitialMemory //======================================================================= -CORBA::Double GHS3DPlugin_Hypothesis_i::GetInitialMemory() +CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory() { ASSERT(myBaseImpl); return this->GetImpl()->GetInitialMemory(); diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx index 58a881b..fd75156 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx @@ -65,14 +65,14 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: /*! * Maximal size of memory to be used by the algorithm (in Megabytes) */ - void SetMaximumMemory(CORBA::Double MB) throw ( SALOME::SALOME_Exception ); - CORBA::Double GetMaximumMemory(); + void SetMaximumMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ); + CORBA::Long GetMaximumMemory(); /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero */ - void SetInitialMemory(CORBA::Double MB) throw ( SALOME::SALOME_Exception ); - CORBA::Double GetInitialMemory(); + void SetInitialMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ); + CORBA::Long GetInitialMemory(); /*! * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium */ diff --git a/src/GUI/GHS3DPluginGUI_AdvWidget_QTD.ui b/src/GUI/GHS3DPluginGUI_AdvWidget_QTD.ui index 1913752..5754262 100644 --- a/src/GUI/GHS3DPluginGUI_AdvWidget_QTD.ui +++ b/src/GUI/GHS3DPluginGUI_AdvWidget_QTD.ui @@ -6,7 +6,7 @@ 0 0 - 465 + 485 477 @@ -58,23 +58,29 @@ - + 1 0 + + 999999999 + - + 1 0 + + 999999999 + @@ -219,6 +225,11 @@ QSpinBox
SMESHGUI_SpinBox.h
+ + SalomeApp_IntSpinBox + QSpinBox +
SalomeApp_IntSpinBox.h
+
diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index fc57275..b21a152 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -76,28 +76,28 @@ namespace { #include #endif - int maxAvailableMemory() + long maxAvailableMemory() { #ifdef WIN32 // See http://msdn.microsoft.com/en-us/library/aa366589.aspx MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); - int err = GlobalMemoryStatusEx (&statex); + long err = GlobalMemoryStatusEx (&statex); if (err != 0) { - int totMB = + long totMB = statex.ullTotalPhys / 1024 / 1024 + statex.ullTotalPageFile / 1024 / 1024 + statex.ullTotalVirtual / 1024 / 1024; - return (int) ( 0.7 * totMB ); + return (long) ( 0.7 * totMB ); } #else struct sysinfo si; - int err = sysinfo( &si ); + long err = sysinfo( &si ); if ( err == 0 ) { - int totMB = + long totMB = si.totalram * si.mem_unit / 1024 / 1024 + si.totalswap * si.mem_unit / 1024 / 1024 ; - return (int) ( 0.7 * totMB ); + return (long) ( 0.7 * totMB ); } #endif return 0; @@ -416,11 +416,11 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" )); myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" )); - myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0); - myAdvWidget->maxMemorySpin->setValue( 128.0 ); + myAdvWidget->maxMemorySpin->stepBy(10); + myAdvWidget->maxMemorySpin->setValue( 128 ); - myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0); - myAdvWidget->initialMemorySpin->setValue( 100.0 ); + myAdvWidget->initialMemorySpin->stepBy(10); + myAdvWidget->initialMemorySpin->setValue( 100 ); myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" )); myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" )); @@ -1422,10 +1422,10 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains ); myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel ); myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 ); - myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory, + myAdvWidget->maxMemorySpin ->setValue ( qMax( (int)data.myMaximumMemory, myAdvWidget->maxMemorySpin->minimum() )); myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 ); - myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory, + myAdvWidget->initialMemorySpin ->setValue ( qMax( (int)data.myInitialMemory, myAdvWidget->initialMemorySpin->minimum() )); myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir ); myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles ); diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h index 5c3e57f..671e105 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h @@ -143,7 +143,8 @@ typedef struct { bool myToMeshHoles,myToMakeGroupsOfDomains,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint, myLogInStandardOutput, myRemoveLogOnSuccess; - double myMaximumMemory,myInitialMemory; + long myMaximumMemory; + long myInitialMemory; int myOptimizationLevel; QString myName,myWorkingDir,myTextOption; double myGradation; -- 2.30.2