1 // Copyright (C) 2007-2024 CEA, EDF
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"
35 class InterpolationMatrix;
36 class MEDCouplingPointSet;
39 /*! Internal class, not part of the public API. Used in InterpolationMatrix.
42 class ElementLocator : public INTERP_KERNEL::InterpolationOptions
45 ElementLocator(const ParaFIELD& sourceField, const ProcessorGroup& distant_group, const ProcessorGroup& local_group);
47 virtual ~ElementLocator();
48 void exchangeMesh(int idistantrank,
49 MEDCouplingPointSet*& target_mesh,
50 mcIdType*& distant_ids);
51 void exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth);
52 const std::vector<int>& getDistantProcIds() const { return _distant_proc_ids; }
53 const MPI_Comm *getCommunicator() const;
54 NatureOfField getLocalNature() const;
55 //! This method is used to informed if there is -1D mesh on distant_group side or on local_group side.
56 bool isM1DCorr() const { return _is_m1d_corr; }
57 //Working side methods
58 void recvPolicyFromLazySideW(std::vector<int>& policy);
59 void sendSumToLazySideW(const std::vector< std::vector<mcIdType> >& distantLocEltIds, const std::vector< std::vector<double> >& partialSumRelToDistantIds);
60 void recvSumFromLazySideW(std::vector< std::vector<double> >& globalSumRelToDistantIds);
61 void sendCandidatesForAddElementsW(const std::vector<mcIdType>& distantGlobIds);
62 void recvAddElementsFromLazyProcsW(std::vector<std::vector<mcIdType> >& elementsToAdd);
64 void sendLocalIdsToLazyProcsW(const std::vector< std::vector<mcIdType> >& distantLocEltIds);
65 void recvGlobalIdsFromLazyProcsW(const std::vector< std::vector<mcIdType> >& distantLocEltIds, std::vector< std::vector<mcIdType> >& globalIds);
66 void recvCandidatesGlobalIdsFromLazyProcsW(std::vector< std::vector<mcIdType> >& globalIds);
67 void sendPartialSumToLazyProcsW(const std::vector<mcIdType>& distantGlobIds, const std::vector<double>& sum);
69 int sendPolicyToWorkingSideL();
70 void recvFromWorkingSideL();
71 void sendToWorkingSideL();
73 void recvLocalIdsFromWorkingSideL();
74 void sendGlobalIdsToWorkingSideL();
75 void sendCandidatesGlobalIdsToWorkingSideL();
77 void recvSumFromWorkingSideL();
78 void recvCandidatesForAddElementsL();
79 void sendAddElementsToWorkingSideL();
81 void _computeBoundingBoxes();
82 bool _intersectsBoundingBox(int irank);
83 void _exchangeMesh(MEDCouplingPointSet* local_mesh, MEDCouplingPointSet*& distant_mesh,
84 int iproc_distant, const DataArrayIdType* distant_ids_send,
85 mcIdType*& distant_ids_recv);
87 const ParaFIELD& _local_para_field ;
88 MEDCouplingPointSet* _local_cell_mesh;
89 int _local_cell_mesh_space_dim;
91 MEDCouplingPointSet* _local_face_mesh;
92 std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
93 std::vector<MEDCouplingPointSet*> _distant_face_meshes;
94 double* _domain_bounding_boxes;
95 const ProcessorGroup& _distant_group;
96 const ProcessorGroup& _local_group;
97 ProcessorGroup* _union_group;
98 std::vector<int> _distant_proc_ids;
99 const MPI_Comm *_comm;
100 //Attributes only used by lazy side
101 std::vector<double> _values_added;
102 std::vector< std::vector<mcIdType> > _ids_per_working_proc;
103 std::vector< std::vector<mcIdType> > _ids_per_working_proc3;
104 std::vector< std::vector<double> > _values_per_working_proc;
106 static const int CUMULATIVE_POLICY=3;
107 static const int NO_POST_TREATMENT_POLICY=7;