Salome HOME
Synchronize adm files
[modules/med.git] / src / ParaMEDMEM / OverlapElementLocator.hxx
1 // Copyright (C) 2007-2014  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 __OVERLAPELEMENTLOCATOR_HXX__
22 #define __OVERLAPELEMENTLOCATOR_HXX__
23
24 #include "InterpolationOptions.hxx"
25 #include "MEDCouplingNatureOfField.hxx"
26 #include "MEDCouplingPointSet.hxx"
27 #include "MEDCouplingMemArray.hxx"
28 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
29
30 #include <mpi.h>
31 #include <vector>
32 #include <map>
33 #include <set>
34
35 namespace ParaMEDMEM
36 {
37   class ParaFIELD;
38   class ProcessorGroup;
39   class ParaSUPPORT;
40   class OverlapInterpolationMatrix;
41   
42   class OverlapElementLocator : public INTERP_KERNEL::InterpolationOptions
43   {
44   public:
45     OverlapElementLocator(const ParaFIELD *sourceField, const ParaFIELD *targetField, const ProcessorGroup& group);
46     virtual ~OverlapElementLocator();
47     const MPI_Comm *getCommunicator() const;
48     void exchangeMeshes(OverlapInterpolationMatrix& matrix);
49     std::vector< std::pair<int,int> > getToDoList() const { return _to_do_list; }
50     std::vector< std::vector< int > > getProcsInInteraction() const { return _proc_pairs; }
51     std::string getSourceMethod() const;
52     std::string getTargetMethod() const;
53     const MEDCouplingPointSet *getSourceMesh(int procId) const;
54     const DataArrayInt *getSourceIds(int procId) const;
55     const MEDCouplingPointSet *getTargetMesh(int procId) const;
56     const DataArrayInt *getTargetIds(int procId) const;
57   private:
58     void computeBoundingBoxes();
59     bool intersectsBoundingBox(int i, int j) const;
60     void sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const;
61     void receiveRemoteMesh(int procId, bool sourceOrTarget);
62     void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const;
63     void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const;
64   private:
65     const ParaFIELD *_local_source_field;
66     const ParaFIELD *_local_target_field;
67     int _local_space_dim;
68     MEDCouplingPointSet *_local_source_mesh;
69     MEDCouplingPointSet *_local_target_mesh;
70     std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
71     std::vector<MEDCouplingPointSet*> _distant_face_meshes;
72     //! of size _group.size(). Contains for each source proc i, the ids of proc j the targets interact with. This vector is common for all procs in _group. 
73     std::vector< std::vector< int > > _proc_pairs;
74     //! list of interpolations couple to be done
75     std::vector< std::pair<int,int> > _to_do_list;
76     std::vector< std::pair<int,bool> > _procs_to_send;
77     std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > > _remote_meshes;
78     std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< DataArrayInt > > _remote_elems;
79     double* _domain_bounding_boxes;
80     const ProcessorGroup& _group;
81     std::vector<int> _distant_proc_ids;
82     const MPI_Comm *_comm;
83     //Attributes only used by lazy side
84     //std::vector<double> _values_added;
85     //std::vector< std::vector<int> > _ids_per_working_proc;
86     //std::vector< std::vector<int> > _ids_per_working_proc3;
87     //std::vector< std::vector<double> > _values_per_working_proc;
88   };
89
90 }
91
92 #endif