From: Yoann Audouin Date: Mon, 14 Nov 2022 14:40:36 +0000 (+0100) Subject: Adding First files X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=38ce511dfecefdbed43be826f5c5f7ad27077e86;p=modules%2Fsmesh.git Adding First files --- diff --git a/src/SMESH/CMakeLists.txt b/src/SMESH/CMakeLists.txt index 88d42d875..ec3761798 100644 --- a/src/SMESH/CMakeLists.txt +++ b/src/SMESH/CMakeLists.txt @@ -77,6 +77,8 @@ SET(_link_LIBRARIES SET(SMESHimpl_HEADERS SMESH_Gen.hxx SMESH_Mesh.hxx + SMESH_SequentialMesh.hxx + SMESH_ParallelMesh.hxx SMESH_subMesh.hxx SMESH_subMeshEventListener.hxx SMESH_Hypothesis.hxx @@ -102,6 +104,8 @@ SET(SMESHimpl_SOURCES memoire.h SMESH_Gen.cxx SMESH_Mesh.cxx + SMESH_SequentialMesh.cxx + SMESH_ParallelMesh.cxx SMESH_subMesh.cxx SMESH_Hypothesis.cxx SMESH_Algo.cxx diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 9c9606499..e2e6644fe 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -391,32 +391,33 @@ class SMESH_EXPORT SMESH_Mesh // Parallel computation functions #ifdef WIN32 - void Lock() {}; - void Unlock() {}; + virtual void Lock() {}; + virtual void Unlock() {}; - int GetNbThreads(){return _NbThreads;}; - void SetNbThreads(long nbThreads){std::cout << "Warning Parallel Meshing is disabled on Windows it will behave as a slower normal compute" << std::endl;_NbThreads=nbThreads;}; + virtual int GetNbThreads(){return _NbThreads;}; + virtual void SetNbThreads(long nbThreads){std::cout << "Warning Parallel Meshing is disabled on Windows it will behave as a slower normal compute" << std::endl;_NbThreads=nbThreads;}; - void InitPoolThreads(){}; - void DeletePoolThreads(){}; - void wait(){} + virtual void InitPoolThreads(){}; + virtual void DeletePoolThreads(){}; + virtual void wait(){} - bool IsParallel(){return _NbThreads > 0;} + virtual bool IsParallel(){return _NbThreads > 0;} #else - void Lock() {_my_lock.lock();}; - void Unlock() {_my_lock.unlock();}; + virtual void Lock() {_my_lock.lock();}; + virtual void Unlock() {_my_lock.unlock();}; - int GetNbThreads(){return _NbThreads;}; - void SetNbThreads(long nbThreads){_NbThreads=nbThreads;}; + virtual int GetNbThreads(){return _NbThreads;}; + virtual void SetNbThreads(long nbThreads){_NbThreads=nbThreads;}; - void InitPoolThreads(){_pool = new boost::asio::thread_pool(_NbThreads);}; - void DeletePoolThreads(){delete _pool;}; + virtual void InitPoolThreads(){_pool = new boost::asio::thread_pool(_NbThreads);}; + virtual void DeletePoolThreads(){delete _pool;}; - void wait(){_pool->join(); DeletePoolThreads(); InitPoolThreads(); } + virtual void wait(){_pool->join(); DeletePoolThreads(); InitPoolThreads(); } - bool IsParallel(){return _NbThreads > 0;} + virtual bool IsParallel(){return _NbThreads > 0;} #endif + //TODO: to remove only used by ParallelMesh void CreateTmpFolder(); void DeleteTmpFolder(); diff --git a/src/SMESH/SMESH_ParallelMesh.cxx b/src/SMESH/SMESH_ParallelMesh.cxx new file mode 100644 index 000000000..3fabf7b38 --- /dev/null +++ b/src/SMESH/SMESH_ParallelMesh.cxx @@ -0,0 +1,28 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +// File : SMESH_ParallelMesh.cxx +// Author : Yoann AUDOUIN, EDF +// Module : SMESH +// +#include "SMESH_ParallelMesh.hxx" + diff --git a/src/SMESH/SMESH_ParallelMesh.hxx b/src/SMESH/SMESH_ParallelMesh.hxx new file mode 100644 index 000000000..c5938424d --- /dev/null +++ b/src/SMESH/SMESH_ParallelMesh.hxx @@ -0,0 +1,62 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +// File : SMESH_ParallelMesh.hxx +// Author : Yoann AUDOUIN, EDF +// Module : SMESH +// +#ifndef _SMESH_PARALLELMESH_HXX_ +#define _SMESH_PARALLELMESH_HXX_ + +#include "SMESH_Mesh.hxx" + +class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh +{ + public: + SMESH_ParallelMesh(int theLocalId, + SMESH_Gen* theGen, + bool theIsEmbeddedMode, + SMESHDS_Document* theDocument); + + virtual ~SMESH_ParallelMesh(); + + void Lock() override {_my_lock.lock();}; + void Unlock() override {_my_lock.unlock();}; + + int GetNbThreads() override{return _NbThreads;}; + void SetNbThreads(long nbThreads) override{_NbThreads=nbThreads;}; + + void InitPoolThreads() override{_pool = new boost::asio::thread_pool(_NbThreads);}; + void DeletePoolThreads() override{delete _pool;}; + + void wait() override{_pool->join(); DeletePoolThreads(); InitPoolThreads(); }; + + bool IsParallel() override{return _NbThreads > 0;}; + + void CreateTmpFolder(); + void DeleteTmpFolder(); + + private: + boost::filesystem::path tmp_folder; + boost::asio::thread_pool * _pool = nullptr; //thread pool for computation +}; +#endif diff --git a/src/SMESH/SMESH_SequentialMesh.cxx b/src/SMESH/SMESH_SequentialMesh.cxx new file mode 100644 index 000000000..3b556403f --- /dev/null +++ b/src/SMESH/SMESH_SequentialMesh.cxx @@ -0,0 +1,27 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +// File : SMESH_SequentialMesh.cxx +// Author : Yoann AUDOUIN, EDF +// Module : SMESH +// +#include "SMESH_SequentialMesh.hxx" diff --git a/src/SMESH/SMESH_SequentialMesh.hxx b/src/SMESH/SMESH_SequentialMesh.hxx new file mode 100644 index 000000000..24bfc8219 --- /dev/null +++ b/src/SMESH/SMESH_SequentialMesh.hxx @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +// File : SMESH_SequentialMesh.hxx +// Author : Yoann AUDOUIN, EDF +// Module : SMESH +// +#ifndef _SMESH_SEQUENTIALMESH_HXX_ +#define _SMESH_SEQUENTIALMESH_HXX_ + +#include "SMESH_Mesh.hxx" + +class SMESH_EXPORT SMESH_SequentialMesh: public SMESH_Mesh +{ + public: + SMESH_SequentialMesh(int theLocalId, + SMESH_Gen* theGen, + bool theIsEmbeddedMode, + SMESHDS_Document* theDocument); + + virtual ~SMESH_SequentialMesh(); + + void Lock() override {}; + void Unlock() override {}; + + int GetNbThreads() override {return 0;}; + void SetNbThreads(long nbThreads) {}; + + void InitPoolThreads() override {}; + void DeletePoolThreads() override {}; + void wait() override {}; + + bool IsParallel() override {return false;}; +}; +#endif