X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FRENUMBER%2Frenumbering.cxx;h=f3fcec95ee872e831c3fff12df6c905189f736cd;hb=c4551c56aa89896595842e5b41b048044681b4e8;hp=765fb7f8f87622d67b28440eab04651edba2e7b7;hpb=a7c082163b233407db4d145f53be4b68bd21cde2;p=tools%2Fmedcoupling.git diff --git a/src/RENUMBER/renumbering.cxx b/src/RENUMBER/renumbering.cxx index 765fb7f8f..f3fcec95e 100644 --- a/src/RENUMBER/renumbering.cxx +++ b/src/RENUMBER/renumbering.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 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 // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// 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 @@ -32,7 +32,7 @@ #include using namespace std; -using namespace ParaMEDMEM; +using namespace MEDCoupling; using namespace MED_RENUMBER; int main(int argc, char** argv) @@ -57,8 +57,8 @@ int main(int argc, char** argv) } // Reading file structure cout << "Reading : " << flush; - MEDCouplingAutoRefCountObjectPtr fd=MEDFileData::New(filename_in); - MEDFileMesh *m=fd->getMeshes()->getMeshWithName(meshname.c_str()); + MCAuto fd(MEDFileData::New(filename_in)); + MEDFileMesh *m=fd->getMeshes()->getMeshWithName(meshname); MEDFileUMesh *mc=dynamic_cast(m); if(!mc) { @@ -68,40 +68,60 @@ int main(int argc, char** argv) t_read_st=clock(); cout << (t_read_st-t_begin)/(double) CLOCKS_PER_SEC << "s" << endl << flush; // Reading mesh - MEDCouplingAutoRefCountObjectPtr workMesh=mc->getMeshAtLevel(0); + MCAuto workMesh=mc->getMeshAtLevel(0); std::vector code=workMesh->getDistributionOfTypes(); cout << "Building the graph : " << flush; DataArrayInt *neighb=0,*neighbI=0; workMesh->computeNeighborsOfCells(neighb,neighbI); - MEDCouplingAutoRefCountObjectPtr neighbSafe(neighb),neighbISafe(neighbI); + MCAuto 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,nb_cell,iperm,perm); + renumb->renumber(graph,graph_index,workMesh->getNumberOfCells(),iperm,perm); + ipermSafe=iperm; permSafe=perm; delete renumb; + 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]); + MCAuto famField2=famField->renumber(perm->begin()); mc->setFamilyFieldArr(0,famField2); } - mc->write(filename_out.c_str(),2); + mc->write(filename_out,2); t_family=clock(); cout << " : " << (t_family-t_compute_graph)/(double) CLOCKS_PER_SEC << "s" << endl << flush; // Fields cout << "Reordering fields and writing : " << flush; MEDFileFields *fs=fd->getFields(); - fs->renumberEntitiesLyingOnMesh(meshname.c_str(),code,code,&perm[0]); - fs->write(); + if(fs) + { + for(int i=0;igetNumberOfFields();i++) + { + MEDFileFieldMultiTS *fmts=dynamic_cast(fs->getFieldAtPos(i)); + if(!fmts) continue; + if(fmts->getMeshName()==meshname) + { + for(int j=0;jgetNumberOfTS();j++) + { + MEDFileField1TS *f1ts=dynamic_cast(fmts->getTimeStepAtPos(j)); + if(!f1ts) continue; + DataArrayDouble *arr=f1ts->getUndergroundDataArray(); + arr->renumberInPlace(perm->begin()); + } + } + } + fs->write(filename_out,0); + //fs->renumberEntitiesLyingOnMesh(meshname,code,code,o2n); bugged + } t_field=clock(); cout << " : " << (t_field-t_family)/(double) CLOCKS_PER_SEC << "s" << endl << flush; return 0;