Salome HOME
Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/salome/medcoupling
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_ParaDomainSelector.cxx
index e6beacf192a2575f0d9b1a9433598a912e0943e6..2a840a350dcc6a16c0cc42f0a6886c47c608f0f5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  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
 #include "MEDPARTITIONER_Utils.hxx"
 
 #include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingSkyLineArray.hxx"
 
 #include <iostream>
 #include <numeric>
 
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
 #include <mpi.h>
 #endif
 
@@ -37,7 +38,7 @@ MEDPARTITIONER::ParaDomainSelector::ParaDomainSelector(bool mesure_memory)
   :_rank(0),_world_size(1), _nb_result_domains(-1), _init_time(0.0),
    _mesure_memory(mesure_memory), _init_memory(0), _max_memory(0)
 {
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
   if (MyGlobals::_Rank==-1)
     {
       MPI_Init(0,0);  //do once only
@@ -55,7 +56,7 @@ MEDPARTITIONER::ParaDomainSelector::ParaDomainSelector(bool mesure_memory)
   _world_size=1;
   _rank=0;
   if (MyGlobals::_Verbose>10)
-    std::cout << "WARNING : ParaDomainSelector contructor without parallel_mode World_Size=1 by default" << std::endl;
+    std::cout << "WARNING : ParaDomainSelector constructor without parallel_mode World_Size=1 by default" << std::endl;
 #endif
   MyGlobals::_World_Size=_world_size;
   MyGlobals::_Rank=_rank;
@@ -76,7 +77,7 @@ bool MEDPARTITIONER::ParaDomainSelector::isOnDifferentHosts() const
   evaluateMemory();
   if ( _world_size < 2 ) return false;
 
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
   char name_here[ MPI_MAX_PROCESSOR_NAME+1 ], name_there[ MPI_MAX_PROCESSOR_NAME+1 ];
   int size;
   MPI_Get_processor_name( name_here, &size);
@@ -132,7 +133,7 @@ int MEDPARTITIONER::ParaDomainSelector::getProcessorID(int domainIndex) const
  * 1) for MED_CELL to know global id shift for domains at graph construction;
  * 2) for sub-entity to know total nb of sub-entities before creating those of joints
  */
-void MEDPARTITIONER::ParaDomainSelector::gatherNbOf(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>& domain_meshes)
+void MEDPARTITIONER::ParaDomainSelector::gatherNbOf(const std::vector<MEDCoupling::MEDCouplingUMesh*>& domain_meshes)
 {
   evaluateMemory();
   // get nb of elems of each domain mesh
@@ -152,11 +153,11 @@ void MEDPARTITIONER::ParaDomainSelector::gatherNbOf(const std::vector<ParaMEDMEM
     }
   else
     {
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
       all_nb_elems.resize( nb_domains*2 );
       MPI_Allreduce((void*)&nb_elems[0], (void*)&all_nb_elems[0], nb_domains*2, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
 #else
-      throw INTERP_KERNEL::Exception("not(HAVE_MPI2) incompatible with MPI_World_Size>1");
+      throw INTERP_KERNEL::Exception("not(HAVE_MPI) incompatible with MPI_World_Size>1");
 #endif
    }
   int total_nb_cells=0, total_nb_nodes=0;
@@ -289,7 +290,7 @@ std::auto_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherG
   Graph* glob_graph = 0;
 
   evaluateMemory();
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
 
   // ---------------
   // Gather indices
@@ -339,7 +340,7 @@ std::auto_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherG
 
   int value_size = graph_index[ index_size-1 ] - graph_index[ 0 ];
   int *graph_value = new int[ value_size ];
-  const int *value = graph->getGraph()->getValue();
+  const int *value = graph->getGraph()->getValues();
 
   MPI_Allgatherv((void*) value,                // send local value
                  value_size_of_proc[_rank],    // value size on this proc
@@ -370,8 +371,8 @@ std::auto_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherG
   // Make graph
   // -----------
 
-  //   MEDPARTITIONER::SkyLineArray* array =
-  //     new MEDPARTITIONER::SkyLineArray( index_size-1, value_size, graph_index, graph_value, true );
+  //   MEDCouplingSkyLineArray* array =
+  //     new MEDCouplingSkyLineArray( index_size-1, value_size, graph_index, graph_value, true );
 
   //   glob_graph = new UserGraph( array, partition, index_size-1 );
 
@@ -379,7 +380,7 @@ std::auto_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherG
 
   delete [] partition;
 
-#endif // HAVE_MPI2
+#endif // HAVE_MPI
 
   return std::auto_ptr<Graph>( glob_graph );
 }
@@ -430,7 +431,7 @@ void MEDPARTITIONER::ParaDomainSelector::gatherNbCellPairs()
   evaluateMemory();
 
   std::vector< int > send_buf = _nb_cell_pairs_by_joint;
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
   MPI_Allreduce((void*)&send_buf[0],
                 (void*)&_nb_cell_pairs_by_joint[0],
                 _nb_cell_pairs_by_joint.size(),
@@ -477,7 +478,7 @@ int *MEDPARTITIONER::ParaDomainSelector::exchangeSubentityIds( int loc_domain, i
                                                const std::vector<int>& loc_ids_here ) const
 {
   int* loc_ids_dist = new int[ loc_ids_here.size()];
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
   int dest = getProcessorID( dist_domain );
   int tag  = 2002 + jointId( loc_domain, dist_domain );
   MPI_Status status;
@@ -516,7 +517,7 @@ int MEDPARTITIONER::ParaDomainSelector::jointId( int local_domain, int distant_d
 
 double MEDPARTITIONER::ParaDomainSelector::getPassedTime() const
 {
-#ifdef HAVE_MPI2
+#ifdef HAVE_MPI
   return MPI_Wtime() - _init_time;
 #else
   return 0.0;
@@ -529,9 +530,9 @@ double MEDPARTITIONER::ParaDomainSelector::getPassedTime() const
   \param target processor id of the target
 */
 
-void MEDPARTITIONER::ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const
+void MEDPARTITIONER::ParaDomainSelector::sendMesh(const MEDCoupling::MEDCouplingUMesh& mesh, int target) const
 {
-#ifndef HAVE_MPI2
+#ifndef HAVE_MPI
   throw INTERP_KERNEL::Exception("ParaDomainSelector::sendMesh : incoherent call in non_MPI mode");
 #else
   if (MyGlobals::_Verbose>600)
@@ -551,8 +552,8 @@ void MEDPARTITIONER::ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingU
 
   if (mesh.getNumberOfCells()>0) //no sends if empty
     {
-      ParaMEDMEM::DataArrayInt *v1Local=0;
-      ParaMEDMEM::DataArrayDouble *v2Local=0;
+      MEDCoupling::DataArrayInt *v1Local=0;
+      MEDCoupling::DataArrayDouble *v2Local=0;
       //serialization of local mesh to send data to distant proc.
       mesh.serialize(v1Local,v2Local);
       int nbLocalElems=0;
@@ -582,9 +583,9 @@ void MEDPARTITIONER::ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingU
   \param mesh  pointer to mesh that is filled
   \param source processor id of the incoming messages
 */
-void MEDPARTITIONER::ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int source)const
+void MEDPARTITIONER::ParaDomainSelector::recvMesh(MEDCoupling::MEDCouplingUMesh*& mesh, int source)const
 {
-#ifndef HAVE_MPI2
+#ifndef HAVE_MPI
   throw INTERP_KERNEL::Exception("ParaDomainSelector::recvMesh : incoherent call in non_MPI mode");
 #else
   // First stage : exchanging sizes
@@ -605,14 +606,14 @@ void MEDPARTITIONER::ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*&
   int NumberOfCells=tinyInfoDistant[tinyVecSize-1];
   if (NumberOfCells>0)
     {
-      ParaMEDMEM::DataArrayInt *v1Distant=ParaMEDMEM::DataArrayInt::New();
-      ParaMEDMEM::DataArrayDouble *v2Distant=ParaMEDMEM::DataArrayDouble::New();
+      MEDCoupling::DataArrayInt *v1Distant=MEDCoupling::DataArrayInt::New();
+      MEDCoupling::DataArrayDouble *v2Distant=MEDCoupling::DataArrayDouble::New();
       //Building the right instance of copy of distant mesh.
-      ParaMEDMEM::MEDCouplingPointSet *distant_mesh_tmp=
-        ParaMEDMEM::MEDCouplingPointSet::BuildInstanceFromMeshType(
-                                                                   (ParaMEDMEM::MEDCouplingMeshType) tinyInfoDistant[0]);
+      MEDCoupling::MEDCouplingPointSet *distant_mesh_tmp=
+        MEDCoupling::MEDCouplingPointSet::BuildInstanceFromMeshType(
+                                                                   (MEDCoupling::MEDCouplingMeshType) tinyInfoDistant[0]);
       std::vector<std::string> unusedTinyDistantSts;
-      mesh=dynamic_cast<ParaMEDMEM::MEDCouplingUMesh*> (distant_mesh_tmp);
+      mesh=dynamic_cast<MEDCoupling::MEDCouplingUMesh*> (distant_mesh_tmp);
  
       mesh->resizeForUnserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
       int nbDistElem=0;
@@ -645,7 +646,7 @@ void MEDPARTITIONER::ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*&
 #endif
 }
 
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
 #include <sys/sysinfo.h>
 #endif
 
@@ -657,7 +658,7 @@ int MEDPARTITIONER::ParaDomainSelector::evaluateMemory() const
   if ( _mesure_memory )
     {
       int used_memory = 0;
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
       struct sysinfo si;
       int err = sysinfo( &si );
       if ( !err )