Salome HOME
MEDMEM suppression
[modules/med.git] / src / MEDSPLITTER / MEDSPLITTER_JointExchangeData.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_JointExchangeData.hxx
20 // Created   : Wed Jul 22 15:29:44 2009
21 // Author    : Edward AGAPOV (eap)
22
23
24 #ifndef __MEDSPLITTER_JointExchangeData_HXX__
25 #define __MEDSPLITTER_JointExchangeData_HXX__
26
27 #include "MEDSPLITTER_Topology.hxx"
28
29 #include <map>
30 #include <vector>
31
32 namespace MEDMEM
33 {
34   class MESH;
35   class CONNECTZONE;
36   class MEDSKYLINEARRAY;
37 }
38
39 namespace MEDSPLITTER
40 {
41   /*!
42    * \brief Class storing data of the joint between domains residing different procs.
43    *  It also provides services to pack/unpack data to be exchanged between proc and
44    *  it creates MEDMEM::CONNECTZONE after data exchange.
45    */
46   class JointExchangeData
47   {
48   public:
49
50     JointExchangeData();
51
52     // Store cell/cell pair of joint between domains (residing different procs by default)
53     void addCellCorrespondence(const MEDMEM::MESH* mesh_here,
54                                int domain_dist, int domain_here,
55                                int glob_dist, int glob_here,
56                                int loc_here, int loc_dist = -1 );
57
58     // Return nb of cell pairs
59     int nbCellPairs() const { return _glob_to_locs_here_and_dist.size(); }
60
61     // Stores meshes and corresponding domain ids
62     void setMeshes( int domain_dist, const MEDMEM::MESH* mesh_dist,
63                     int domain_here, const MEDMEM::MESH* mesh_here); 
64
65     // Stores local and global connectivity of joint cells on this proc
66     void setConnectivity( const int* glob_fused_nodes);
67
68     int distantDomain() const { return _dist_domain; }
69     int   localDomain() const { return _loc_domain; }
70
71     // Exchanging
72     int serialize (std::vector<int> & out_data) const;
73     void deserialize(const std::vector<int> & in_data);
74
75     //!< Set starting global id for sub-entitis of joint to create
76     void setFisrtGlobalIdOfSubentity(int id) { _first_glob_sub_id = id; }
77
78     // Create MEDSKYLINEARRAY describing cell/cell correspondencies of the joint
79     MEDMEM::MEDSKYLINEARRAY* makeCellCorrespArray() const;
80
81     // Creates CONNECTZONE
82     MEDMEM::CONNECTZONE* makeConnectZone(TGeom2FacesByDomian& face_map);
83
84   private:
85
86     // map global cell id on of procs to pair of local cell ids: here and distant
87     typedef std::multimap<int, std::pair< int, int > > TGlob2LocsHD;
88     TGlob2LocsHD _glob_to_locs_here_and_dist;
89
90     int _dist_domain, _loc_domain, _conn_here_size, _nb_cell_pairs, _first_glob_sub_id;
91
92     const MEDMEM::MESH* _dist_mesh;
93     const MEDMEM::MESH* _loc_mesh;
94
95     std::vector<int> _global_conn_here, _global_conn_dist;
96     std::vector<int> _local_conn_here,  _local_conn_dist;
97
98   };
99 }
100 #endif