Back to index

salome-med  6.5.0
MEDSPLITTER_ParaDomainSelector.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 // File      : MEDSPLITTER_ParaDomainSelector.hxx
00020 // Created   : Wed Jun 24 12:18:58 2009
00021 // Author    : Edward AGAPOV (eap)
00022 
00023 
00024 #ifndef __MEDSPLITTER_ParaDomainSelector_HXX__
00025 #define __MEDSPLITTER_ParaDomainSelector_HXX__
00026 
00027 #include "MEDSPLITTER.hxx"
00028 
00029 #include <MEDMEM_define.hxx>
00030 
00031 #include <memory>
00032 #include <vector>
00033 
00034 namespace MEDMEM
00035 {
00036   class MESH;
00037 }
00038 
00039 namespace MEDSPLITTER
00040 {
00041   class Graph;
00042   class JointExchangeData;
00043 
00047 class MEDSPLITTER_EXPORT ParaDomainSelector
00048 {
00049 public:
00050 
00051   ParaDomainSelector(bool mesure_memory=false);
00052   ~ParaDomainSelector();
00053 
00055   int rank() const { return _rank; }
00056 
00058   int nbProcs() const { return _world_size; }
00059 
00060   // Return true if is running on different hosts
00061   bool isOnDifferentHosts() const;
00062 
00063   // Return true if the domain with domainIndex is to be loaded on this proc
00064   bool isMyDomain(int domainIndex) const;
00065 
00066   // Return processor id where the domain with domainIndex resides
00067   int getProccessorID(int domainIndex) const;
00068 
00069 
00071   void setNbDomains(int nb) { _nb_result_domains = nb; }
00072 
00073   // Return identifier for a joint
00074   int jointId( int local_domain, int distant_domain ) const;
00075 
00076   // Return domain order
00077   //int getDomianOrder(int domainIndex, int nb_domains) const;
00078 
00079 
00080   // Collect nb of entities on procs and return total nb
00081   int gatherNbOf(MED_EN::medEntityMesh entity, const std::vector<MEDMEM::MESH*>& domain_meshes);
00082 
00083   // Return distribution of the graph vertices among the processors
00084   int* getNbVertOfProcs() const;
00085 
00086   // Return nb of cells on processors with lower rank
00087   int getProcShift() const;
00088 
00089   // Return nb of cells in domains with lower index
00090   int getDomainShift(int domainIndex) const;
00091 
00092 //   // Return nb of sub-entities in domains with lower index
00093 //   int getDomainSubentityShift(int domainIndex) const;
00094 
00095   // Gather graphs from all processors into one
00096   std::auto_ptr<Graph> gatherGraph(const Graph* graph) const;
00097 
00098   // Set types and number of elements of the entity to all meshes
00099   void gatherEntityTypesInfo(std::vector<MEDMEM::MESH*>& domain_meshes,
00100                              MED_EN::medEntityMesh       entity);
00101 
00102   // Set nb of cell/cell pairs in a joint between domains
00103   void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain );
00104 
00105   // Gather size of each proc/proc joint
00106   void gatherNbCellPairs();
00107 
00108   // Return nb of cell/cell pairs in a joint between domains on different procs
00109   int getNbCellPairs( int dist_domain, int loc_domain ) const;
00110 
00111   // Send-receive joint data
00112   void exchangeJoint( JointExchangeData* joint ) const;
00113 
00114   // Return the first global id of sub-entity for the joint
00115   int getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const;
00116 
00117   // Send-receive local ids of joint faces
00118   int* exchangeSubentityIds( int loc_domain, int dist_domain,
00119                              const std::vector<int>& loc_ids_here ) const;
00120 
00121   // Return time passed from construction in seconds
00122   double getPassedTime() const;
00123 
00124   // Evaluate current memory usage and return the maximal one in KB
00125   int evaluateMemory() const;
00126 
00127 private:
00128 
00129   int _rank, _world_size; // my rank and nb of processors
00130 
00131   int _nb_result_domains; // required nb of domains
00132 
00133   //int _total_nb_faces; // nb of faces in the whole mesh without proc/proc joint faces
00134 
00135   std::vector< int > _nb_cell_pairs_by_joint;
00136 
00137   std::vector< int > _nb_vert_of_procs; // graph vertices
00138   std::vector< int > _cell_shift_by_domain;
00139   std::vector< int > _face_shift_by_domain;
00140 
00141   double _init_time;
00142   bool   _mesure_memory;
00143   int    _init_memory, _max_memory;
00144 };
00145 
00146 }
00147 
00148 #endif