From: ageay Date: Tue, 24 Sep 2013 07:31:55 +0000 (+0000) Subject: Some minor refactoring for swig X-Git-Tag: V7_3_1b1~133 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5083dcf12b01a4944d0e07e3920b80daf17a42ac;p=tools%2Fmedcoupling.git Some minor refactoring for swig --- diff --git a/src/RENUMBER/CMakeLists.txt b/src/RENUMBER/CMakeLists.txt index 7810b4bf3..275d2c355 100644 --- a/src/RENUMBER/CMakeLists.txt +++ b/src/RENUMBER/CMakeLists.txt @@ -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}) diff --git a/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx b/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx index 60d5eec3d..34c98685f 100644 --- a/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx +++ b/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx @@ -17,32 +17,39 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "RENUMBER_BOOSTRenumbering.hxx" + +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" + #include #include #include #include #include -#include "RENUMBER_BOOSTRenumbering.hxx" - -void BOOSTRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector& iperm,std::vector& 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 out0(ParaMEDMEM::DataArrayInt::New()),out1(ParaMEDMEM::DataArrayInt::New()); + out0->alloc(nbCell,1); out1->alloc(nbCell,1); + out0->fillWithZero(); out1->fillWithZero(); + // typedef boost::adjacency_list > > Graph; typedef boost::graph_traits::vertex_descriptor Vertex; typedef boost::graph_traits::vertices_size_type size_type; - Graph G(nb_cell); - for (int i=0;i::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(); } diff --git a/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx b/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx index ff1b6d6a3..97c81eccd 100644 --- a/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx +++ b/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx @@ -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& iperm,std::vector& perm); + void renumber(const int *graph, const int *index_graph, int nbCell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm); }; #endif /*BOOSTRENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RENUMBER_METISRenumbering.cxx b/src/RENUMBER/RENUMBER_METISRenumbering.cxx index ca07cf8dc..1227e879a 100644 --- a/src/RENUMBER/RENUMBER_METISRenumbering.cxx +++ b/src/RENUMBER/RENUMBER_METISRenumbering.cxx @@ -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& iperm,std::vector& 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 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(); } diff --git a/src/RENUMBER/RENUMBER_METISRenumbering.hxx b/src/RENUMBER/RENUMBER_METISRenumbering.hxx index e5591911e..47eb3c3d0 100644 --- a/src/RENUMBER/RENUMBER_METISRenumbering.hxx +++ b/src/RENUMBER/RENUMBER_METISRenumbering.hxx @@ -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& iperm,std::vector& perm); + virtual void renumber(const int *graph, const int *index_graph, int nb_cell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm); }; #endif /*METISRENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RENUMBER_Renumbering.hxx b/src/RENUMBER/RENUMBER_Renumbering.hxx index acc79f6b4..13dd07215 100644 --- a/src/RENUMBER/RENUMBER_Renumbering.hxx +++ b/src/RENUMBER/RENUMBER_Renumbering.hxx @@ -22,10 +22,15 @@ #include "RENUMBERDefines.hxx" #include +namespace ParaMEDMEM +{ + class DataArrayInt; +} + class RENUMBER_EXPORT Renumbering { public: - virtual void renumber(const int* graphe,const int* index_graphe,int nb_cell,std::vector& iperm,std::vector& perm)=0; + virtual void renumber(const int *graph, const int *index_graph, int nbCell, ParaMEDMEM::DataArrayInt *&iperm, ParaMEDMEM::DataArrayInt *&perm) = 0; }; #endif /*RENUMBERING_HXX_*/ diff --git a/src/RENUMBER/renumbering.cxx b/src/RENUMBER/renumbering.cxx index ce86bde6e..41c6938f4 100644 --- a/src/RENUMBER/renumbering.cxx +++ b/src/RENUMBER/renumbering.cxx @@ -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 neighbSafe(neighb),neighbISafe(neighbI); + MEDCouplingAutoRefCountObjectPtr neighbSafe(neighb),neighbISafe(neighbI),ipermSafe,permSafe; const int *graph=neighbSafe->begin(); const int *graph_index=neighbISafe->begin(); // Compute permutation iperm->new2old perm->old2new - vector 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 famField2=famField->renumber(&perm[0]); + MEDCouplingAutoRefCountObjectPtr 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(fmts->getTimeStepAtPos(j)); if(!f1ts) continue; DataArrayDouble *arr=f1ts->getUndergroundDataArray(); - arr->renumberInPlace(&perm[0]); + arr->renumberInPlace(perm->begin()); } } }