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
20 #ifndef __ELEMENTLOCATOR_HXX__
21 #define __ELEMENTLOCATOR_HXX__
23 #include "InterpolationOptions.hxx"
24 #include "MEDCouplingNatureOfField.hxx"
34 class InterpolationMatrix;
35 class MEDCouplingPointSet;
38 /*! Internal class, not part of the public API. Used in InterpolationMatrix.
41 class ElementLocator : public INTERP_KERNEL::InterpolationOptions
44 ElementLocator(const ParaFIELD& sourceField, const ProcessorGroup& distant_group, const ProcessorGroup& local_group);
46 virtual ~ElementLocator();
47 void exchangeMesh(int idistantrank,
48 MEDCouplingPointSet*& target_mesh,
50 void exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth);
51 const std::vector<int>& getDistantProcIds() const { return _distant_proc_ids; }
52 const MPI_Comm *getCommunicator() const;
53 NatureOfField getLocalNature() const;
54 //! This method is used to informed if there is -1D mesh on distant_group side or on local_group side.
55 bool isM1DCorr() const { return _is_m1d_corr; }
56 //Working side methods
57 void recvPolicyFromLazySideW(std::vector<int>& policy);
58 void sendSumToLazySideW(const std::vector< std::vector<int> >& distantLocEltIds, const std::vector< std::vector<double> >& partialSumRelToDistantIds);
59 void recvSumFromLazySideW(std::vector< std::vector<double> >& globalSumRelToDistantIds);
60 void sendCandidatesForAddElementsW(const std::vector<int>& distantGlobIds);
61 void recvAddElementsFromLazyProcsW(std::vector<std::vector<int> >& elementsToAdd);
63 void sendLocalIdsToLazyProcsW(const std::vector< std::vector<int> >& distantLocEltIds);
64 void recvGlobalIdsFromLazyProcsW(const std::vector< std::vector<int> >& distantLocEltIds, std::vector< std::vector<int> >& globalIds);
65 void recvCandidatesGlobalIdsFromLazyProcsW(std::vector< std::vector<int> >& globalIds);
66 void sendPartialSumToLazyProcsW(const std::vector<int>& distantGlobIds, const std::vector<double>& sum);
68 int sendPolicyToWorkingSideL();
69 void recvFromWorkingSideL();
70 void sendToWorkingSideL();
72 void recvLocalIdsFromWorkingSideL();
73 void sendGlobalIdsToWorkingSideL();
74 void sendCandidatesGlobalIdsToWorkingSideL();
76 void recvSumFromWorkingSideL();
77 void recvCandidatesForAddElementsL();
78 void sendAddElementsToWorkingSideL();
80 void _computeBoundingBoxes();
81 bool _intersectsBoundingBox(int irank);
82 void _exchangeMesh(MEDCouplingPointSet* local_mesh, MEDCouplingPointSet*& distant_mesh,
83 int iproc_distant, const DataArrayInt* distant_ids_send,
84 int*& distant_ids_recv);
86 const ParaFIELD& _local_para_field ;
87 MEDCouplingPointSet* _local_cell_mesh;
88 int _local_cell_mesh_space_dim;
90 MEDCouplingPointSet* _local_face_mesh;
91 std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
92 std::vector<MEDCouplingPointSet*> _distant_face_meshes;
93 double* _domain_bounding_boxes;
94 const ProcessorGroup& _distant_group;
95 const ProcessorGroup& _local_group;
96 ProcessorGroup* _union_group;
97 std::vector<int> _distant_proc_ids;
98 const MPI_Comm *_comm;
99 //Attributes only used by lazy side
100 std::vector<double> _values_added;
101 std::vector< std::vector<int> > _ids_per_working_proc;
102 std::vector< std::vector<int> > _ids_per_working_proc3;
103 std::vector< std::vector<double> > _values_per_working_proc;
105 static const int CUMULATIVE_POLICY=3;
106 static const int NO_POST_TREATMENT_POLICY=7;