Back to index

salome-med  6.5.0
ElementLocator.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __ELEMENTLOCATOR_HXX__
00021 #define __ELEMENTLOCATOR_HXX__
00022 
00023 #include "InterpolationOptions.hxx"
00024 #include "MEDCouplingNatureOfField.hxx"
00025 
00026 #include <mpi.h>
00027 #include <vector>
00028 #include <set>
00029 
00030 namespace ParaMEDMEM
00031 {
00032   class ParaFIELD;
00033   class ProcessorGroup;
00034   class ParaSUPPORT;
00035   class InterpolationMatrix;
00036   class MEDCouplingPointSet;
00037   class DataArrayInt;
00038 
00039   class ElementLocator : public INTERP_KERNEL::InterpolationOptions
00040   {
00041   public:
00042     ElementLocator(const ParaFIELD& sourceField, const ProcessorGroup& distant_group, const ProcessorGroup& local_group);
00043 
00044     virtual ~ElementLocator();
00045     void exchangeMesh(int idistantrank,
00046                       MEDCouplingPointSet*& target_mesh,
00047                       int*& distant_ids);
00048     void exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth);
00049     const std::vector<int>& getDistantProcIds() const { return _distant_proc_ids; }
00050     const MPI_Comm *getCommunicator() const;
00051     NatureOfField getLocalNature() const;
00053     bool isM1DCorr() const { return _is_m1d_corr; }
00054     //Working side methods
00055     void recvPolicyFromLazySideW(std::vector<int>& policy);
00056     void sendSumToLazySideW(const std::vector< std::vector<int> >& distantLocEltIds, const std::vector< std::vector<double> >& partialSumRelToDistantIds);
00057     void recvSumFromLazySideW(std::vector< std::vector<double> >& globalSumRelToDistantIds);
00058     void sendCandidatesForAddElementsW(const std::vector<int>& distantGlobIds);
00059     void recvAddElementsFromLazyProcsW(std::vector<std::vector<int> >& elementsToAdd);
00060     //
00061     void sendLocalIdsToLazyProcsW(const std::vector< std::vector<int> >& distantLocEltIds);
00062     void recvGlobalIdsFromLazyProcsW(const std::vector< std::vector<int> >& distantLocEltIds, std::vector< std::vector<int> >& globalIds);
00063     void recvCandidatesGlobalIdsFromLazyProcsW(std::vector< std::vector<int> >& globalIds);
00064     void sendPartialSumToLazyProcsW(const std::vector<int>& distantGlobIds, const std::vector<double>& sum);
00065     //Lazy side methods
00066     int sendPolicyToWorkingSideL();
00067     void recvFromWorkingSideL();
00068     void sendToWorkingSideL();
00069     //
00070     void recvLocalIdsFromWorkingSideL();
00071     void sendGlobalIdsToWorkingSideL();
00072     void sendCandidatesGlobalIdsToWorkingSideL();
00073     //
00074     void recvSumFromWorkingSideL();
00075     void recvCandidatesForAddElementsL();
00076     void sendAddElementsToWorkingSideL();
00077   private:
00078     void _computeBoundingBoxes();
00079     bool _intersectsBoundingBox(int irank);
00080     void _exchangeMesh(MEDCouplingPointSet* local_mesh, MEDCouplingPointSet*& distant_mesh,
00081                        int iproc_distant, const DataArrayInt* distant_ids_send,
00082                        int*& distant_ids_recv);
00083   private:
00084     const ParaFIELD&  _local_para_field ;
00085     MEDCouplingPointSet* _local_cell_mesh;
00086     int _local_cell_mesh_space_dim;
00087     bool _is_m1d_corr;
00088     MEDCouplingPointSet* _local_face_mesh;
00089     std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
00090     std::vector<MEDCouplingPointSet*> _distant_face_meshes;
00091     double* _domain_bounding_boxes;
00092     const ProcessorGroup& _distant_group;
00093     const ProcessorGroup& _local_group;
00094     ProcessorGroup* _union_group;
00095     std::vector<int> _distant_proc_ids;
00096     const MPI_Comm *_comm;
00097     //Attributes only used by lazy side
00098     std::vector<double> _values_added;
00099     std::vector< std::vector<int> > _ids_per_working_proc;
00100     std::vector< std::vector<int> > _ids_per_working_proc3;
00101     std::vector< std::vector<double> > _values_per_working_proc;
00102   public:
00103     static const int CUMULATIVE_POLICY=3;
00104     static const int NO_POST_TREATMENT_POLICY=7;
00105   };
00106 
00107 }
00108 
00109 #endif