From: cconopoima Date: Fri, 24 Mar 2023 18:07:46 +0000 (-0300) Subject: bos #32737 Allow to choose between MG-Tetra and MG-Tetra_HPC multithread X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=96a800193b343cf15fdff10f380d394479354936;p=plugins%2Fghs3dplugin.git bos #32737 Allow to choose between MG-Tetra and MG-Tetra_HPC multithread Update documentation to reflect availability of MGTetra HPC optionalities. Doc improvement. Define new Set... methods in GHS3DPluginBuilder.py Update methods SaveTo and LoadFrom to include new hypothesis options. Solve problems observed with hdf dumped files. Fixing issues pointed. Eliminate reference to MG_TetraHPC_API class since it is not be used. Fix typo when MGTetra HPC (parallel_mode is parallel_strategy). Reuse the same command line for MGTetra and MGTetraHPC changing the called executable depending on the user selection. Define ghs3dSetParametersDemo.py as test folling suggested instructions. Solving more issues. Carefull var init in constructor to avoid compilation warnings. Diasable EnforcedVertice and EnforceMesh widget when MGTetraHPC is selected. Avoid ref to non initialized class member on call to CommandToRun static method. Fixing CmakeLists in examples to properly copy the test from python example file into the SALOME_TEST_INSTALLDIR. Add missing CTestTestfileInstall.cmake file as suggested. Set reproducible_given_max_number_of_thread as default for MGTetraHPC and safe by default for MG-Tetra. Set Maximal number of threads to true as default on the hypothesis. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4683a30..376548c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,12 +195,14 @@ SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME SET(SALOME_GHS3DPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/ghs3dplugin" CACHE PATH "Install path: SALOME GHS3DPLUGIN specific data") +SET(SALOME_GHS3DPLUGIN_INSTALL_TESTS "${SALOME_INSTALL_BINS}/test") + 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) MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES) MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED) MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC) -MARK_AS_ADVANCED(SALOME_GHS3DPLUGIN_INSTALL_RES_DATA) +MARK_AS_ADVANCED(SALOME_GHS3DPLUGIN_INSTALL_RES_DATA SALOME_GHS3DPLUGIN_INSTALL_TESTS) # Accumulate environment variables for GHS3DPLUGIN module SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS} diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index edf8555..ab22a12 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -18,4 +18,33 @@ # FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") -INSTALL(FILES ${files} DESTINATION ${SALOME_INSTALL_DOC}/examples/GHS3DPLUGIN) +INCLUDE(examples.set) + +SET(COMPONENT_NAME GHS3DPLUGIN) + +SET(TEST_INSTALL_DIRECTORY ${SALOME_GHS3DPLUGIN_INSTALL_TESTS}) + +# make test +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${EXAMPLE_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env}") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") + MESSAGE( ${SALOME_INSTALL_DOC}) + INSTALL(FILES ${tfile}.py DESTINATION ${SALOME_INSTALL_DOC}/examples/GHS3DPLUGIN) +ENDFOREACH() + +# salome test +FOREACH(tfile ${EXAMPLE_NAMES}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDFOREACH() + +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) + +INSTALL(FILES examples.set DESTINATION ${TEST_INSTALL_DIRECTORY}) \ No newline at end of file diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake new file mode 100644 index 0000000..0e36b3f --- /dev/null +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -0,0 +1,31 @@ +# Copyright (C) 2016-2022 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(examples.set) + +SET(COMPONENT_NAME GHS3DPLUGIN) +SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/python_test_driver.py") +SET(TIMEOUT 300) + + +FOREACH(tfile ${EXAMPLE_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() diff --git a/doc/salome/examples/examples.set b/doc/salome/examples/examples.set new file mode 100644 index 0000000..11f137d --- /dev/null +++ b/doc/salome/examples/examples.set @@ -0,0 +1,22 @@ +# Copyright (C) 2016-2022 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(EXAMPLE_NAMES + ghs3dSetParametersDemo +) \ No newline at end of file diff --git a/doc/salome/examples/ghs3dSetParametersDemo.py b/doc/salome/examples/ghs3dSetParametersDemo.py new file mode 100644 index 0000000..b2c6f4c --- /dev/null +++ b/doc/salome/examples/ghs3dSetParametersDemo.py @@ -0,0 +1,49 @@ +import unittest + +import salome +salome.salome_init() + +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# create a box +box = geompy.MakeBoxDXDYDZ(200., 200., 200.) +geompy.addToStudy(box, "box") + +# create a mesh on the box +mgtetraMesh = smesh.Mesh(box,"box: MG-Tetra and NETGEN_1D_2D mesh") + +# create a NETGEN1D2D algorithm for faces and vertices +NETGEN_1D_2D = mgtetraMesh.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D_Parameters_1 = NETGEN_1D_2D.Parameters() +MG_Tetra = mgtetraMesh.Tetrahedron(algo=smeshBuilder.MG_Tetra) +MG_Tetra_Parameters_1 = MG_Tetra.Parameters() +MG_Tetra_Parameters_1.SetAlgorithm( 1 ) # 1 MGTetra (Default) - 0 MGTetra HPC +MG_Tetra_Parameters_1.SetUseNumOfThreads( 1 ) # 1 true - 0 false +MG_Tetra_Parameters_1.SetNumOfThreads( 6 ) # Number of threads +MG_Tetra_Parameters_1.SetPthreadMode( 1 ) # 0 - none, 1 - aggressive, 2 - safe + +# compute the mesh with MGTetra +status = mgtetraMesh.Compute() +assert( status ) + +mgtetraHPCMesh = smesh.Mesh(box,"box: MG-Tetra HPC and NETGEN_1D_2D mesh") +status = mgtetraHPCMesh.AddHypothesis(NETGEN_2D_Parameters_1) +NETGEN_1D_2D_1 = mgtetraHPCMesh.Triangle(algo=smeshBuilder.NETGEN_1D2D) +MG_Tetra_1 = mgtetraHPCMesh.Tetrahedron(algo=smeshBuilder.MG_Tetra) +MG_Tetra_Parameters_2 = MG_Tetra_1.Parameters() +MG_Tetra_Parameters_2.SetAlgorithm( 0 ) # 1 MGTetra (Default) - 0 MGTetra HPC +MG_Tetra_Parameters_2.SetUseNumOfThreads( 1 ) # 1 true - 0 false +MG_Tetra_Parameters_2.SetNumOfThreads( 6 ) # Number of threads +MG_Tetra_Parameters_2.SetParallelMode( 1 ) # 0 - none, 1 - reproducible_given_max_num_of_threads, 2 - reproducible, 3 - aggressive + +# compute the mesh with MGTetra HPC +status = mgtetraHPCMesh.Compute() +assert( status ) + + +# End of script + diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png index a0bca6a..e28fdb2 100644 Binary files a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png index 3ecb4f2..c29c3be 100644 Binary files a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc b/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc index af2ab19..d66b2f8 100644 --- a/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc +++ b/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc @@ -17,6 +17,8 @@ To get a license, visit http://www.meshgems.com/meshgems-products.html - Name - allows to define the name of the hypothesis (MG-Tetra Parameters by default). +- Algorithm Selection - allows to select the version of MG-Tetra algorithm to be used. + - Optimization level - allows choosing the required optimization level (higher level of optimization provides better mesh, but can be time-consuming): @@ -27,7 +29,7 @@ but can be time-consuming): - medium (standard) - - standard+ + - standard+ (not available whem MG-Tetra HPC is selected) - strong @@ -35,6 +37,22 @@ but can be time-consuming): - Maximal size - sets the maximum edge size in the generated mesh. +- Maximal number of threads - define the maximal number of threads to be used by the meshing algorithm. + On selection of this box the Pthread mode is activated when MG-Tetra is selected and + Parallel mode is activated if the MG-Tetra HPC algorithm is selected. + +- Pthread mode - define the parallel strategy used by the mesher when MG-Tetra is selected. + - none + - aggresive - is faster than the sequential mode, but the quality of the resulting mesh may altered compared to the sequential mode. + - safe - is slower than the sequential mode, but the quality of the mesh can only improve; + +- Paralle strategy (HPC) - define the parallel strategy used by the mesher when MG-Tetra HPC is selected. + - none + - reproducible_given_max_number_of_threads + - reproducible + - aggressive + + - Volumic gradation - Defines the volumic ratio between 2 consecutive elements. WARNING: Changing the default value of this parameter may dramatically decrease the quality of the resulting mesh. @@ -58,7 +76,7 @@ domain.
\image html ghs3d_parameters_advanced.png -\subsection advanced_meshing_options Advanced meshing options +\subsection advanced_meshing_options Advanced meshing options for MG-Tetra algorithm Advanced page tab expose mostly useful advanced options. Initially, default values of the options are displayed and they are not @@ -130,10 +148,6 @@ option will be erased upon pressing \a Ok. to a given maximum number of errors. At least 1 error is printed and at most 100 errors are printed to prevent infinite loops. -- Maximal number of threads - This allows to set the maximal - number of threads the software can use in parallel for the - multi-threading optimization mode. - - No central point - yes prevents adding an internal point at the centre of gravity of the bounding box that MeshGems-Tetra uses by default in order to speed up and to simplify the meshing @@ -151,17 +165,6 @@ option will be erased upon pressing \a Ok. - Optimise worst elements - Applies an optimization processing to improve the worst quality elements whenever possible. -- Mode of pthreads - This option sets the optimization mode - when using multithread capabilities. By default, this option is not - activated which means that only a sequential optimization is - performed. - - - safe is slower than the sequential mode, but the - quality of the mesh can only improve; - - - aggressive - is faster than the sequential mode, but - the quality of the resulting mesh may altered compared to the sequential mode. - - Rectify jacobian - This option activates correction of some nodes so as to make the Jacobian of element strictly positive when generating a quadratic mesh. @@ -172,6 +175,19 @@ option will be erased upon pressing \a Ok. caracterizes a sliver : any tetrahedron which has at least an angle below this value will be considered as a sliver. +- Target quality - Sets the desired maximum target of worst + quality acceptable for the volume mesh used during optimisation + phase. When defined, an optimization processing is applied to + improve the quality until the given target is reached whenever + possible. By default, this option is not activated which means that + only the standard optimisations are performed (the quality target is + the target quality computed by the program). + +\subsection advanced_meshing_options_HPC Advanced meshing options for MG-Tetra and MG-Tetra HPC algorithms + +This option is common to both algorithms. When MG-Tetra HPC algorithm is selected on the General Parameters view, all advanced options +are disabled except the follow ones: + - Remove overconstrained tetrahedra - This option can be used to only split the tetrahadra which have at least two facets that belong to the surface mesh. It will not split the overconstrained @@ -185,15 +201,7 @@ option will be erased upon pressing \a Ok. - only means only correction is applied to an existing mesh. -- Target quality - Sets the desired maximum target of worst - quality acceptable for the volume mesh used during optimisation - phase. When defined, an optimization processing is applied to - improve the quality until the given target is reached whenever - possible. By default, this option is not activated which means that - only the standard optimisations are performed (the quality target is - the target quality computed by the program). - -\subsection memory_settings Memory settings +\subsection memory_settings Memory settings (disable when MG-Tetra HPC is selected) - Maximum memory size - launches MG-Tetra software with work space limited to the specified amount of RAM, in Mbytes. If this option is diff --git a/doc/salome/gui/GHS3DPLUGIN/input/index.doc b/doc/salome/gui/GHS3DPLUGIN/input/index.doc index 9313082..8fd532e 100644 --- a/doc/salome/gui/GHS3DPLUGIN/input/index.doc +++ b/doc/salome/gui/GHS3DPLUGIN/input/index.doc @@ -3,9 +3,9 @@ \mainpage Introduction to MG-Tetra plug-in MG-Tetra plug-in adds two meshing algorithm to the SALOME Mesh: -\b MG-Tetra (former GHS3D) and MG-Tetra Optimization. + MG-Tetra or MG-Tetra HPC (former GHS3D) and MG-Tetra Optimization. -\b MG-Tetra meshing algorithm is destined for: + MG-Tetra or MG-Tetra HPC meshing algorithm is destined for: - Meshing 3D geometric entities: solids are split into tetrahedral (pyramidal) elements. - Generating 3D meshes from 2D meshes (triangles and quadrangles), working without geometrical objects. diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index ad673c2..3467b6f 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -118,6 +118,31 @@ module GHS3DPlugin */ void SetOptimizationLevel(in short level) raises (SALOME::SALOME_Exception); short GetOptimizationLevel(); + /*! + * Algorithm selection: 0-MGTetra HPC, 1-MGTetra + */ + void SetAlgorithm(in short level) raises (SALOME::SALOME_Exception); + short GetAlgorithm(); + /*! + * Set use number of threads + */ + void SetUseNumOfThreads(in boolean setThread) raises (SALOME::SALOME_Exception); + boolean GetUseNumOfThreads(); + /*! + * Set number of threads to use + */ + void SetNumOfThreads(in short numThreads); + short GetNumOfThreads(); + /*! + * PThreadMode defined for MGTetra + */ + void SetPthreadMode(in short pThreadMode) raises (SALOME::SALOME_Exception); + short GetPthreadMode(); + /*! + * ParallelMode defined for MGTetra HPC + */ + void SetParallelMode(in short parallelMode) raises (SALOME::SALOME_Exception); + short GetParallelMode(); /*! * Path to working directory */ diff --git a/src/GHS3DPlugin/GHS3DPluginBuilder.py b/src/GHS3DPlugin/GHS3DPluginBuilder.py index 06f1a87..8ce03ed 100644 --- a/src/GHS3DPlugin/GHS3DPluginBuilder.py +++ b/src/GHS3DPlugin/GHS3DPluginBuilder.py @@ -222,6 +222,43 @@ class GHS3D_Algorithm(Mesh_Algorithm): self.Parameters().SetToRemoveCentralPoint(toRemove) pass + ## To set the algorithm id + # @param algorithm ID 0 MGTetra HPC - 1 MGTetra + def SetAlgorithm(self,algoId): + self.Parameters().SetAlgorithm(algoId) + pass + + ## To use parallel mode + # @param toUseNumOfThreads "use max number of threads" flag value + def SetUseNumOfThreads(self,useThreads): + self.Parameters().SetUseNumOfThreads(useThreads) + pass + + ## To set the number of threads to be used + # @param numberOfThreads define max_num_threads for MGTetra and MGTetra HPC + def SetNumOfThreads(self,numThreads): + self.Parameters().SetNumOfThreads(numThreads) + pass + + ## Set SetPthreadMode. + # @param pthreadMode for parallel algorithm in MGTetra + # - 0 - none + # - 1 - aggresive + # - 2 - safe + def SetPthreadMode(self,pthreadMode): + self.Parameters().SetPthreadMode(pthreadMode) + pass + + ## Set SetParallelMode. + # @param parallelMode for parallel algorithm in MGTetra HPC + # - 0 - none + # - 1 - reproducible_given_max_number_of_threads + # - 2 - reproducible + # - 3 - aggressive + def SetPthreadMode(self,parallelMode): + self.Parameters().SetParallelMode(parallelMode) + pass + ## To set an enforced vertex. # @param x : x coordinate # @param y : y coordinate diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index b7b3109..0b48cdf 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -1580,12 +1580,12 @@ static bool writeGMFFile(MG_Tetra_API* MGInput return true; } + //============================================================================= /*! *Here we are going to use the MG-Tetra mesher with geometry */ //============================================================================= - bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape) { @@ -1871,7 +1871,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, /*! *Here we are going to use the MG-Tetra mesher w/o geometry */ -//============================================================================= +//================================0============================================= + bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, SMESH_MesherHelper* theHelper) { diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx index 620d336..7f5a6b5 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx @@ -57,19 +57,18 @@ public: virtual bool CheckHypothesis(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, Hypothesis_Status& aStatus); - - virtual bool Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape); - virtual void CancelCompute(); bool computeCanceled() { return _computeCanceled; } virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, MapShapeNbElems& aResMap); + virtual bool Compute(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape); + virtual bool Compute(SMESH_Mesh& theMesh, - SMESH_MesherHelper* aHelper); - + SMESH_MesherHelper* aHelper); + virtual void SubmeshRestored(SMESH_subMesh* subMesh); virtual void SetEventListener(SMESH_subMesh* subMesh); diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index 73a58fb..989eea6 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -70,6 +70,11 @@ GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, SMESH_Gen * gen) myGradation(DefaultGradation()), myUseVolumeProximity(DefaultUseVolumeProximity()), myNbVolumeProximityLayers(DefaultNbVolumeProximityLayers()), + myAlgorithm(DefaultAlgorithm()), + myNumOfThreads(DefaultNumOfThreads()), + myUseNumOfThreads(DefaultUseNumOfThreads()), + myPthreadModeMG(DefaultMyPthreadMode()), + myPthreadModeMGHPC(DefaultMyPthreadModeHPC()), myMinSize(0), myMinSizeDefault(0), myMaxSize(0), @@ -88,15 +93,13 @@ GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, SMESH_Gen * gen) "" // mark of end }; const char* intOptionNames[] = { "max_number_of_errors_printed", // 1 - "max_number_of_threads", // 4 "" // mark of end }; const char* doubleOptionNames[] = { "target_quality", // 0 "sliver_angle", // 5 "" // mark of end }; - const char* charOptionNames[] = { "pthreads_mode", // "" - "boundary_regeneration", // standard + const char* charOptionNames[] = { "boundary_regeneration", // standard "split_overconstrained_tetrahedra", // no "" // mark of end }; @@ -132,10 +135,8 @@ GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, SMESH_Gen * gen) _defaultOptionValues["rectify_jacobian" ] = "yes"; _defaultOptionValues["jacobian_rectification_respect_input_surface_mesh"] = "yes"; _defaultOptionValues["max_number_of_errors_printed" ] = "1"; - _defaultOptionValues["max_number_of_threads" ] = "4"; _defaultOptionValues["target_quality" ] = "";//NoValue(); _defaultOptionValues["sliver_angle" ] = "5"; - _defaultOptionValues["pthreads_mode" ] = "";//NoValue(); _defaultOptionValues["boundary_regeneration" ] = "standard"; _defaultOptionValues["split_overconstrained_tetrahedra" ] = "no"; @@ -354,9 +355,108 @@ void GHS3DPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate) } //======================================================================= -//function : GetToCreateNewNodes +//function : SetAlgorithm +//======================================================================= +void GHS3DPlugin_Hypothesis::SetAlgorithm(ImplementedAlgorithms algoId) +{ + if ( myAlgorithm != algoId ) { + myAlgorithm = algoId; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : short GetAlgorithm() const; + +//======================================================================= +GHS3DPlugin_Hypothesis::ImplementedAlgorithms GHS3DPlugin_Hypothesis::GetAlgorithm() const +{ + return (ImplementedAlgorithms) myAlgorithm; +} + +//======================================================================= +//function : SetPthreadMode +//======================================================================= +void GHS3DPlugin_Hypothesis::SetPthreadMode(PThreadMode pThreadsMode ) +{ + if ( myPthreadModeMG != pThreadsMode ) { + myPthreadModeMG = pThreadsMode; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : short GetPthreadMode() const; + +//======================================================================= +GHS3DPlugin_Hypothesis::PThreadMode GHS3DPlugin_Hypothesis::GetPthreadMode() const +{ + return (PThreadMode)myPthreadModeMG; +} + +//======================================================================= +//function : SetParallelMode +//======================================================================= +void GHS3DPlugin_Hypothesis::SetParallelMode(ParallelMode parallelMode ) +{ + if ( myPthreadModeMGHPC != parallelMode ) { + myPthreadModeMGHPC = parallelMode; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : short GetParallelMode() const; + +//======================================================================= +GHS3DPlugin_Hypothesis::ParallelMode GHS3DPlugin_Hypothesis::GetParallelMode() const +{ + return (ParallelMode)myPthreadModeMGHPC; +} + +//======================================================================= +//function : SetUseNumOfThreads +//======================================================================= +void GHS3DPlugin_Hypothesis::SetUseNumOfThreads(bool setUseOfThreads) +{ + if ( myUseNumOfThreads != setUseOfThreads ) { + myUseNumOfThreads = setUseOfThreads; + NotifySubMeshesHypothesisModification(); + } +} + //======================================================================= +//function : bool GetUseNumOfThreads() const; +//======================================================================= +bool GHS3DPlugin_Hypothesis::GetUseNumOfThreads() const +{ + return myUseNumOfThreads; +} + +//======================================================================= +//function : SetNumOfThreads +//======================================================================= +void GHS3DPlugin_Hypothesis::SetNumOfThreads(short numOfThreads) +{ + if ( myNumOfThreads != numOfThreads ) { + myNumOfThreads = numOfThreads; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : short GetUseNumOfThreads() const; + +//======================================================================= +short GHS3DPlugin_Hypothesis::GetNumOfThreads() const +{ + return myNumOfThreads; +} + +//======================================================================= +//function : GetToCreateNewNodes +//======================================================================= bool GHS3DPlugin_Hypothesis::GetToCreateNewNodes() const { return myToCreateNewNodes; @@ -1252,6 +1352,13 @@ std::ostream & GHS3DPlugin_Hypothesis::SaveTo(std::ostream & save) for ( o2v = _customOption2value.begin(); o2v != _customOption2value.end(); ++o2v ) save << " -" << o2v->first << " -" << o2v->second; + // New options (issue #32737) + save << " " << myAlgorithm; + save << " " << myUseNumOfThreads; + save << " " << myNumOfThreads; + save << " " << myPthreadModeMG; + save << " " << myPthreadModeMGHPC; + return save; } @@ -1608,6 +1715,36 @@ std::istream & GHS3DPlugin_Hypothesis::LoadFrom(std::istream & load) } } + isOK = static_cast(load >> i); + if (isOK) + myAlgorithm = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = static_cast(load >> i); + if (isOK) + myUseNumOfThreads = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = static_cast(load >> i); + if (isOK) + myNumOfThreads = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = static_cast(load >> i); + if (isOK) + myPthreadModeMG = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = static_cast(load >> i); + if (isOK) + myPthreadModeMGHPC = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + return load; } @@ -1639,17 +1776,57 @@ bool GHS3DPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, return true; } +void GHS3DPlugin_Hypothesis::SetAdvancedOptionsInCommandLine( std::string & cmd ) const +{ + std::string option, value; + bool isDefault; + const TOptionValues* options[] = { & this->_option2value, & this->_customOption2value }; + for ( int iOp = 0; iOp < 2; ++iOp ) + { + TOptionValues::const_iterator o2v = options[iOp]->begin(); + for ( ; o2v != options[iOp]->end(); ++o2v ) + { + option = o2v->first; + value = this->GetOptionValue( option, &isDefault ); + + if ( isDefault ) + continue; + + if ( value.empty() )//value == NoValue() ) + { + if ( this->_defaultOptionValues.count( option )) + continue; // non-custom option with no value + //value.clear(); + } + + if ( strncmp( "no", option.c_str(), 2 ) == 0 ) // options w/o values: --no_* + { + if ( !value.empty() && ToBool( value ) == false ) + continue; + value.clear(); + } + + if ( option[0] != '-' ) + cmd += " --"; + else + cmd += " "; + cmd += option + " " + value; + } + } +} + //================================================================================ /*! * \brief Return command to run MG-Tetra mesher excluding file prefix (-f) */ //================================================================================ - std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp, const bool hasShapeToMesh, const bool forExecutable) { - std::string cmd = GetExeName(); + GHS3DPlugin_Hypothesis::ImplementedAlgorithms algoId = hyp ? (ImplementedAlgorithms) hyp->myAlgorithm : MGTetra; + std::string cmd = GetExeName( algoId ); + // check if any option is overridden by hyp->myTextOption bool max_memory = hyp ? !hyp->HasOptionDefined("max_memory") : true; bool auto_memory = hyp ? !hyp->HasOptionDefined("automatic_memory") : true; @@ -1668,20 +1845,20 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h useBndRecovery = hyp->myToUseBoundaryRecoveryVersion; // MG-Tetra needs to know amount of memory it may use (MB). - // Default memory is defined at MG-Tetra installation but it may be not enough, - // so allow to use about all available memory - if ( max_memory ) { + // Default memory is defined at MG-Tetra installation but it may be not enough, // so allow to use about all available memory + if ( algoId == MGTetra && max_memory ) { float aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; cmd += " --max_memory "; if ( aMaximumMemory < 0 ) cmd += SMESH_Comment( int( DefaultMaximumMemory() )); else cmd += SMESH_Comment( int( aMaximumMemory )); } - if ( auto_memory && !useBndRecovery ) { + if ( algoId == MGTetra && ( auto_memory && !useBndRecovery ) ) { float aInitialMemory = hyp ? hyp->myInitialMemory : -1; cmd += " --automatic_memory "; if ( aInitialMemory > 0 ) cmd += SMESH_Comment( int( aInitialMemory )); else cmd += "100"; } + // component to mesh if ( comp && !useBndRecovery ) { // We always run MG-Tetra with "to mesh holes'==TRUE (see PAL19680) @@ -1700,11 +1877,13 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h cmd += " --optimisation_level none"; // issue 22608 } else if ( optim_level && hyp && !useBndRecovery ) { - if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 5 ) { - const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; - cmd += " --optimisation_level "; - cmd += level[ hyp->myOptimizationLevel ]; - } + const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; + const short myOpt = hyp->myOptimizationLevel; + + if ( myOpt >= 0 && myOpt < 5 && ( algoId == MGTetra || ( algoId == MGTetraHPC && myOpt != 3 ) ) ) { + cmd += " --optimisation_level "; + cmd += level[ myOpt ]; + } } // to create internal nodes @@ -1715,101 +1894,66 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h cmd += " --internalpoints no"; } - // verbose mode - if ( verbose && hyp ) { - cmd += " --verbose " + SMESH_Comment( hyp->myVerboseLevel ); - } - - // boundary recovery version - // if ( useBndRecovery ) { - // cmd += " -C"; - // } - - // to use FEM correction - // if ( fem && hyp && hyp->myToUseFemCorrection) { - // cmd += " -FEM"; - // } - - // to remove initial central point. - if ( rem && hyp && hyp->myToRemoveCentralPoint ) { - if ( forExecutable ) - cmd += " --no_initial_central_point"; - else - cmd += " --centralpoint no"; - } + if ( hyp ) + { + // verbose mode + if ( verbose ) { + cmd += " --verbose " + SMESH_Comment( hyp->myVerboseLevel ); + } - // options as text - // if ( hyp && !hyp->myTextOption.empty() ) { - // cmd += " " + hyp->myTextOption; - // } + // to remove initial central point. + if ( rem && hyp->myToRemoveCentralPoint ) { + if ( forExecutable ) + cmd += " --no_initial_central_point"; + else + cmd += " --centralpoint no"; + } - // min/max size - if ( hyp ) - { if ( hyp->GetMinSize() > 0 ) cmd += " --min_size " + SMESH_Comment( hyp->GetMinSize() ); + if ( hyp->GetMaxSize() > 0 ) cmd += " --max_size " + SMESH_Comment( hyp->GetMaxSize() ); - } - // to define volumic gradation. - if ( gra && hyp ) - { - cmd += " --gradation " + SMESH_Comment( hyp->myGradation ); - } + // to define volumic gradation. + if ( gra ) + cmd += " --gradation " + SMESH_Comment( hyp->myGradation ); + + if ( hyp->GetUseNumOfThreads() ) + { + cmd += " --max_number_of_threads " + SMESH_Comment( hyp->GetNumOfThreads() ); + const char* pthreadMode[] = { "none" , "aggressive" , "safe" }; + const char* parallelMode[] = { "none", "reproducible_given_max_number_of_threads", "reproducible", "aggressive" }; + + if ( algoId == MGTetra && hyp->myPthreadModeMG >= 1 && hyp->myPthreadModeMG < 3 ) { + cmd += " --pthreads_mode "; + cmd += pthreadMode[ hyp->myPthreadModeMG ]; + } + else if ( algoId == MGTetraHPC && hyp->myPthreadModeMGHPC >= 1 && hyp->myPthreadModeMGHPC < 4 ) + { + cmd += " --parallel_strategy "; + cmd += parallelMode[ hyp->myPthreadModeMGHPC ]; + } + } - if ( hyp ) - { // proximity if ( hyp->GetUseVolumeProximity() ) { cmd += " --volume_proximity_layers " + SMESH_Comment( hyp->GetNbVolumeProximityLayers() ); } - - std::string option, value; - bool isDefault; - const TOptionValues* options[] = { & hyp->_option2value, & hyp->_customOption2value }; - for ( int iOp = 0; iOp < 2; ++iOp ) - { - TOptionValues::const_iterator o2v = options[iOp]->begin(); - for ( ; o2v != options[iOp]->end(); ++o2v ) - { - option = o2v->first; - value = hyp->GetOptionValue( option, &isDefault ); - - if ( isDefault ) - continue; - if ( value.empty() )//value == NoValue() ) - { - if ( hyp->_defaultOptionValues.count( option )) - continue; // non-custom option with no value - //value.clear(); - } - if ( strncmp( "no", option.c_str(), 2 ) == 0 ) // options w/o values: --no_* - { - if ( !value.empty() && ToBool( value ) == false ) - continue; - value.clear(); - } - if ( option[0] != '-' ) - cmd += " --"; - else - cmd += " "; - cmd += option + " " + value; - } - } + + hyp->SetAdvancedOptionsInCommandLine( cmd ); } #ifdef WIN32 cmd += " < NUL"; #endif - return cmd; } //================================================================================ /*! - * \brief Return a unique file name + * \brief Return a unique file name for MGTetra */ //================================================================================ @@ -1835,15 +1979,51 @@ std::string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hy return aGenericName.ToCString(); } +//================================================================================ +/*! + * \brief Return a unique file name when running MGTetra HPC + */ +//================================================================================ + +std::string GHS3DPlugin_Hypothesis::GetFileNameHPC(const GHS3DPlugin_Hypothesis* hyp) +{ + std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory(); + if ( !SMESH_File( aTmpDir ).exists() ) + aTmpDir = Kernel_Utils::GetTmpDirByPath( aTmpDir ); + + const char lastChar = *aTmpDir.rbegin(); +#ifdef WIN32 + if(lastChar != '\\') aTmpDir+='\\'; +#else + if(lastChar != '/') aTmpDir+='/'; +#endif + + TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); + aGenericName += "MGTETRAHPC_"; + aGenericName += getpid(); + aGenericName += "_"; + aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString()); + + return aGenericName.ToCString(); +} + //================================================================================ /* * Return the name of executable */ //================================================================================ -std::string GHS3DPlugin_Hypothesis::GetExeName() +std::string GHS3DPlugin_Hypothesis::GetExeName( ImplementedAlgorithms algoId ) { - return "mg-tetra.exe"; + switch ( algoId ) + { + case MGTetra: + return "mg-tetra.exe"; + case MGTetraHPC: + return "mg-tetra_hpc.exe"; + default: + throw( "Undefined algorithm id: "); + } } //================================================================================ diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index 28279b2..fd8c951 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -183,6 +183,36 @@ public: */ void SetVerboseLevel(short level); short GetVerboseLevel() const; + /*! + * Implemented algorithms to be executed [0,1] + * 0 - MGTetra-HPC + * 1 - MGTetra + */ + enum ImplementedAlgorithms { MGTetraHPC = 0, MGTetra }; + void SetAlgorithm(ImplementedAlgorithms algoId); + ImplementedAlgorithms GetAlgorithm() const; + /*! + * Set Get for flag to use pthread parallel version of the algorithm + */ + void SetUseNumOfThreads(bool setUseOfThreads); + bool GetUseNumOfThreads() const; + /*! + * Set Get num of threads to be used by MGTetra algorithms + */ + void SetNumOfThreads(short numOfThreads); + short GetNumOfThreads() const; + /*! + * Set Get pthread mode used for MGTetra + */ + enum PThreadMode { PThreadNone = 0, PThreadAggressive, Safe }; + void SetPthreadMode(PThreadMode pthreadMode ); + PThreadMode GetPthreadMode() const; + /*! + * Set Get paralle mode used for MGTetra HPC + */ + enum ParallelMode { ParallelNone = 0, ReproducibleGivenMaxNumThreads, Reproducible, ParallelAggressive }; + void SetParallelMode(ParallelMode parallelMode ); + ParallelMode GetParallelMode() const; /*! * To create new nodes */ @@ -211,7 +241,7 @@ public: * To set hiden/undocumented/advanced options */ void SetAdvancedOption(const std::string& option); - std::string GetAdvancedOption() const; + std::string GetAdvancedOption() const; /*! * To define the volumic gradation */ @@ -240,16 +270,20 @@ public: void ClearOption(const std::string& optionName); TOptionValues GetOptionValues() const; const TOptionValues& GetCustomOptionValues() const { return _customOption2value; } - //static inline const char* NoValue() { return "_"; } + + // bool isMGTetraHPCOptions( std::string & option ) const; + /*! + * \brief To set the advanced options in the execution command line + */ + void SetAdvancedOptionsInCommandLine( std::string & cmd ) const; + //static inline const char* NoValue() { return "_"; } // struct TEnforcedEdge { // long ID; // long node1; // long node2; // std::string groupName; // }; - - /*! * \brief Return command to run MG-Tetra mesher excluding file prefix (-f) */ @@ -260,10 +294,14 @@ public: * \brief Return a unique file name */ static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp); + /*! + * \brief Return a unique file name for MGTetraHPC will have a GHS3D prefix + */ + static std::string GetFileNameHPC(const GHS3DPlugin_Hypothesis* hyp); /*! * \brief Return the name of executable */ - static std::string GetExeName(); + static std::string GetExeName( ImplementedAlgorithms algoId ); /*! * To set an enforced vertex @@ -331,6 +369,11 @@ public: static inline double DefaultGradation() { return 1.05; } static bool DefaultUseVolumeProximity() { return false; } static int DefaultNbVolumeProximityLayers() { return 2; } + static short DefaultAlgorithm() { return MGTetra; } + static short DefaultNumOfThreads() { return 4; } + static bool DefaultUseNumOfThreads() { return true; } + static short DefaultMyPthreadMode() { return 2; } //reproducible_given_max_of_threads + static short DefaultMyPthreadModeHPC() { return 1; } // safe void SetMinMaxSizeDefault( double theMinSize, double theMaxSize ) { myMinSizeDefault = theMinSize; myMaxSizeDefault = theMaxSize; } @@ -374,13 +417,19 @@ protected: double myGradation; bool myUseVolumeProximity; int myNbVolumeProximityLayers; + short myAlgorithm; //member used to pivot between MG-Tetra and MG-Tetra + short myNumOfThreads; + bool myUseNumOfThreads; + short myPthreadModeMG; + short myPthreadModeMGHPC; double myMinSize, myMinSizeDefault; double myMaxSize, myMaxSizeDefault; //std::string myTextOption; + TOptionValues _option2value, _customOption2value; // user defined values TOptionValues _defaultOptionValues; // default values - TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option + TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option TGHS3DEnforcedVertexList _enfVertexList; TGHS3DEnforcedVertexCoordsValues _enfVertexCoordsSizeList; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx index 1713aa4..f9bf94b 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -241,7 +241,7 @@ void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level) (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; if ( l < ::GHS3DPlugin_Hypothesis::None || l > ::GHS3DPlugin_Hypothesis::Strong ) - THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM ); + THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level", SALOME::BAD_PARAM ); ASSERT(myBaseImpl); this->GetImpl()->SetOptimizationLevel(l); @@ -258,6 +258,121 @@ CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel() return this->GetImpl()->GetOptimizationLevel(); } +//======================================================================= +//function : SetAlgorithm +//======================================================================= +void GHS3DPlugin_Hypothesis_i::SetAlgorithm(CORBA::Short algoId) +{ + ::GHS3DPlugin_Hypothesis::ImplementedAlgorithms algo = + (::GHS3DPlugin_Hypothesis::ImplementedAlgorithms) algoId; + if ( algo != ::GHS3DPlugin_Hypothesis::MGTetra && algo != ::GHS3DPlugin_Hypothesis::MGTetraHPC ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid algorithm type", SALOME::BAD_PARAM ); + + ASSERT(myBaseImpl); + this->GetImpl()->SetAlgorithm(algo); + SMESH::TPythonDump() << _this() << ".SetAlgorithm( " << algoId << " )"; +} + +//======================================================================= +//function : GetAlgorithm +//======================================================================= +CORBA::Short GHS3DPlugin_Hypothesis_i::GetAlgorithm() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetAlgorithm(); +} + +//======================================================================= +//function : SetUseNumOfThreads +//======================================================================= +void GHS3DPlugin_Hypothesis_i::SetUseNumOfThreads(CORBA::Boolean setThread) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetUseNumOfThreads(setThread); + SMESH::TPythonDump() << _this() << ".SetUseNumOfThreads( " << setThread << " )"; +} + +//======================================================================= +//function : GetUseNumOfThreads +//======================================================================= +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetUseNumOfThreads() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetUseNumOfThreads(); +} + +//======================================================================= +//function : SetNumOfThreads +//======================================================================= +void GHS3DPlugin_Hypothesis_i::SetNumOfThreads(CORBA::Short numOfThreads) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetNumOfThreads(numOfThreads); + SMESH::TPythonDump() << _this() << ".SetNumOfThreads( " << numOfThreads << " )"; +} + +//======================================================================= +//function : GetNumOfThreads +//======================================================================= +CORBA::Short GHS3DPlugin_Hypothesis_i::GetNumOfThreads() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetNumOfThreads(); +} + +//======================================================================= +//function : SetNumOfThreads +//======================================================================= +void GHS3DPlugin_Hypothesis_i::SetPthreadMode(CORBA::Short pThreadMode) +{ + ::GHS3DPlugin_Hypothesis::PThreadMode mode = + (::GHS3DPlugin_Hypothesis::PThreadMode) pThreadMode; + + if ( mode < ::GHS3DPlugin_Hypothesis::PThreadNone || + mode > ::GHS3DPlugin_Hypothesis::Safe ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid pthreadMode type", SALOME::BAD_PARAM ); + + + ASSERT(myBaseImpl); + this->GetImpl()->SetPthreadMode(mode); + SMESH::TPythonDump() << _this() << ".SetPthreadMode( " << pThreadMode << " )"; +} + +//======================================================================= +//function : GetNumOfThreads +//======================================================================= +CORBA::Short GHS3DPlugin_Hypothesis_i::GetPthreadMode() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetPthreadMode(); +} + +//======================================================================= +//function : SetNumOfThreads +//======================================================================= +void GHS3DPlugin_Hypothesis_i::SetParallelMode(CORBA::Short parallelMode) +{ + ::GHS3DPlugin_Hypothesis::ParallelMode mode = + (::GHS3DPlugin_Hypothesis::ParallelMode) parallelMode; + + if ( mode < ::GHS3DPlugin_Hypothesis::ParallelNone || + mode > ::GHS3DPlugin_Hypothesis::ParallelAggressive ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid parallelMode type", SALOME::BAD_PARAM ); + + ASSERT(myBaseImpl); + this->GetImpl()->SetParallelMode(mode); + SMESH::TPythonDump() << _this() << ".SetParallelMode( " << parallelMode << " )"; +} + +//======================================================================= +//function : GetNumOfThreads +//======================================================================= +CORBA::Short GHS3DPlugin_Hypothesis_i::GetParallelMode() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetParallelMode(); +} + //======================================================================= //function : SetWorkingDirectory //======================================================================= diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx index 050a8e1..b9df09b 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx @@ -93,6 +93,33 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: */ void SetOptimizationLevel(CORBA::Short level); CORBA::Short GetOptimizationLevel(); + /*! + * Algorithm Id: 0-MGTetra HPC, 1-MGTetra + */ + void SetAlgorithm(CORBA::Short algoId); + CORBA::Short GetAlgorithm(); + /*! + * Flag for set get optional use parallelism in MGTetra + */ + void SetUseNumOfThreads(CORBA::Boolean useThreads); + CORBA::Boolean GetUseNumOfThreads(); + /*! + * Get set number of threads to use on the parallel MGTetra algorithm + */ + void SetNumOfThreads(CORBA::Short numThreads); + CORBA::Short GetNumOfThreads(); + /*! + * For MGTetra + * PthreadMode: 0-PThreadNone, 1-PThreadAggressive, 2-Safe + */ + void SetPthreadMode(CORBA::Short pThreadMode); + CORBA::Short GetPthreadMode(); + /*! + * For MGTetra HPC + * SetParallelMode level: 0-ParallelNone, 1-ReproducibleGivenMaxNumThreads, 2-Reproducible, 3-ParallelAggressive + */ + void SetParallelMode(CORBA::Short parallelMode); + CORBA::Short GetParallelMode(); /*! * Path to working directory */ diff --git a/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx index 7e5cf77..a27c823 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_OptimizerHypothesis.cxx @@ -153,7 +153,7 @@ bool GHS3DPlugin_OptimizerHypothesis::SetParametersByDefaults(const TDefaults& std::string GHS3DPlugin_OptimizerHypothesis::CommandToRun(const GHS3DPlugin_OptimizerHypothesis* hyp) { - SMESH_Comment cmd( GetExeName() ); + SMESH_Comment cmd( GetExeName( (ImplementedAlgorithms) 1 ) ); cmd << " --max_memory " << (( hyp && hyp->myMaximumMemory > 0 ) ? hyp->myMaximumMemory : DefaultMaximumMemory()); diff --git a/src/GUI/GHS3DPluginGUI_AdvWidget.cxx b/src/GUI/GHS3DPluginGUI_AdvWidget.cxx index b2dc3a1..e70781f 100644 --- a/src/GUI/GHS3DPluginGUI_AdvWidget.cxx +++ b/src/GUI/GHS3DPluginGUI_AdvWidget.cxx @@ -135,3 +135,23 @@ void GHS3DPluginGUI_AdvWidget::itemChanged(QTreeWidgetItem * tblRow, int column) myOptionTable->blockSignals( false ); } } + +void GHS3DPluginGUI_AdvWidget::EnableAdvancedOptions( bool isMGTetra ) +{ + int iRow = 0, nbRows = myOptionTable->topLevelItemCount(); + // hard coded: register all possible options here + std::vector_commonOptions = { "split_overconstrained_tetrahedra" }; + std::vector::iterator tk; + for ( ; iRow < nbRows; ++iRow ) + { + // Have to allow advanced option for MGTetra HPC to work + tk = std::find( _commonOptions.begin(), + _commonOptions.end(), + myOptionTable->topLevelItem( iRow )->data( NAME_COL, PARAM_NAME ).toString().toStdString() + ); + + if ( tk == _commonOptions.end() ) + myOptionTable->topLevelItem( iRow )->setDisabled( !isMGTetra ); + + } +} \ No newline at end of file diff --git a/src/GUI/GHS3DPluginGUI_Dlg.h b/src/GUI/GHS3DPluginGUI_Dlg.h index 7fb6d65..8bb619c 100644 --- a/src/GUI/GHS3DPluginGUI_Dlg.h +++ b/src/GUI/GHS3DPluginGUI_Dlg.h @@ -49,7 +49,7 @@ public: void AddOption( const char* name_value_type, bool isCustom = false ); void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt ); - + void EnableAdvancedOptions( bool isMGTetra ); public slots: void itemChanged(QTreeWidgetItem * tblRow, int column); diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index bbdf366..948855b 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -58,7 +59,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -303,6 +306,8 @@ GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QStrin myMaxSizeCheck(0), myMinSizeSpin(0), myMaxSizeSpin(0), + myNumOfThreadsCheck(0), + myNumOfThreadsSpin(0), myGradationCheck(0), myGradationSpin(0), myUseProximityGroup(0), @@ -314,7 +319,9 @@ GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QStrin myPThreadsModeCombo(0), myNumberOfThreadsSpin(0), mySmoothOffSliversCheck(0), - myCreateNewNodesCheck(0) + myCreateNewNodesCheck(0), + myPthreadMode(0), + myParallelMode(0) { GeomToolSelected = NULL; GeomToolSelected = getGeomSelectionTool(); @@ -354,6 +361,70 @@ bool GHS3DPluginGUI_HypothesisCreator::isOptimization() const return ( hypType() == GHS3DPlugin_OptimizerHypothesis::GetHypType() ); } +void GHS3DPluginGUI_HypothesisCreator::onRadioButtonSelect() +{ + onNumOfThreadsCheck(); + + // Disable selection of standart+ + QStandardItemModel * model = qobject_cast(myOptimizationLevelCombo->model()); + if(!model) return; + QStandardItem * item = model->item( GHS3DPlugin_Hypothesis::StandardPlus ); + if(!item) return; + + if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetra ) + { + // Enable selection of stadart+ + item->setEnabled(true); + // Set possibility to check memory options again. + myAdvWidget->maxMemoryCheck ->setEnabled( true ); + myAdvWidget->initialMemoryCheck ->setEnabled( true ); + + myAdvWidget->EnableAdvancedOptions( true ); + myEnfGroup->setEnabled( true ); + myEnfMeshGroup->setEnabled( true ); + } + else if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetraHPC ) + { + // Disable selection of stadart+ + item->setEnabled(false); + // Set to false memory checks and disable checkbox + myAdvWidget->maxMemoryCheck ->setChecked( false ); + myAdvWidget->initialMemoryCheck ->setChecked( false ); + myAdvWidget->maxMemoryCheck ->setEnabled( false ); + myAdvWidget->initialMemoryCheck ->setEnabled( false ); + myAdvWidget->EnableAdvancedOptions( false ); + myEnfGroup->setEnabled( false ); + myEnfMeshGroup->setEnabled( false ); + } + +} + +void GHS3DPluginGUI_HypothesisCreator::onNumOfThreadsCheck() +{ + if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetra ) + { + if ( myNumOfThreadsCheck->isChecked() ) + myPthreadMode->setEnabled( true ); + else + myPthreadMode->setEnabled( false ); + + myParallelMode->setEnabled( false ); + } + else if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetraHPC ) + { + if ( myNumOfThreadsCheck->isChecked() ) + myParallelMode->setEnabled( true ); + else + myParallelMode->setEnabled( false ); + + myPthreadMode->setEnabled( false ); + } + else + { + + } +} + QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() { QFrame* fr = new QFrame( 0 ); @@ -419,26 +490,64 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() } else { + // Algorithm selection + QGroupBox* radioBottomGroup = new QGroupBox( tr("GHS3D_ALGO_SELECTION"), myStdGroup ); + myRadioBottomGroup = new QButtonGroup( radioBottomGroup ); + + QRadioButton * GM_MSH = new QRadioButton(tr("GHS3D_ALGO_MGTETRA"), radioBottomGroup ); + QRadioButton * GM_MSH_HPC = new QRadioButton(tr("GHS3D_ALGO_MGTETRAHPC"), radioBottomGroup ); + + myRadioBottomGroup->addButton( GM_MSH, 1 ); + myRadioBottomGroup->addButton( GM_MSH_HPC, 0 ); + GM_MSH->setChecked( true ); + + QGridLayout* radioBottomLayout = new QGridLayout( radioBottomGroup ); + radioBottomLayout->setSpacing( 4 ); + radioBottomLayout->setMargin( 11 ); + radioBottomLayout->addWidget( GM_MSH, 0, 0, 1, 1 ); + radioBottomLayout->addWidget( GM_MSH_HPC, 0, 1, 1, 1 ); + // Main parameters + QGroupBox* mainGroup = new QGroupBox( tr("GHS3D_MAIN_PARAMS"), myStdGroup ); + QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), mainGroup ); + QLabel* pthreadModeLbl = new QLabel( tr( "GHS3D_PTHREAD_MODE" ), mainGroup ); + QLabel* parallelStrat = new QLabel( tr( "GHS3D_PARALLE_STRAT" ), mainGroup ); + + myOptimizationLevelCombo = new QComboBox( mainGroup ); + myMinSizeCheck = new QCheckBox( tr("GHS3D_MIN_SIZE"), mainGroup ); + myMaxSizeCheck = new QCheckBox( tr("GHS3D_MAX_SIZE"), mainGroup ); + myNumOfThreadsCheck = new QCheckBox( tr("GHS3D_THREADS_SIZE"), mainGroup ); + myPthreadMode = new QComboBox( mainGroup ); + myParallelMode = new QComboBox( mainGroup ); + + myMinSizeSpin = new SMESHGUI_SpinBox( mainGroup ); + myMaxSizeSpin = new SMESHGUI_SpinBox( mainGroup ); + myNumOfThreadsSpin = new SalomeApp_IntSpinBox( 1, 128, 1, mainGroup ); - QGroupBox* mainGroup = new QGroupBox( tr("GHS3D_MAIN_PARAMS"), myStdGroup ); - QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), mainGroup ); - myOptimizationLevelCombo = new QComboBox( mainGroup ); - myMinSizeCheck = new QCheckBox( tr("GHS3D_MIN_SIZE"), mainGroup ); - myMaxSizeCheck = new QCheckBox( tr("GHS3D_MAX_SIZE"), mainGroup ); - myMinSizeSpin = new SMESHGUI_SpinBox( mainGroup ); - myMaxSizeSpin = new SMESHGUI_SpinBox( mainGroup ); myMinSizeCheck->setChecked( false ); myMaxSizeCheck->setChecked( false ); + myNumOfThreadsCheck->setChecked( false ); + myMinSizeSpin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); myMaxSizeSpin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); - myMinSizeSpin->setEnabled( false ); - myMaxSizeSpin->setEnabled( false ); - connect( myMinSizeCheck, SIGNAL( toggled(bool)), myMinSizeSpin, SLOT( setEnabled(bool))); - connect( myMaxSizeCheck, SIGNAL( toggled(bool)), myMaxSizeSpin, SLOT( setEnabled(bool))); + myNumOfThreadsSpin->setValue( 4 ); + + myMinSizeSpin ->setEnabled( false ); + myMaxSizeSpin ->setEnabled( false ); + myNumOfThreadsSpin->setEnabled(false); + myPthreadMode ->setEnabled( false ); + myParallelMode->setEnabled( false ); + + // ACTIONS ON BUTTOMS + connect( myMinSizeCheck, SIGNAL( toggled(bool)), myMinSizeSpin, SLOT( setEnabled(bool))); + connect( myMaxSizeCheck, SIGNAL( toggled(bool)), myMaxSizeSpin, SLOT( setEnabled(bool))); + connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), myNumOfThreadsSpin, SLOT( setEnabled(bool))); + connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), this, SLOT( onNumOfThreadsCheck() )); + connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), this, SLOT( onNumOfThreadsCheck() )); + connect( GM_MSH, SIGNAL( toggled( bool )),this, SLOT( onRadioButtonSelect() )); QGridLayout* mainLayout = new QGridLayout( mainGroup ); - mainLayout->setSpacing( 6 ); + mainLayout->setSpacing( 12 ); mainLayout->setMargin( 11 ); mainLayout->addWidget( optimizatiolLevelLbl, 0, 0, 1, 1 ); mainLayout->addWidget( myOptimizationLevelCombo, 0, 1, 1, 1 ); @@ -446,7 +555,13 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() mainLayout->addWidget( myMinSizeSpin, 1, 1, 1, 1 ); mainLayout->addWidget( myMaxSizeCheck, 2, 0, 1, 1 ); mainLayout->addWidget( myMaxSizeSpin, 2, 1, 1, 1 ); - + mainLayout->addWidget( myNumOfThreadsCheck, 3, 0, 1, 1 ); + mainLayout->addWidget( myNumOfThreadsSpin, 3, 1, 1, 1 ); + mainLayout->addWidget( pthreadModeLbl, 4, 0, 1, 1 ); + mainLayout->addWidget( myPthreadMode, 4, 1, 1, 1 ); + mainLayout->addWidget( parallelStrat, 5, 0, 1, 1 ); + mainLayout->addWidget( myParallelMode, 5, 1, 1, 1 ); + // Volume proximity QGroupBox* proxyGroup = new QGroupBox( tr("GHS3D_VOLUME_PROXIMITY"), myStdGroup ); @@ -484,10 +599,13 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() otherLayout->addWidget( myToMeshHolesCheck, 0, 0 ); otherLayout->addWidget( myToMakeGroupsOfDomains, 1, 0 ); + aStdLayout->addWidget( radioBottomGroup,row++, 0, 1, 2 ); + aStdLayout->addWidget( mainGroup, row++, 0, 1, 2 ); + aStdLayout->addWidget( proxyGroup, row++, 0, 1, 2 ); + aStdLayout->addWidget( otherGroup, row++, 0, 1, 2 ); - aStdLayout->addWidget( mainGroup, row++, 0, 1, 2 ); - aStdLayout->addWidget( proxyGroup, row++, 0, 1, 2 ); - aStdLayout->addWidget( otherGroup, row++, 0, 1, 2 ); + myPthreadMode->addItems( QStringList() << tr( "MODE_NONE" ) << tr( "MODE_AGGRESSIVE" ) << tr( "MODE_SAFE" ) ); + myParallelMode->addItems( QStringList() << tr( "MODE_NONE" ) << tr( "MODE_REPRODUCIBLE_GIVEN_MAX_THREADS" ) << tr( "MODE_REPRODUCIBLE" ) << tr( "MODE_AGGRESSIVE" ) ); } aStdLayout->setRowStretch( row, 10 ); @@ -549,7 +667,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup); myEnforcedTableWidget = new QTableWidget(myEnfGroup); - myEnforcedTableWidget ->setMinimumWidth(300); + myEnforcedTableWidget->setMinimumWidth(300); myEnforcedTableWidget->setRowCount( 0 ); myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTableWidget->setSortingEnabled(true); @@ -1459,7 +1577,12 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const } myToMeshHolesCheck ->setChecked ( data.myToMeshHoles ); myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains ); - myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel ); + + if ( data.myAlgorithm == GHS3DPlugin_Hypothesis::MGTetraHPC && data.myOptimizationLevel == GHS3DPlugin_Hypothesis::StandardPlus /*not implemented by MGTetraHPC*/ ) + myOptimizationLevelCombo ->setCurrentIndex( GHS3DPlugin_Hypothesis::None ); + else + myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel ); + if ( myOptimizationCombo ) // optimizer { myOptimizationCombo ->setCurrentIndex( data.myOptimization ); @@ -1471,14 +1594,19 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const } else { - myMinSizeSpin->setValue( data.myMinSize ); - myMinSizeCheck->setChecked( data.myUseMinSize ); - myMaxSizeSpin->setValue( data.myMaxSize ); - myMaxSizeCheck->setChecked( data.myUseMaxSize ); - myGradationCheck->setChecked( data.myUseGradation ); - myGradationSpin->setValue( data.myUseGradation ? data.myGradation : GHS3DPlugin_Hypothesis::DefaultGradation() ); - myUseProximityGroup->setChecked( data.myUseProximity ); - myNbProximityLayers->setValue( data.myNbProximityLayers ); + myRadioBottomGroup ->button( data.myAlgorithm )->setChecked( true ); + myMinSizeSpin ->setValue( data.myMinSize ); + myMinSizeCheck ->setChecked( data.myUseMinSize ); + myMaxSizeSpin ->setValue( data.myMaxSize ); + myMaxSizeCheck ->setChecked( data.myUseMaxSize ); + myGradationCheck ->setChecked( data.myUseGradation ); + myGradationSpin ->setValue( data.myUseGradation ? data.myGradation : GHS3DPlugin_Hypothesis::DefaultGradation() ); + myUseProximityGroup ->setChecked( data.myUseProximity ); + myNbProximityLayers ->setValue( data.myNbProximityLayers ); + myNumOfThreadsCheck ->setChecked( data.myUseNumOfThreads ); + myNumOfThreadsSpin ->setValue( data.myNumOfThreads ); + myPthreadMode ->setCurrentIndex( data.myPthreadMode ); + myParallelMode ->setCurrentIndex( data.myParallelMode ); } myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 ); myAdvWidget->maxMemorySpin ->setValue @@ -1501,7 +1629,7 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const myAdvWidget->AddOption( that->myCustomOptions[i].in() ); } myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN ); - + myAdvWidget->EnableAdvancedOptions( data.myAlgorithm == GHS3DPlugin_Hypothesis::MGTetra ); TEnfVertexList::const_iterator it; int rowCount = 0; @@ -1703,6 +1831,7 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data.myNumberOfThreads = 1; h_data.mySmoothOffSlivers = 1; } + h_data.myAlgorithm = h->GetAlgorithm(); h_data.myOptimizationLevel = h->GetOptimizationLevel(); h_data.myMinSize = h->GetMinSize(); h_data.myMaxSize = h->GetMaxSize(); @@ -1731,6 +1860,10 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& //h_data.myTextOption = h->GetAdvancedOption(); h_data.myLogInStandardOutput = h->GetStandardOutputLog(); h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess(); + h_data.myUseNumOfThreads = h->GetUseNumOfThreads(); + h_data.myNumOfThreads = h->GetNumOfThreads(); + h_data.myPthreadMode = h->GetPthreadMode(); + h_data.myParallelMode = h->GetParallelMode(); GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; that->myOptions = h->GetOptionValues(); @@ -1791,19 +1924,28 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD if( isCreation() ) SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() ); + if ( opt->_is_nil() ) + { + h->SetAlgorithm ((CORBA::Short) h_data.myAlgorithm ); + h->SetUseNumOfThreads ( h_data.myUseNumOfThreads ); + h->SetNumOfThreads ( (CORBA::Short) h_data.myNumOfThreads ); + h->SetPthreadMode ( (CORBA::Short) h_data.myPthreadMode ); + h->SetParallelMode ( (CORBA::Short) h_data.myParallelMode ); + h->SetGradation ( h_data.myGradation ); + h->SetToMeshHoles ( h_data.myToMeshHoles ); + h->SetToMakeGroupsOfDomains ( h_data.myToMakeGroupsOfDomains ); + h->SetVolumeProximity ( h_data.myUseProximity ); + h->SetNbVolumeProximityLayers ((CORBA::Short) h_data.myNbProximityLayers ); + } + + // Common existing options optimization a MGTetra && MGTetraHPC h->SetOptimizationLevel ((CORBA::Short) h_data.myOptimizationLevel ); h->SetMinSize ( h_data.myUseMinSize ? h_data.myMinSize : 0 ); h->SetMaxSize ( h_data.myUseMaxSize ? h_data.myMaxSize : 0 ); h->SetMinMaxSizeDefault ( this->myMinSizeDefault, this->myMaxSizeDefault ); - h->SetGradation ( h_data.myGradation ); - h->SetVolumeProximity ( h_data.myUseProximity ); - h->SetNbVolumeProximityLayers ((CORBA::Short) h_data.myNbProximityLayers ); - h->SetToMeshHoles ( h_data.myToMeshHoles ); - h->SetToMakeGroupsOfDomains ( h_data.myToMakeGroupsOfDomains ); h->SetMaximumMemory ( h_data.myMaximumMemory ); h->SetInitialMemory ( h_data.myInitialMemory ); - h->SetInitialMemory ( h_data.myInitialMemory ); h->SetKeepFiles ( h_data.myKeepFiles ); h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() ); h->SetVerboseLevel ( h_data.myVerboseLevel ); @@ -1812,6 +1954,7 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD //h->SetFEMCorrection ( h_data.myFEMCorrection ); h->SetStandardOutputLog ( h_data.myLogInStandardOutput ); h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess ); + if ( !opt->_is_nil() ) { @@ -1915,6 +2058,11 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisDat h_data.myNbProximityLayers = myNbProximityLayers->value(); h_data.myToMeshHoles = myToMeshHolesCheck->isChecked(); h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked(); + h_data.myAlgorithm = myRadioBottomGroup->checkedId(); + h_data.myUseNumOfThreads = myNumOfThreadsCheck->isChecked(); + h_data.myNumOfThreads = myNumOfThreadsSpin->value(); + h_data.myPthreadMode = myPthreadMode->currentIndex(); + h_data.myParallelMode = myParallelMode->currentIndex(); } h_data.myMaximumMemory = float( myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1 ); h_data.myInitialMemory = float( myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1 ); diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h index 2212dc5..7a69145 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h @@ -49,6 +49,7 @@ #include CORBA_SERVER_HEADER(SMESH_Mesh) class QWidget; +class QButtonGroup; class QComboBox; class QCheckBox; class QLineEdit; @@ -156,6 +157,8 @@ typedef struct short myVerboseLevel; TEnfVertexList myEnforcedVertices; TEnfMeshList myEnforcedMeshes; + short myAlgorithm, myNumOfThreads, myPthreadMode, myParallelMode; + bool myUseNumOfThreads; int myOptimization, mySplitOverConstrained, myPThreadsMode, myNumberOfThreads; bool mySmoothOffSlivers; @@ -208,6 +211,8 @@ protected slots: void onRemoveEnforcedMesh(); //void synchronizeEnforcedMesh(); void checkEnfMeshIsDefined(); + void onRadioButtonSelect(); + void onNumOfThreadsCheck(); signals: void vertexDefined(bool); @@ -230,6 +235,8 @@ private: QCheckBox* myMaxSizeCheck; SMESHGUI_SpinBox* myMinSizeSpin; SMESHGUI_SpinBox* myMaxSizeSpin; + QCheckBox* myNumOfThreadsCheck; + SalomeApp_IntSpinBox* myNumOfThreadsSpin; mutable double myMinSizeDefault, myMaxSizeDefault; // proximity QCheckBox* myGradationCheck; @@ -246,6 +253,9 @@ private: SalomeApp_IntSpinBox* myNumberOfThreadsSpin; QCheckBox* mySmoothOffSliversCheck; QCheckBox* myCreateNewNodesCheck; + QComboBox* myPthreadMode; + QComboBox* myParallelMode; + QButtonGroup* myRadioBottomGroup; QWidget* myAdvGroup; GHS3DPluginGUI_AdvWidget* myAdvWidget; diff --git a/src/GUI/GHS3DPlugin_msg_en.ts b/src/GUI/GHS3DPlugin_msg_en.ts index 5271493..e5cca7c 100644 --- a/src/GUI/GHS3DPlugin_msg_en.ts +++ b/src/GUI/GHS3DPlugin_msg_en.ts @@ -60,8 +60,52 @@ Light - LEVEL_MEDIUM - Medium (standard) + LEVEL_MEDIUM + Medium (standard) + + + GHS3D_PTHREAD_MODE + Pthread Mode + + + GHS3D_PARALLE_STRAT + Parallel Strategy (HPC) + + + MODE_NONE + None + + + MODE_AGGRESSIVE + Aggressive + + + MODE_SAFE + Safe + + + MODE_REPRODUCIBLE + Reproducible + + + MODE_REPRODUCIBLE_GIVEN_MAX_THREADS + Reproducible Given Max Number of Threads + + + GHS3D_ALGO_SELECTION + Algorithm selection + + + GHS3D_ALGO_MGTETRA + MG-Tetra + + + GHS3D_ALGO_MGTETRAHPC + MG-Tetra HPC + + + GHS3D_THREADS_SIZE + Maximal number of threads LEVEL_STANDARDPLUS diff --git a/src/GUI/GHS3DPlugin_msg_fr.ts b/src/GUI/GHS3DPlugin_msg_fr.ts index 37f7e4a..b42f7bb 100644 --- a/src/GUI/GHS3DPlugin_msg_fr.ts +++ b/src/GUI/GHS3DPlugin_msg_fr.ts @@ -63,6 +63,50 @@ LEVEL_MEDIUM Moyen (standard) + + GHS3D_PTHREAD_MODE + Mode Pthread + + + GHS3D_PARALLE_STRAT + Statégie Parallèle(HPC) + + + MODE_NONE + Zéro + + + MODE_AGGRESSIVE + Agressif + + + MODE_SAFE + Sûr + + + MODE_REPRODUCIBLE + Reproductible + + + MODE_REPRODUCIBLE_GIVEN_MAX_THREADS + Reproductible étant donné le nombre max de threads + + + GHS3D_ALGO_SELECTION + Sélection d'algorithme + + + GHS3D_ALGO_MGTETRA + MG-Tetra + + + GHS3D_ALGO_MGTETRAHPC + MG-Tetra HPC + + + GHS3D_THREADS_SIZE + Nombre max de threads + LEVEL_STANDARDPLUS Standard+