1 // Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESH_ParallelMesh.hxx
24 // Author : Yoann AUDOUIN, EDF
27 #ifndef _SMESH_PARALLELMESH_HXX_
28 #define _SMESH_PARALLELMESH_HXX_
30 #include "SMESH_Mesh.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "SMESH_subMesh.hxx"
35 class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
38 SMESH_ParallelMesh(int theLocalId,
40 bool theIsEmbeddedMode,
41 SMESHDS_Document* theDocument);
43 virtual ~SMESH_ParallelMesh();
46 void Lock() override {_my_lock.lock();};
47 void Unlock() override {_my_lock.unlock();};
49 int GetNbThreads() override{return _NbThreads;};
50 void SetNbThreads(long nbThreads) override{_NbThreads=nbThreads;};
52 void InitPoolThreads() override {_pool = new boost::asio::thread_pool(_NbThreads);};
53 void DeletePoolThreads() override {delete _pool;};
55 void wait() override {_pool->join(); DeletePoolThreads(); InitPoolThreads(); };
57 bool IsParallel() override {return _NbThreads > 0;};
59 void CreateTmpFolder();
60 void DeleteTmpFolder();
62 boost::filesystem::path GetTmpFolder() override {return tmp_folder;};
63 boost::asio::thread_pool* GetPool() override {return _pool;};
65 void Lock() override {};
66 void Unlock() override {};
68 int GetNbThreads() override {return 0;};
69 void SetNbThreads(long nbThreads) {(void) nbThreads;};
71 void InitPoolThreads() override {};
72 void DeletePoolThreads() override {};
73 void wait() override {};
75 bool IsParallel() override {return false;};
77 void CreateTmpFolder();
78 void DeleteTmpFolder();
81 bool ComputeSubMeshes(
84 const TopoDS_Shape & aShape,
85 const ::MeshDimension aDim,
86 TSetOfInt* aShapesId /*=0*/,
87 TopTools_IndexedMapOfShape* allowedSubShapes,
88 SMESH_subMesh::compute_event &computeEvent,
89 const bool includeSelf,
90 const bool complexShapeFirst,
91 const bool aShapeOnly) override;
94 SMESH_ParallelMesh():SMESH_Mesh() {};
95 SMESH_ParallelMesh(const SMESH_ParallelMesh& aMesh):SMESH_Mesh(aMesh) {};
98 boost::filesystem::path tmp_folder;
99 boost::asio::thread_pool * _pool = nullptr; //thread pool for computation