1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __OVERLAPELEMENTLOCATOR_HXX__
21 #define __OVERLAPELEMENTLOCATOR_HXX__
23 #include "InterpolationOptions.hxx"
24 #include "MEDCouplingNatureOfField.hxx"
25 #include "MEDCouplingPointSet.hxx"
26 #include "MEDCouplingMemArray.hxx"
27 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
39 class OverlapInterpolationMatrix;
41 class OverlapElementLocator : public INTERP_KERNEL::InterpolationOptions
44 OverlapElementLocator(const ParaFIELD *sourceField, const ParaFIELD *targetField, const ProcessorGroup& group);
45 virtual ~OverlapElementLocator();
46 const MPI_Comm *getCommunicator() const;
47 void exchangeMeshes(OverlapInterpolationMatrix& matrix);
48 std::vector< std::pair<int,int> > getToDoList() const { return _to_do_list; }
49 std::vector< std::vector< int > > getProcsInInteraction() const { return _proc_pairs; }
50 std::string getSourceMethod() const;
51 std::string getTargetMethod() const;
52 const MEDCouplingPointSet *getSourceMesh(int procId) const;
53 const DataArrayInt *getSourceIds(int procId) const;
54 const MEDCouplingPointSet *getTargetMesh(int procId) const;
55 const DataArrayInt *getTargetIds(int procId) const;
57 void computeBoundingBoxes();
58 bool intersectsBoundingBox(int i, int j) const;
59 void sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const;
60 void receiveRemoteMesh(int procId, bool sourceOrTarget);
61 void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const;
62 void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const;
64 const ParaFIELD *_local_source_field;
65 const ParaFIELD *_local_target_field;
67 MEDCouplingPointSet *_local_source_mesh;
68 MEDCouplingPointSet *_local_target_mesh;
69 std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
70 std::vector<MEDCouplingPointSet*> _distant_face_meshes;
71 //! 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.
72 std::vector< std::vector< int > > _proc_pairs;
73 //! list of interpolations couple to be done
74 std::vector< std::pair<int,int> > _to_do_list;
75 std::vector< std::pair<int,bool> > _procs_to_send;
76 std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > > _remote_meshes;
77 std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< DataArrayInt > > _remote_elems;
78 double* _domain_bounding_boxes;
79 const ProcessorGroup& _group;
80 std::vector<int> _distant_proc_ids;
81 const MPI_Comm *_comm;
82 //Attributes only used by lazy side
83 //std::vector<double> _values_added;
84 //std::vector< std::vector<int> > _ids_per_working_proc;
85 //std::vector< std::vector<int> > _ids_per_working_proc3;
86 //std::vector< std::vector<double> > _values_per_working_proc;