Back to index

salome-med  6.5.0
OverlapElementLocator.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 __OVERLAPELEMENTLOCATOR_HXX__
00021 #define __OVERLAPELEMENTLOCATOR_HXX__
00022 
00023 #include "InterpolationOptions.hxx"
00024 #include "MEDCouplingNatureOfField.hxx"
00025 #include "MEDCouplingPointSet.hxx"
00026 #include "MEDCouplingMemArray.hxx"
00027 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
00028 
00029 #include <mpi.h>
00030 #include <vector>
00031 #include <map>
00032 #include <set>
00033 
00034 namespace ParaMEDMEM
00035 {
00036   class ParaFIELD;
00037   class ProcessorGroup;
00038   class ParaSUPPORT;
00039   class OverlapInterpolationMatrix;
00040   
00041   class OverlapElementLocator : public INTERP_KERNEL::InterpolationOptions
00042   {
00043   public:
00044     OverlapElementLocator(const ParaFIELD *sourceField, const ParaFIELD *targetField, const ProcessorGroup& group);
00045     virtual ~OverlapElementLocator();
00046     const MPI_Comm *getCommunicator() const;
00047     void exchangeMeshes(OverlapInterpolationMatrix& matrix);
00048     std::vector< std::pair<int,int> > getToDoList() const { return _to_do_list; }
00049     std::vector< std::vector< int > > getProcsInInteraction() const { return _proc_pairs; }
00050     std::string getSourceMethod() const;
00051     std::string getTargetMethod() const;
00052     const MEDCouplingPointSet *getSourceMesh(int procId) const;
00053     const DataArrayInt *getSourceIds(int procId) const;
00054     const MEDCouplingPointSet *getTargetMesh(int procId) const;
00055     const DataArrayInt *getTargetIds(int procId) const;
00056   private:
00057     void computeBoundingBoxes();
00058     bool intersectsBoundingBox(int i, int j) const;
00059     void sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const;
00060     void receiveRemoteMesh(int procId, bool sourceOrTarget);
00061     void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const;
00062     void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const;
00063   private:
00064     const ParaFIELD *_local_source_field;
00065     const ParaFIELD *_local_target_field;
00066     int _local_space_dim;
00067     MEDCouplingPointSet *_local_source_mesh;
00068     MEDCouplingPointSet *_local_target_mesh;
00069     std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
00070     std::vector<MEDCouplingPointSet*> _distant_face_meshes;
00072     std::vector< std::vector< int > > _proc_pairs;
00074     std::vector< std::pair<int,int> > _to_do_list;
00075     std::vector< std::pair<int,bool> > _procs_to_send;
00076     std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > > _remote_meshes;
00077     std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< DataArrayInt > > _remote_elems;
00078     double* _domain_bounding_boxes;
00079     const ProcessorGroup& _group;
00080     std::vector<int> _distant_proc_ids;
00081     const MPI_Comm *_comm;
00082     //Attributes only used by lazy side
00083     //std::vector<double> _values_added;
00084     //std::vector< std::vector<int> > _ids_per_working_proc;
00085     //std::vector< std::vector<int> > _ids_per_working_proc3;
00086     //std::vector< std::vector<double> > _values_per_working_proc;
00087   };
00088 
00089 }
00090 
00091 #endif