Salome HOME
MEDCoupling API renaming - stage #2
[tools/medcoupling.git] / src / ParaMEDMEM / MxN_Mapping.cxx
index e1fd35aa26b9096ad6f4e8daa4f4c655ac4a75a5..5c3f8d0bb901958b89fb576b111d8d0d4c425cc0 100644 (file)
@@ -1,21 +1,22 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "CommInterface.hxx" 
 #include "ProcessorGroup.hxx"
 #include "MPIProcessorGroup.hxx"
 
 using namespace std;
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
 
   MxN_Mapping::MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group,const DECOptions& dec_options)
-    : _union_group(source_group.fuse(target_group)),
-      DECOptions(dec_options)
+    : DECOptions(dec_options),
+      _union_group(source_group.fuse(target_group)),
+      _nb_comps(0), _sending_ids(), _recv_ids()
   {
     _access_DEC = new MPIAccessDEC(source_group,target_group,getAsynchronous());
     _access_DEC->setTimeInterpolator(getTimeInterpolationMethod());
@@ -57,6 +59,12 @@ namespace ParaMEDMEM
       _send_proc_offsets[i+1]++;
   }
 
+  void MxN_Mapping::initialize()
+  {
+    _sending_ids.clear();
+    std::fill(_send_proc_offsets.begin(),_send_proc_offsets.end(),0);
+  }
+
   void MxN_Mapping::prepareSendRecv()
   {
     CommInterface comm_interface=_union_group->getCommInterface();
@@ -103,7 +111,7 @@ namespace ParaMEDMEM
         recvdispls[i]=_recv_proc_offsets[i];
       }
     vector<int> offsets = _send_proc_offsets;
-    for (int i=0; i<_sending_ids.size();i++)
+    for (int i=0; i<(int)_sending_ids.size();i++)
       {
         int iproc = _sending_ids[i].first;
         isendbuf[offsets[iproc]]=_sending_ids[i].second;
@@ -161,7 +169,7 @@ namespace ParaMEDMEM
     //building the buffer of the elements to be sent
     vector<int> offsets = _send_proc_offsets;
 
-    for (int i=0; i<_sending_ids.size();i++)
+    for (int i=0; i<(int)_sending_ids.size();i++)
       { 
         int iproc = _sending_ids[i].first;
         for (int icomp=0; icomp<nbcomp; icomp++)
@@ -288,7 +296,6 @@ namespace ParaMEDMEM
     delete[] recvdispls;
   }
 
-
   ostream & operator<< (ostream & f ,const AllToAllMethod & alltoallmethod )
   {
     switch (alltoallmethod)