Salome HOME
fix conflict
[tools/medcoupling.git] / src / ParaMEDMEM / DisjointDEC.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 __DISJOINTDEC_HXX__
21 #define __DISJOINTDEC_HXX__
22
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "NormalizedUnstructuredMesh.hxx"
25 #include "DEC.hxx"
26
27 #include <mpi.h>
28 #include <set>
29
30 namespace ICoCo
31 {
32   class MEDField;
33 }
34
35 namespace ParaMEDMEM
36 {
37   class ProcessorGroup;
38   class ParaFIELD;
39   
40   class DisjointDEC : public DEC
41   {
42   public:
43     DisjointDEC():_local_field(0),_union_group(0),_source_group(0),_target_group(0),
44     _comm_interface(0),
45     _owns_field(false),_owns_groups(false),
46     _union_comm(MPI_COMM_NULL)
47     { }
48     DisjointDEC(ProcessorGroup& source_group, ProcessorGroup& target_group);
49     DisjointDEC(const DisjointDEC&);
50     DisjointDEC &operator=(const DisjointDEC& s);
51     DisjointDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids,
52                 const MPI_Comm& world_comm=MPI_COMM_WORLD);
53     void setNature(NatureOfField nature);
54     void attachLocalField( MEDCouplingFieldDouble *field);
55     void attachLocalField(const ParaFIELD *field, bool ownPt=false);
56     void attachLocalField(const ICoCo::MEDField *field);
57     
58     virtual void prepareSourceDE() = 0;
59     virtual void prepareTargetDE() = 0;
60     virtual void recvData() = 0;
61     virtual void sendData() = 0;
62     void sendRecvData(bool way=true);
63     virtual void synchronize() = 0;
64     virtual ~DisjointDEC();
65     virtual void computeProcGroup() { }
66     void renormalizeTargetField(bool isWAbs);
67     //
68     ProcessorGroup *getSourceGrp() const { return _source_group; }
69     ProcessorGroup *getTargetGrp() const { return _target_group; }
70     bool isInSourceSide() const;
71     bool isInTargetSide() const;
72     bool isInUnion() const;
73   protected:
74     void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception);
75     void cleanInstance();
76     void copyInstance(const DisjointDEC& other);
77   protected:
78     const ParaFIELD* _local_field;
79     //! Processor group representing the union of target and source processors
80     ProcessorGroup* _union_group;
81     ProcessorGroup* _source_group;
82     ProcessorGroup* _target_group;
83     
84     const CommInterface* _comm_interface;
85     bool _owns_field;
86     bool _owns_groups;
87     MPI_Comm _union_comm;
88   };
89 }
90
91 #endif