Salome HOME
refactor!: remove adm_local/ directory
[tools/medcoupling.git] / src / ParaMEDMEM / MxN_Mapping.hxx
1 // Copyright (C) 2007-2024  CEA, EDF
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, mcIdType distant_elem);
46     void prepareSendRecv();
47     void sendRecv(MEDCouplingFieldDouble& field);
48     MCAuto<DataArrayIdType> retrieveNonFetchedIdsTarget(mcIdType nbTuples) const;
49     void sendRecv(double* sendfield, MEDCouplingFieldDouble& field) const ;
50     void reverseSendRecv(double* recvfield, MEDCouplingFieldDouble& field) const ;
51  
52     //
53     const std::vector<std::pair<int,mcIdType> >& getSendingIds() const { return _sending_ids; }
54     const std::vector<int>& getSendProcsOffsets() const { return _send_proc_offsets; }
55     void initialize();
56
57     MPIAccessDEC* getAccessDEC(){ return _access_DEC; }
58   private :
59     ProcessorGroup* _union_group;
60     MPIAccessDEC * _access_DEC;
61     int _nb_comps;
62     std::vector<std::pair<int,mcIdType> > _sending_ids;
63     std::vector<mcIdType> _recv_ids;
64     std::vector<int> _send_proc_offsets;
65     std::vector<int> _recv_proc_offsets;
66   };
67
68   std::ostream & operator<< (std::ostream &,const AllToAllMethod &);
69
70 }
71
72 #endif