Salome HOME
Implementation of ParaUMesh::getCellIdsLyingOnNodes
[tools/medcoupling.git] / src / ParaMEDMEM / ExplicitTopology.cxx
index de90d7060de29466fca21462e5c72ed716d92672..0d46627db0acb29c9345f960528b4103ea761d64 100644 (file)
@@ -1,21 +1,22 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019  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"
 #include <algorithm>
 
 using namespace std;
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
 
+ExplicitTopology::ExplicitTopology():
+   _proc_group(NULL), _nb_elems(0), _nb_components(0),
+   _loc2glob(NULL), _glob2loc()
+  {}
+
 ExplicitTopology::ExplicitTopology(const ParaMESH& paramesh ):
 _proc_group(paramesh.getBlockTopology()->getProcGroup()),
 _nb_components(1)
 {
   _nb_elems=paramesh.getCellMesh()->getNumberOfCells();
-  const int* global=paramesh.getGlobalNumberingCell();
-  _loc2glob=new int[_nb_elems]; 
+  const mcIdType* global=paramesh.getGlobalNumberingCell();
+  _loc2glob=new mcIdType[_nb_elems]; 
   
-    for (int i=0; i<_nb_elems; i++)
+    for (mcIdType i=0; i<_nb_elems; i++)
     {
       _loc2glob[i]=global[i];
       _glob2loc[global[i]]=i;
@@ -52,8 +58,8 @@ ExplicitTopology::ExplicitTopology(const ExplicitTopology& topo, int nb_componen
   _proc_group = topo._proc_group;
   _nb_elems = topo._nb_elems;
   _nb_components = nb_components;
-  _loc2glob=new int[_nb_elems];
-  for (int i=0; i<_nb_elems; i++)
+  _loc2glob=new mcIdType[_nb_elems];
+  for (mcIdType i=0; i<_nb_elems; i++)
     {
       _loc2glob[i]=topo._loc2glob[i];
     }
@@ -69,18 +75,18 @@ ExplicitTopology::~ExplicitTopology()
 
 /*! Serializes the data contained in the Explicit Topology
  * for communication purposes*/
-void ExplicitTopology::serialize(int* & serializer, int& size) const 
+void ExplicitTopology::serialize(mcIdType* & serializer, mcIdType& size) const 
 {
-  vector <int> buffer;
+  vector <mcIdType> buffer;
   
   buffer.push_back(_nb_elems);
-  for (int i=0; i<_nb_elems; i++)
+  for (mcIdType i=0; i<_nb_elems; i++)
   {
     buffer.push_back(_loc2glob[i]);
   }
     
-  serializer=new int[buffer.size()];
-  size=  buffer.size();
+  serializer=new mcIdType[buffer.size()];
+  size=ToIdType(buffer.size());
   copy(buffer.begin(), buffer.end(), serializer);
   
 }
@@ -88,14 +94,14 @@ void ExplicitTopology::serialize(int* & serializer, int& size) const
  * after communication. Uses the same structure as the one used for serialize()
  * 
  * */
-void ExplicitTopology::unserialize(const int* serializer,const CommInterface& comm_interface)
+void ExplicitTopology::unserialize(const mcIdType* serializer,const CommInterface& comm_interface)
 {
-  const int* ptr_serializer=serializer;
+  const mcIdType* ptr_serializer=serializer;
   cout << "unserialize..."<<endl;
   _nb_elems=*ptr_serializer++;
   cout << "nbelems "<<_nb_elems<<endl;
-  _loc2glob=new int[_nb_elems];
-  for (int i=0; i<_nb_elems; i++)
+  _loc2glob=new mcIdType[_nb_elems];
+  for (mcIdType i=0; i<_nb_elems; i++)
   {
     _loc2glob[i]=*ptr_serializer;
     _glob2loc[*ptr_serializer]=i;