1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __OVERLAPELEMENTLOCATOR_HXX__
22 #define __OVERLAPELEMENTLOCATOR_HXX__
24 #include "InterpolationOptions.hxx"
25 #include "MEDCouplingNatureOfField.hxx"
26 #include "MEDCouplingPointSet.hxx"
27 #include "MEDCouplingMemArray.hxx"
28 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
39 class OverlapInterpolationMatrix;
41 typedef std::pair<int,int> ProcCouple; // a couple of proc IDs, typically used to define a exchange betw 2 procs
43 class OverlapElementLocator : public INTERP_KERNEL::InterpolationOptions
46 OverlapElementLocator(const ParaFIELD *sourceField, const ParaFIELD *targetField, const ProcessorGroup& group,double epsAbs);
47 virtual ~OverlapElementLocator();
48 const MPI_Comm *getCommunicator() const;
49 void exchangeMeshes(OverlapInterpolationMatrix& matrix);
50 std::vector< std::pair<int,int> > getToDoList() const { return _to_do_list; }
51 std::vector< int > getProcsToSendFieldData() const { return _procs_to_send_field; }
52 std::string getSourceMethod() const;
53 std::string getTargetMethod() const;
54 const MEDCouplingPointSet *getSourceMesh(int procId) const;
55 const DataArrayInt *getSourceIds(int procId) const;
56 const MEDCouplingPointSet *getTargetMesh(int procId) const;
57 const DataArrayInt *getTargetIds(int procId) const;
59 void computeBoundingBoxesAndTodoList();
60 bool intersectsBoundingBox(int i, int j) const;
61 void sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const;
62 void receiveRemoteMeshFrom(int procId, bool sourceOrTarget);
63 void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const;
64 void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const;
66 typedef MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > AutoMCPointSet;
67 typedef MEDCouplingAutoRefCountObjectPtr< DataArrayInt > AutoDAInt;
68 typedef std::pair<int,bool> Proc_SrcOrTgt; // a key indicating a proc ID and whether the data is for source mesh/field or target mesh/field
70 static const int START_TAG_MESH_XCH;
72 const ParaFIELD *_local_source_field;
73 const ParaFIELD *_local_target_field;
76 MEDCouplingPointSet *_local_source_mesh;
77 MEDCouplingPointSet *_local_target_mesh;
79 /*! of size _group.size(). Contains for each source proc i, the ids of proc j the targets interact with.
80 This vector is common for all procs in _group. */
81 std::vector< std::vector< int > > _proc_pairs;
82 //! list of interpolation couples to be done by this proc only. This is a simple extraction of the member _pairsToBeDonePerProc
83 std::vector< ProcCouple > _to_do_list;
84 //! list of procs the local proc will have to send mesh data to:
85 std::vector< Proc_SrcOrTgt > _procs_to_send_mesh;
86 /*! list of procs the local proc will have to send field data to for the final matrix-vector computation:
87 * This can be different from _procs_to_send_mesh because interpolation matrix bits are computed on a potentially
88 * different proc than the target one. */
89 std::vector< int > _procs_to_send_field;
90 //! Set of distant meshes
91 std::map< Proc_SrcOrTgt, AutoMCPointSet > _remote_meshes;
92 //! Set of cell ID mappings for the above distant meshes (because only part of the meshes are exchanged)
93 std::map< Proc_SrcOrTgt, AutoDAInt > _remote_elems;
94 double* _domain_bounding_boxes;
95 //! bounding box absolute adjustment
98 std::vector<int> _distant_proc_ids;
100 const ProcessorGroup& _group;
101 const MPI_Comm *_comm;