1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : MEDSPLITTER_ParaDomainSelector.hxx
20 // Created : Wed Jun 24 12:18:58 2009
21 // Author : Edward AGAPOV (eap)
24 #ifndef __MEDSPLITTER_ParaDomainSelector_HXX__
25 #define __MEDSPLITTER_ParaDomainSelector_HXX__
27 #include "MEDSPLITTER.hxx"
29 #include <MEDMEM_define.hxx>
42 class JointExchangeData;
45 * \brief Communication helper in parallel mode
47 class MEDSPLITTER_EXPORT ParaDomainSelector
51 ParaDomainSelector(bool mesure_memory=false);
52 ~ParaDomainSelector();
54 //!< return processor rank
55 int rank() const { return _rank; }
57 //!< return number of processors
58 int nbProcs() const { return _world_size; }
60 // Return true if is running on different hosts
61 bool isOnDifferentHosts() const;
63 // Return true if the domain with domainIndex is to be loaded on this proc
64 bool isMyDomain(int domainIndex) const;
66 // Return processor id where the domain with domainIndex resides
67 int getProccessorID(int domainIndex) const;
70 //!< Set nb of required domains. (Used to sort joints via jointId())
71 void setNbDomains(int nb) { _nb_result_domains = nb; }
73 // Return identifier for a joint
74 int jointId( int local_domain, int distant_domain ) const;
76 // Return domain order
77 //int getDomianOrder(int domainIndex, int nb_domains) const;
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);
83 // Return distribution of the graph vertices among the processors
84 int* getNbVertOfProcs() const;
86 // Return nb of cells on processors with lower rank
87 int getProcShift() const;
89 // Return nb of cells in domains with lower index
90 int getDomainShift(int domainIndex) const;
92 // // Return nb of sub-entities in domains with lower index
93 // int getDomainSubentityShift(int domainIndex) const;
95 // Gather graphs from all processors into one
96 std::auto_ptr<Graph> gatherGraph(const Graph* graph) const;
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);
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 );
105 // Gather size of each proc/proc joint
106 void gatherNbCellPairs();
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;
111 // Send-receive joint data
112 void exchangeJoint( JointExchangeData* joint ) const;
114 // Return the first global id of sub-entity for the joint
115 int getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const;
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;
121 // Return time passed from construction in seconds
122 double getPassedTime() const;
124 // Evaluate current memory usage and return the maximal one in KB
125 int evaluateMemory() const;
129 int _rank, _world_size; // my rank and nb of processors
131 int _nb_result_domains; // required nb of domains
133 //int _total_nb_faces; // nb of faces in the whole mesh without proc/proc joint faces
135 std::vector< int > _nb_cell_pairs_by_joint;
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;
143 int _init_memory, _max_memory;