Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / ParaMEDMEM / OverlapDEC.hxx
1 // Copyright (C) 2007-2020  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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __OVERLAPDEC_HXX__
22 #define __OVERLAPDEC_HXX__
23
24 #include "DEC.hxx"
25 #include "InterpolationOptions.hxx"
26
27 #include <mpi.h>
28 #include <string>
29
30 namespace ICoCo {
31   class MEDField;
32 }
33
34 namespace MEDCoupling
35 {
36   class OverlapInterpolationMatrix;
37   class OverlapElementLocator;
38   class ProcessorGroup;
39   class ParaFIELD;
40
41   class OverlapDEC : public DEC, public INTERP_KERNEL::InterpolationOptions
42   {
43   public:
44     OverlapDEC(const std::set<int>& procIds,const MPI_Comm& world_comm=MPI_COMM_WORLD);
45     virtual ~OverlapDEC();
46     void sendRecvData(bool way=true);
47     void sendData();
48     void recvData();
49     void synchronize();
50     void attachSourceLocalField(ParaFIELD *field, bool ownPt=false);
51     void attachTargetLocalField(ParaFIELD *field, bool ownPt=false);
52     void attachSourceLocalField(MEDCouplingFieldDouble *field);
53     void attachTargetLocalField(MEDCouplingFieldDouble *field);
54     void attachSourceLocalField(ICoCo::MEDField *field);
55     void attachTargetLocalField(ICoCo::MEDField *field);
56     ProcessorGroup *getGroup() { return _group; }
57     bool isInGroup() const;
58
59     void setDefaultValue(double val) {_default_field_value = val;}
60     //! 0 means initial algo from Antho, 1 or 2 means Adrien's algo (2 should be better). Make your choice :-))
61     void setWorkSharingAlgo(int method)  { _load_balancing_algo = method; }
62
63     void debugPrintWorkSharing(std::ostream & ostr) const;
64   private:
65     int _load_balancing_algo;
66
67     bool _own_group;
68     OverlapInterpolationMatrix* _interpolation_matrix;
69     OverlapElementLocator* _locator;
70     ProcessorGroup *_group;
71
72     double _default_field_value;
73
74     ParaFIELD *_source_field;
75     bool _own_source_field;
76     ParaFIELD *_target_field;
77     bool _own_target_field;
78     MPI_Comm _comm;
79   };
80 }
81
82 #endif