Back to index

salome-med  6.5.0
MEDSPLITTER_MeshSendReceive.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 // File      : MEDSPLITTER_MeshSendReceive.hxx
00020 // Created   : Tue Jun 30 19:14:51 2009
00021 // Author    : Edward AGAPOV (eap)
00022 
00023 
00024 #ifndef __MEDSPLITTER_MeshSendReceive_HXX__
00025 #define __MEDSPLITTER_MeshSendReceive_HXX__
00026 
00027 #include "MEDSPLITTER.hxx"
00028 
00029 #ifdef HAVE_MPI2
00030 #include <mpi.h>
00031 #else
00032 typedef int MPI_Request;
00033 #endif
00034 
00035 #include <vector>
00036 
00037 namespace MEDMEM
00038 {
00039   class MESH;
00040 }
00041 
00042 namespace MEDSPLITTER
00043 {
00052   class MEDSPLITTER_EXPORT MeshSendReceive
00053   {
00054   public:
00055 
00056     MeshSendReceive();
00057     ~MeshSendReceive();
00058 
00059     // Sends the mesh of idomain to irank processor asynchronously
00060     // WARNING: do NOT delete the mesh until this->isSent()!
00061     void send(int irank, int idomain, MEDMEM::MESH* mesh,
00062               const std::vector<int>& cell_glob_nums,
00063               const std::vector<int>& face_glob_nums,
00064               const std::vector<int>& node_glob_nums);
00065 
00066     // Receives the mesh of idomain from irank processor synchronously
00067     MEDMEM::MESH* recv(int irank, int idomain,
00068                        std::vector<int>& cell_glob_numbers,
00069                        std::vector<int>& face_glob_numbers,
00070                        std::vector<int>& node_glob_numbers);
00071 
00073     MEDMEM::MESH* getMesh() { return _mesh; }
00074 
00075     // Returns true if mesh is already sent
00076     bool isSent();
00077 
00078     // Frees buffers waiting until isSent()
00079     void clear();
00080 
00081   private:
00082 
00083     std::vector< int > _int_buf;
00084     std::vector< int > _node_glob_numbers, _cell_glob_numbers, _face_glob_numbers;
00085     std::vector< char> _char_buf;
00086 
00087     MEDMEM::MESH*      _mesh;
00088 
00089     MPI_Request        _int_request, _coord_request, _char_request;
00090     MPI_Request        _node_nums_request, _cell_nums_request, _face_nums_request;
00091   };
00092 }
00093 
00094 
00095 #endif