Salome HOME
Get relevant changes from V7_dev branch (copyright update, adm files etc)
[tools/medcoupling.git] / src / ParaMEDMEM / MxN_Mapping.hxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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
20 #ifndef __MXN_MAPPING_HXX__
21 #define __MXN_MAPPING_HXX__
22
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "MPIAccessDEC.hxx"
25 #include "DECOptions.hxx"
26
27 #include <vector>
28
29 namespace MEDCoupling
30 {
31
32   class ProcessorGroup;
33
34   /*!
35    * Internal class, not part of the public API.
36    *
37    * Used by InterpolationMatrix. This class manages the mapping between a given processor and part
38    * of the mesh (cell ids).
39    */
40   class MxN_Mapping : public DECOptions
41   {
42   public:
43     MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group, const DECOptions& dec_options);
44     virtual ~MxN_Mapping();
45     void addElementFromSource(int distant_proc, int distant_elem);
46     void prepareSendRecv();
47     void sendRecv(MEDCouplingFieldDouble& field);
48     void sendRecv(double* sendfield, MEDCouplingFieldDouble& field) const ;
49     void reverseSendRecv(double* recvfield, MEDCouplingFieldDouble& field) const ;
50  
51     //
52     const std::vector<std::pair<int,int> >& getSendingIds() const { return _sending_ids; }
53     const std::vector<int>& getSendProcsOffsets() const { return _send_proc_offsets; }
54     void initialize();
55
56     MPIAccessDEC* getAccessDEC(){ return _access_DEC; }
57   private :
58     ProcessorGroup* _union_group;
59     MPIAccessDEC * _access_DEC;
60     int _nb_comps;
61     std::vector<std::pair<int,int> > _sending_ids;
62     std::vector<int> _recv_ids;
63     std::vector<int> _send_proc_offsets;
64     std::vector<int> _recv_proc_offsets;
65   };
66
67   std::ostream & operator<< (std::ostream &,const AllToAllMethod &);
68
69 }
70
71 #endif