Salome HOME
521353f5ed5d5ee4f28ee55ed09873c3671023dc
[modules/med.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),_owns_field(false),_owns_groups(false) { }
44     DisjointDEC(ProcessorGroup& source_group, ProcessorGroup& target_group);
45     DisjointDEC(const DisjointDEC&);
46     DisjointDEC &operator=(const DisjointDEC& s);
47     DisjointDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids,
48                 const MPI_Comm& world_comm=MPI_COMM_WORLD);
49     void setNature(NatureOfField nature);
50     void attachLocalField( MEDCouplingFieldDouble *field);
51     void attachLocalField(const ParaFIELD *field, bool ownPt=false);
52     void attachLocalField(const ICoCo::MEDField *field);
53     
54     virtual void prepareSourceDE() = 0;
55     virtual void prepareTargetDE() = 0;
56     virtual void recvData() = 0;
57     virtual void sendData() = 0;
58     void sendRecvData(bool way=true);
59     virtual void synchronize() = 0;
60     virtual ~DisjointDEC();
61     virtual void computeProcGroup() { }
62     void renormalizeTargetField(bool isWAbs);
63     //
64     ProcessorGroup *getSourceGrp() const { return _source_group; }
65     ProcessorGroup *getTargetGrp() const { return _target_group; }
66     bool isInSourceSide() const;
67     bool isInTargetSide() const;
68     bool isInUnion() const;
69   protected:
70     void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception);
71     void cleanInstance();
72     void copyInstance(const DisjointDEC& other);
73   protected:
74     const ParaFIELD* _local_field;
75     //! Processor group representing the union of target and source processors
76     ProcessorGroup* _union_group;
77     ProcessorGroup* _source_group;
78     ProcessorGroup* _target_group;
79     
80     const CommInterface* _comm_interface;
81     bool _owns_field;
82     bool _owns_groups;
83   };
84 }
85
86 #endif