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})
// 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();
}
// 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"
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_*/
#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();
}
// 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"
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_*/
#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_*/
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);
MEDFileField1TS *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j));
if(!f1ts) continue;
DataArrayDouble *arr=f1ts->getUndergroundDataArray();
- arr->renumberInPlace(&perm[0]);
+ arr->renumberInPlace(perm->begin());
}
}
}