]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Some minor refactoring for swig
authorageay <ageay>
Tue, 24 Sep 2013 07:31:55 +0000 (07:31 +0000)
committerageay <ageay>
Tue, 24 Sep 2013 07:31:55 +0000 (07:31 +0000)
src/RENUMBER/CMakeLists.txt
src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx
src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx
src/RENUMBER/RENUMBER_METISRenumbering.cxx
src/RENUMBER/RENUMBER_METISRenumbering.hxx
src/RENUMBER/RENUMBER_Renumbering.hxx
src/RENUMBER/renumbering.cxx

index 7810b4bf3589012c339b7e717e42e879c37ca376..275d2c355bc6cf78e4c8157e645507af8ff5d91d 100644 (file)
@@ -53,14 +53,14 @@ SET(renumber_SOURCES
 
 SET(renumbercpp_LDFLAGS medloader)
 
-IF(Metis_FOUND)
+IF(METIS_FOUND)
   INCLUDE_DIRECTORIES(${METIS_INCLUDE_DIRS})
   
   SET(renumbercpp_SOURCES ${renumbercpp_SOURCES} RENUMBER_METISRenumbering.cxx)
   SET(renumbercpp_HEADERS_HXX ${renumbercpp_HEADERS_HXX} RENUMBER_METISRenumbering.hxx)
-  SET(renumbercpp_LDFLAGS ${renumbercpp_LDFLAGS} ${METIS_LIBS})
+  SET(renumbercpp_LDFLAGS ${renumbercpp_LDFLAGS} ${METIS_LIBRARIES})
   SET(renumber_DEFINITIONS "${renumber_DEFINITIONS} ${METIS_DEFINITIONS}")
-ENDIF(Metis_FOUND)
+ENDIF(METIS_FOUND)
 
 IF(Boost_FOUND)
   INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
index 60d5eec3d8dd83030849905759133f89c98b5e07..34c98685f0e83e475a3c105871810f2f9cceecec 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+#include "RENUMBER_BOOSTRenumbering.hxx"
+
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
 #include <boost/config.hpp>
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/graph/cuthill_mckee_ordering.hpp>
 #include <boost/graph/properties.hpp>
 #include <boost/graph/bandwidth.hpp>
 
-#include "RENUMBER_BOOSTRenumbering.hxx"
-
-void BOOSTRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm)
+void BOOSTRenumbering::renumber(const int *graph, const int *index_graph, int nbCell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm)
 {
-  iperm.resize(nb_cell,0);
-  perm.resize(nb_cell,0);
-
+  ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayInt> out0(ParaMEDMEM::DataArrayInt::New()),out1(ParaMEDMEM::DataArrayInt::New());
+  out0->alloc(nbCell,1); out1->alloc(nbCell,1);
+  out0->fillWithZero(); out1->fillWithZero();
+  //
   typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, 
      boost::property<boost::vertex_color_t, boost::default_color_type,
        boost::property<boost::vertex_degree_t,int> > > Graph;
   typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
   typedef boost::graph_traits<Graph>::vertices_size_type size_type;
-  Graph G(nb_cell);
-  for (int i=0;i<nb_cell;++i)
+  Graph G(nbCell);
+  for (int i=0;i<nbCell;++i)
     for (int j=index_graph[i];j<index_graph[i+1];++j)
       add_edge(i,graph[j],G);
   boost::property_map<Graph, boost::vertex_index_t>::type
     index_map = boost::get(boost::vertex_index, G);
-  boost::cuthill_mckee_ordering(G, iperm.rbegin(), boost::get(boost::vertex_color, G),
+  boost::cuthill_mckee_ordering(G, out0->getPointer(), boost::get(boost::vertex_color, G),
                            boost::make_degree_map(G));
-  for (size_type c = 0; c != iperm.size(); ++c)
-    perm[index_map[iperm[c]]] = c;
+  int *out0Ptr(out0->getPointer()),*out1Ptr(out1->getPointer());
+  for(int c=0;c!=nbCell;++c)
+    out1Ptr[index_map[out0Ptr[nbCell-c-1]]]=c;
+  out0->reverse();
+  iperm=out0.retn(); perm=out1.retn();
 }
index ff1b6d6a3aed95a7b4f17fda7375c81264c0bea1..97c81eccd5619971417356b873dd26938a62e294 100644 (file)
@@ -17,8 +17,8 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#ifndef BOOSTRENUMBERING_HXX_
-#define BOOSTRENUMBERING_HXX_
+#ifndef __BOOSTRENUMBERING_HXX__
+#define __BOOSTRENUMBERING_HXX__
 
 #include "RENUMBERDefines.hxx"
 #include "RENUMBER_Renumbering.hxx"
@@ -26,7 +26,7 @@
 class RENUMBER_EXPORT BOOSTRenumbering:public Renumbering
 {
 public:
-  virtual void renumber(const int* graph,const int* index_graph,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm);
+  void renumber(const int *graph, const int *index_graph, int nbCell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm);
 };
 
 #endif /*BOOSTRENUMBERING_HXX_*/
index ca07cf8dc6043fb2354e85209b10db458fbf6cc8..1227e879a3edeff0083d886e4c5dc900fe75ed8a 100644 (file)
@@ -28,13 +28,18 @@ extern "C"
 #include "metis.h"
 }
 
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
 #include "RENUMBER_METISRenumbering.hxx"
 
-void METISRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm)
+void METISRenumbering::renumber(const int *graph, const int *index_graph, int nbCell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm)
 {
-  iperm.resize(nb_cell,0);
-  perm.resize(nb_cell,0);
+  ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayInt> out0(ParaMEDMEM::DataArrayInt::New()),out1(ParaMEDMEM::DataArrayInt::New());
+  out0->alloc(nbCell,1); out1->alloc(nbCell,1);
+  out0->fillWithZero(); out1->fillWithZero();
   int num_flag=1;
   int options=0;
-  METIS_NodeND(&nb_cell,(int*)index_graph,(int*)graph,&num_flag,&options,&iperm[0],&perm[0]);
+  METIS_NodeND(&nbCell,(int*)index_graph,(int*)graph,&num_flag,&options,out0->getPointer(),out1->getPointer());
+  iperm=out0.retn(); perm=out1.retn();
 }
index e5591911edd3b3578e49419171da45535439b55e..47eb3c3d0c0c1056353f598cd0e16dc3c2d4405a 100644 (file)
@@ -17,8 +17,8 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#ifndef METISRENUMBERING_HXX_
-#define METISRENUMBERING_HXX_
+#ifndef __METISRENUMBERING_HXX__
+#define __METISRENUMBERING_HXX__
 
 #include "RENUMBERDefines.hxx"
 #include "RENUMBER_Renumbering.hxx"
@@ -26,7 +26,7 @@
 class RENUMBER_EXPORT METISRenumbering:public Renumbering
 {
 public:
-  virtual void renumber(const int* graph,const int* index_graph,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm);
+  virtual void renumber(const int *graph, const int *index_graph, int nb_cell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm);
 };
 
 #endif /*METISRENUMBERING_HXX_*/
index acc79f6b4a0fc8d7f8747fd4e65c82f4a535ffc6..13dd07215456ec23402fcc23b4aa70af13d6a0cc 100644 (file)
 #include "RENUMBERDefines.hxx"
 #include <vector>
 
+namespace ParaMEDMEM
+{
+  class DataArrayInt;
+}
+
 class RENUMBER_EXPORT Renumbering
 {
 public:
-  virtual void renumber(const int* graphe,const int* index_graphe,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm)=0;
+  virtual void renumber(const int *graph, const int *index_graph, int nbCell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm) = 0;
 }; 
 
 #endif /*RENUMBERING_HXX_*/
index ce86bde6e44e2c638b89ce2e8a4959c6ae8caeee..41c6938f46c31ab476becb939c0a9093b22048e7 100644 (file)
@@ -73,26 +73,27 @@ int main(int argc, char** argv)
   cout << "Building the graph : " << flush;
   DataArrayInt *neighb=0,*neighbI=0;
   workMesh->computeNeighborsOfCells(neighb,neighbI);
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> neighbSafe(neighb),neighbISafe(neighbI);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> neighbSafe(neighb),neighbISafe(neighbI),ipermSafe,permSafe;
   const int *graph=neighbSafe->begin();
   const int *graph_index=neighbISafe->begin();
   // Compute permutation iperm->new2old perm->old2new
-  vector<int> iperm,perm;
+  DataArrayInt *iperm(0),*perm(0);
   Renumbering *renumb=RenumberingFactory(type_renum);
   renumb->renumber(graph,graph_index,workMesh->getNumberOfCells(),iperm,perm);
+  ipermSafe=iperm; permSafe=perm;
   delete renumb;
-  iperm.clear();//erase new2old, we are using only old 2 new
+  ipermSafe=0;//erase new2old, we are using only old 2 new
   t_compute_graph=clock();
   cout << " : " << (t_compute_graph-t_read_st)/(double) CLOCKS_PER_SEC << "s" << endl;
   cout.flush();
   // Connectivity
   cout << "Reordering connectivity & families and writing : " << flush;
-  workMesh->renumberCells(&perm[0],false);
+  workMesh->renumberCells(perm->begin(),false);
   mc->setMeshAtLevel(0,workMesh);
   const DataArrayInt *famField=mc->getFamilyFieldAtLevel(0);
   if(famField)
     {
-      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> famField2=famField->renumber(&perm[0]);
+      MEDCouplingAutoRefCountObjectPtr<DataArrayInt> famField2=famField->renumber(perm->begin());
       mc->setFamilyFieldArr(0,famField2);
     }
   mc->write(filename_out.c_str(),2);
@@ -114,7 +115,7 @@ int main(int argc, char** argv)
                   MEDFileField1TS *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j));
                  if(!f1ts) continue;
                   DataArrayDouble *arr=f1ts->getUndergroundDataArray();
-                  arr->renumberInPlace(&perm[0]);
+                  arr->renumberInPlace(perm->begin());
                 }
             }
         }