Salome HOME
Initiating medtool
[modules/med.git] / src / ParaMEDMEM / MxN_Mapping.hxx
1 // Copyright (C) 2007-2015  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 ParaMEDMEM
30 {
31
32   class ProcessorGroup;
33
34   class MxN_Mapping : public DECOptions
35   {
36   public:
37     MxN_Mapping();
38     MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group, const DECOptions& dec_options);
39     virtual ~MxN_Mapping();
40     void addElementFromSource(int distant_proc, int distant_elem);
41     void prepareSendRecv();
42     void sendRecv(MEDCouplingFieldDouble& field);
43     void sendRecv(double* sendfield, MEDCouplingFieldDouble& field) const ;
44     void reverseSendRecv(double* recvfield, MEDCouplingFieldDouble& field) const ;
45  
46     //
47     const std::vector<std::pair<int,int> >& getSendingIds() const { return _sending_ids; }
48     const std::vector<int>& getSendProcsOffsets() const { return _send_proc_offsets; }
49     void initialize();
50
51     MPIAccessDEC* getAccessDEC(){ return _access_DEC; }
52   private :
53     ProcessorGroup* _union_group;
54     MPIAccessDEC * _access_DEC;
55     int _nb_comps;
56     std::vector<std::pair<int,int> > _sending_ids;
57     std::vector<int> _recv_ids;
58     std::vector<int> _send_proc_offsets;
59     std::vector<int> _recv_proc_offsets;
60   };
61
62   std::ostream & operator<< (std::ostream &,const AllToAllMethod &);
63
64 }
65
66 #endif