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; } // same set as the set of procs we sent mesh data to
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;
58 bool isInMyTodoList(int i, int j) const;
60 void computeBoundingBoxesAndTodoList();
61 bool intersectsBoundingBox(int i, int j) const;
62 void sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const;
63 void receiveRemoteMeshFrom(int procId, bool sourceOrTarget);
64 void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const;
65 void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const;
67 typedef MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > AutoMCPointSet;
68 typedef MEDCouplingAutoRefCountObjectPtr< DataArrayInt > AutoDAInt;
69 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
71 static const int START_TAG_MESH_XCH;
73 const ParaFIELD *_local_source_field;
74 const ParaFIELD *_local_target_field;
77 MEDCouplingPointSet *_local_source_mesh;
78 MEDCouplingPointSet *_local_target_mesh;
80 /*! of size _group.size(). Contains for each source proc i, the ids of proc j the targets interact with.
81 This vector is common for all procs in _group. */
82 std::vector< std::vector< int > > _proc_pairs;
83 //! list of interpolation couples to be done by this proc only. This is a simple extraction of the member _pairsToBeDonePerProc
84 std::vector< ProcCouple > _to_do_list;
85 //! list of procs the local proc will have to send mesh data to:
86 std::vector< Proc_SrcOrTgt > _procs_to_send_mesh;
87 // /*! list of procs the local proc will have to send field data to for the final matrix-vector computation:
88 // * This can be different from _procs_to_send_mesh (restricted to Source) because interpolation matrix bits are computed on a potentially
89 // * different proc than the target one. */
90 std::vector< int > _procs_to_send_field;
91 //! Set of distant meshes
92 std::map< Proc_SrcOrTgt, AutoMCPointSet > _remote_meshes;
93 //! Set of cell ID mappings for the above distant meshes (because only part of the meshes are exchanged)
94 std::map< Proc_SrcOrTgt, AutoDAInt > _remote_elems;
95 double* _domain_bounding_boxes;
96 //! bounding box absolute adjustment
99 std::vector<int> _distant_proc_ids;
101 const ProcessorGroup& _group;
102 const MPI_Comm *_comm;