]> SALOME platform Git repositories - modules/med.git/blob - src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.hxx
Salome HOME
MEDMEM suppression
[modules/med.git] / src / MEDSPLITTER / MEDSPLITTER_ParaDomainSelector.hxx
1 // Copyright (C) 2007-2013  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.
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 // File      : MEDSPLITTER_ParaDomainSelector.hxx
20 // Created   : Wed Jun 24 12:18:58 2009
21 // Author    : Edward AGAPOV (eap)
22
23
24 #ifndef __MEDSPLITTER_ParaDomainSelector_HXX__
25 #define __MEDSPLITTER_ParaDomainSelector_HXX__
26
27 #include "MEDSPLITTER.hxx"
28
29 #include <MEDMEM_define.hxx>
30
31 #include <memory>
32 #include <vector>
33
34 namespace MEDMEM
35 {
36   class MESH;
37 }
38
39 namespace MEDSPLITTER
40 {
41   class Graph;
42   class JointExchangeData;
43
44 /*!
45  * \brief Communication helper in parallel mode
46  */
47 class MEDSPLITTER_EXPORT ParaDomainSelector
48 {
49 public:
50
51   ParaDomainSelector(bool mesure_memory=false);
52   ~ParaDomainSelector();
53
54   //!< return processor rank
55   int rank() const { return _rank; }
56
57   //!< return number of processors
58   int nbProcs() const { return _world_size; }
59
60   // Return true if is running on different hosts
61   bool isOnDifferentHosts() const;
62
63   // Return true if the domain with domainIndex is to be loaded on this proc
64   bool isMyDomain(int domainIndex) const;
65
66   // Return processor id where the domain with domainIndex resides
67   int getProccessorID(int domainIndex) const;
68
69
70   //!< Set nb of required domains. (Used to sort joints via jointId())
71   void setNbDomains(int nb) { _nb_result_domains = nb; }
72
73   // Return identifier for a joint
74   int jointId( int local_domain, int distant_domain ) const;
75
76   // Return domain order
77   //int getDomianOrder(int domainIndex, int nb_domains) const;
78
79
80   // Collect nb of entities on procs and return total nb
81   int gatherNbOf(MED_EN::medEntityMesh entity, const std::vector<MEDMEM::MESH*>& domain_meshes);
82
83   // Return distribution of the graph vertices among the processors
84   int* getNbVertOfProcs() const;
85
86   // Return nb of cells on processors with lower rank
87   int getProcShift() const;
88
89   // Return nb of cells in domains with lower index
90   int getDomainShift(int domainIndex) const;
91
92 //   // Return nb of sub-entities in domains with lower index
93 //   int getDomainSubentityShift(int domainIndex) const;
94
95   // Gather graphs from all processors into one
96   std::auto_ptr<Graph> gatherGraph(const Graph* graph) const;
97
98   // Set types and number of elements of the entity to all meshes
99   void gatherEntityTypesInfo(std::vector<MEDMEM::MESH*>& domain_meshes,
100                              MED_EN::medEntityMesh       entity);
101
102   // Set nb of cell/cell pairs in a joint between domains
103   void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain );
104
105   // Gather size of each proc/proc joint
106   void gatherNbCellPairs();
107
108   // Return nb of cell/cell pairs in a joint between domains on different procs
109   int getNbCellPairs( int dist_domain, int loc_domain ) const;
110
111   // Send-receive joint data
112   void exchangeJoint( JointExchangeData* joint ) const;
113
114   // Return the first global id of sub-entity for the joint
115   int getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const;
116
117   // Send-receive local ids of joint faces
118   int* exchangeSubentityIds( int loc_domain, int dist_domain,
119                              const std::vector<int>& loc_ids_here ) const;
120
121   // Return time passed from construction in seconds
122   double getPassedTime() const;
123
124   // Evaluate current memory usage and return the maximal one in KB
125   int evaluateMemory() const;
126
127 private:
128
129   int _rank, _world_size; // my rank and nb of processors
130
131   int _nb_result_domains; // required nb of domains
132
133   //int _total_nb_faces; // nb of faces in the whole mesh without proc/proc joint faces
134
135   std::vector< int > _nb_cell_pairs_by_joint;
136
137   std::vector< int > _nb_vert_of_procs; // graph vertices
138   std::vector< int > _cell_shift_by_domain;
139   std::vector< int > _face_shift_by_domain;
140
141   double _init_time;
142   bool   _mesure_memory;
143   int    _init_memory, _max_memory;
144 };
145
146 }
147
148 #endif