Back to index

salome-med  6.5.0
MEDPARTITIONER_ParallelTopology.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 
00020 #ifndef __MEDPARTITIONER_PARALLELTOPOLOGY_HXX__
00021 #define __MEDPARTITIONER_PARALLELTOPOLOGY_HXX__
00022 
00023 #include "MEDPARTITIONER_Topology.hxx"
00024 #include "MEDPARTITIONER_ParaDomainSelector.hxx"
00025 
00026 #include "InterpKernelHashMap.hxx"
00027 
00028 #include <set>
00029 #include <vector>
00030 
00031 namespace MEDPARTITIONER
00032 {
00033   class Graph;
00034   class MeshCollection;
00035   class MEDPARTITIONER_FaceModel;
00036 
00037   class ParallelTopology : public Topology
00038   {
00039 
00040   public:
00041 
00042     ParallelTopology();
00043     ParallelTopology(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>&);
00044     ParallelTopology(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>&,
00045                      const std::vector<MEDPARTITIONER::ConnectZone*>&,
00046                      std::vector<int*>&,
00047                      std::vector<int*>&,
00048                      std::vector<int*>&);
00049     ParallelTopology(Graph* graph, Topology* oldTopology, int nbdomain, int mesh_dimension);
00050     ~ParallelTopology();
00051     
00052     void setGlobalNumerotationDefault(ParaDomainSelector* domainSelector);
00053 
00057     void convertGlobalNodeList(const int*, int,int*,int*);
00058     void convertGlobalNodeList(const int*, int,int*,int);
00059     void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size);
00060 
00064     void convertGlobalCellList(const int*, int , int*, int *);
00065 
00069     void convertGlobalFaceList(const int*, int , int*, int *);  
00070     void convertGlobalFaceList(const int*, int , int*, int);  
00071     void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array,int& size);
00072 
00074     void convertToLocal2ndVersion(int* nodes, int nbnodes, int idomain);
00075 
00077     int convertNodeToGlobal(int ip, int icell) const { return _node_loc_to_glob[ip][icell]; }
00078 
00080     int convertFaceToGlobal(int ip, int iface) const { return _face_loc_to_glob[ip][iface]; }
00081 
00083     int convertCellToGlobal(int ip, int icell) const { return _loc_to_glob[ip][icell]; }
00084 
00085     void convertNodeToGlobal(int ip, const int* local, int n, int *global) const
00086     {
00087       for (int i=0; i<n; i++)
00088         global[i]=_node_loc_to_glob[ip][local[i]];
00089     }
00090 
00091     void convertCellToGlobal(int ip, const int* local, int n, int *global) const
00092     {
00093       for (int i=0; i<n; i++)
00094         global[i]=_loc_to_glob[ip][local[i]];  
00095     }
00096 
00097     void convertFaceToGlobal(int ip, const int* local, int n, int *global) const
00098     {
00099       for (int i=0; i<n; i++) 
00100         global[i]=_face_loc_to_glob[ip][local[i]];
00101     }
00102 
00103     int nbDomain() const { return _nb_domain; }
00104 
00105     int nbCells() const { return _nb_total_cells; }
00106     
00107     int nbNodes() const { return _nb_total_nodes; }
00108 
00109     int nbCells( int idomain) const { return _nb_cells[idomain]; }
00110 
00112     int getNodeNumber(int idomain) const { return _nb_nodes[idomain]; }
00113 
00114     int getNodeNumber() const;
00115 
00116     void getNodeList(int idomain, int* list) const;
00117 
00119     std::vector<int> & getFusedCellNumbers(int idomain) { return _cell_loc_to_glob_fuse[idomain]; }
00120     
00121     const std::vector<int>& getFusedCellNumbers(int idomain) const { return _cell_loc_to_glob_fuse[idomain]; }
00122 
00124     std::vector<int> & getFusedFaceNumbers(int idomain) { return _face_loc_to_glob_fuse[idomain]; }
00125 
00126     const std::vector<int>& getFusedFaceNumbers(int idomain) const { return _face_loc_to_glob_fuse[idomain]; }
00127 
00129     int getCellNumber(int idomain) const { return _nb_cells[idomain]; }
00130 
00131     int getCellDomainNumber(int global) const { return (_glob_to_loc.find(global)->second).first; }
00132 
00133     void getCellList(int idomain, int* list) const;
00134 
00135     int getFaceNumber(int idomain) const { return _nb_faces[idomain]; }
00136 
00137     int getFaceNumber() const;
00138 
00139     void getFaceList(int idomain, int* list) const;
00140 
00142     std::pair<int,int> convertGlobalCell(int iglobal) const { return _glob_to_loc.find(iglobal)->second; }
00143 
00144     int convertGlobalFace(int iglobal, int idomain);
00145 
00146     int convertGlobalNode(int iglobal, int idomain);
00147     
00148     //adding a face to the topology
00149     void appendFace(int idomain, int ilocal, int iglobal);
00150 
00151     //return max global face number
00152     int getMaxGlobalFace() const;
00153 
00154   private:
00155     bool hasCellWithNodes( const MeshCollection&, int dom, const std::set<int>& nodes );
00156 
00157   private:
00158     //mapping global -> local
00159     typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2DomainLoc;
00160 
00161     TGlob2DomainLoc _glob_to_loc;
00162     std::vector<std::vector<int> >  _loc_to_glob;
00163     INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > _node_glob_to_loc;
00164 
00165     //mapping local -> global
00166     std::vector<std::vector <int> > _node_loc_to_glob;
00167 
00168     // global numbers in parallel mode
00169     std::vector<std::vector <int> > _cell_loc_to_glob_fuse; // glob nums after merging
00170     std::vector<std::vector <int> > _face_loc_to_glob_fuse; // glob nums after merging
00171 
00172     //mapping global -> local
00173     typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2LocsMap;
00174     TGlob2LocsMap _face_glob_to_loc;
00175 
00176     //mapping local -> global
00177     std::vector<std::vector <int> > _face_loc_to_glob;
00178     std::vector<int> _nb_cells;
00179     std::vector<int> _nb_nodes;
00180     std::vector<int> _nb_faces;
00181     int _nb_total_cells;
00182     int _nb_total_nodes;
00183     int _nb_total_faces;
00184     int _nb_domain;
00185     int _mesh_dimension;
00186   };
00187 }
00188 #endif