Salome HOME
f4cd902f0694ae99032f125ba6ffdf2d841f61d8
[tools/medcoupling.git] / src / ParaMEDMEM / ProcessorGroup.hxx
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __PROCESSORGROUP_HXX__
21 #define __PROCESSORGROUP_HXX__
22
23 #include "CommInterface.hxx"
24
25 #include <set>
26
27 namespace MEDCoupling
28 {
29   /*!
30    * Abstract class defining a group of processors (computation nodes) in a parallel run of a code.
31    *
32    * See the non-abstract child \ref MPIProcessorGroup-det "MPIProcessorGroup"
33    */
34   class ProcessorGroup
35   {
36   public:
37   
38     ProcessorGroup(const CommInterface& interface):_comm_interface(interface) { }
39     ProcessorGroup(const CommInterface& interface, std::set<int> proc_ids):
40       _comm_interface(interface),_proc_ids(proc_ids) { }
41     ProcessorGroup (const ProcessorGroup& proc_group, std::set<int> proc_ids):
42       _comm_interface(proc_group.getCommInterface()),_proc_ids(proc_ids) { }
43     ProcessorGroup (const ProcessorGroup& other):
44       _comm_interface(other.getCommInterface()),_proc_ids(other._proc_ids) { }
45     ProcessorGroup (const CommInterface& interface, int start, int end);
46     virtual ~ProcessorGroup() { }
47     virtual ProcessorGroup *deepCopy() const = 0;
48     virtual ProcessorGroup* fuse (const ProcessorGroup&) const = 0;
49     virtual void intersect (ProcessorGroup&) = 0;
50     bool contains(int rank) const { return _proc_ids.find(rank)!=_proc_ids.end(); }
51     virtual bool containsMyRank() const = 0;
52     int size() const  { return (int)_proc_ids.size(); }
53     const CommInterface& getCommInterface()const { return _comm_interface; }
54     virtual int myRank() const = 0;
55     virtual int translateRank(const ProcessorGroup*, int) const = 0;
56     virtual ProcessorGroup* createComplementProcGroup() const = 0;
57     virtual ProcessorGroup* createProcGroup() const = 0;
58     virtual const std::set<int>& getProcIDs()const  { return _proc_ids; } 
59   protected:
60     const CommInterface _comm_interface;
61     std::set<int> _proc_ids;
62   };
63 }
64
65 #endif