X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FMEDReader%2FIO%2FMEDFileFieldRepresentationTree.cxx;h=4d3c82bd8bda011c0b10b231bcb95ad84ddf78f7;hb=c2fb6da45f443de1cacaebb2873904debc00bfc3;hp=3669c63cb5462ec53c42ebe7f40dbf6f6a78b47c;hpb=ebbd2915a22d111ae165c01dbdd7cd9b12848709;p=modules%2Fparavis.git diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 3669c63c..4d3c82bd 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// Copyright (C) 2010-2015 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 @@ -50,9 +50,6 @@ #include "vtkFieldData.h" #include "vtkCellData.h" -#include "vtksys/stl/string" -#include "vtksys/ios/fstream" -#include "vtksys/stl/algorithm" #include "vtkMutableDirectedGraph.h" using namespace ParaMEDMEM; @@ -110,7 +107,7 @@ vtkIdTypeArray *ELGACmp::isExisting(const std::vector& locsReallyUs vtkIdTypeArray *ELGACmp::createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const { - static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; std::vector< std::vector > locNames(_loc_names); std::vector elgas(_elgas); std::vector< std::pair< vtkQuadratureSchemeDefinition *, unsigned char > > defs; @@ -167,7 +164,7 @@ vtkIdTypeArray *ELGACmp::createNew(const ParaMEDMEM::MEDFileFieldGlobsReal *glob offset+=delta; } elga->GetInformation()->Set(MEDUtilities::ELGA(),1); - elga->SetArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); + elga->SetVoidArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); std::ostringstream oss; oss << "ELGA" << "@" << _loc_names.size(); std::string ossStr(oss.str()); elga->SetName(ossStr.c_str()); @@ -275,8 +272,8 @@ bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const ParaMEDMEM::MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDMeshMultiLev *mml, const ParaMEDMEM::MEDFileMeshStruct *mst, vtkDataSet *ds) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; - static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; tr->setNumberOfTS((operator->())->getNumberOfTS()); tr->initIterator(); for(int timeStepId=0;timeStepIdsize();timeStepId++,++(*tr)) @@ -366,7 +363,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, offset+=delta; } elno->GetInformation()->Set(MEDUtilities::ELNO(),1); - elno->SetArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); + elno->SetVoidArray(pt,ncell,0,VTK_DATA_ARRAY_DELETE); std::string nameElno("ELNO"); nameElno+="@"; nameElno+=name; elno->SetName(nameElno.c_str()); ds->GetCellData()->AddArray(elno); @@ -535,6 +532,12 @@ bool MEDFileFieldRepresentationLeaves::containZeName(const char *name, int& id) return false; } +void MEDFileFieldRepresentationLeaves::dumpState(std::map& status) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + status[(*it).getZeName()]=(*it).getStatus(); +} + bool MEDFileFieldRepresentationLeaves::isActivated() const { for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) @@ -628,7 +631,7 @@ void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationUnstructured(MEDUMeshMultiLev *mm) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; DataArrayDouble *coordsMC(0); DataArrayByte *typesMC(0); DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0); @@ -642,18 +645,18 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New()); cellTypes->SetArray(reinterpret_cast(typesSafe->getPointer()),nbOfCells,0,VTK_DATA_ARRAY_FREE); typesSafe->accessToMemArray().setSpecificDeallocator(0); vtkIdTypeArray *cellLocations(vtkIdTypeArray::New()); - cellLocations->SetArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + cellLocations->SetVoidArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0); vtkCellArray *cells(vtkCellArray::New()); vtkIdTypeArray *cells2(vtkIdTypeArray::New()); - cells2->SetArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0); + cells2->SetVoidArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0); cells->SetCells(nbOfCells,cells2); cells2->Delete(); if(faceLocationsMC!=0 && facesMC!=0) { vtkIdTypeArray *faces(vtkIdTypeArray::New()); - faces->SetArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0); + faces->SetVoidArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0); vtkIdTypeArray *faceLocations(vtkIdTypeArray::New()); - faceLocations->SetArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + faceLocations->SetVoidArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0); ret->SetCells(cellTypes,cellLocations,cells,faceLocations,faces); faceLocations->Delete(); faces->Delete(); @@ -683,7 +686,7 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCartesian(ParaMEDMEM::MEDCMeshMultiLev *mm) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; bool isInternal; std::vector< DataArrayDouble * > arrs(mm->buildVTUArrays(isInternal)); vtkDoubleArray *vtkTmp(0); @@ -736,7 +739,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCurveLinear(ParaMEDMEM::MEDCurveLinearMeshMultiLev *mm) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; int meshStr[3]={1,1,1}; DataArrayDouble *coords(0); std::vector nodeStrct; @@ -778,7 +781,7 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const ParaMEDMEM::MEDFileMeshes *meshes) const { - static const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; + const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; vtkDataSet *ret(0); //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs); MEDCouplingAutoRefCountObjectPtr mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change @@ -1104,6 +1107,14 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam { #ifdef MEDREADER_USE_MPI _ms=ParaMEDFileMeshes::New(iPart,nbOfParts,fileName); + int nbMeshes(_ms->getNumberOfMeshes()); + for(int i=0;igetMeshAtPos(i)); + ParaMEDMEM::MEDFileUMesh *tmp2(dynamic_cast(tmp)); + if(tmp2) + MEDCouplingAutoRefCountObjectPtr tmp3(tmp2->zipCoords()); + } _fields=MEDFileFields::LoadPartOf(fileName,false,_ms);//false is important to not read the values #else std::ostringstream oss; oss << "MEDFileFieldRepresentationTree::loadMainStructureOfFile : request for iPart/nbOfParts=" << iPart << "/" << nbOfParts << " whereas Plugin not compiled with MPI !"; @@ -1136,6 +1147,7 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam { AppendFieldFromMeshes(_ms,_fields); } + _ms->cartesianizeMe(); _fields->removeFieldsWithoutAnyTimeStep(); std::vector meshNames(_ms->getMeshesNames()); std::vector< MEDCouplingAutoRefCountObjectPtr > fields_per_mesh(meshNames.size()); @@ -1151,7 +1163,24 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam { MEDCouplingAutoRefCountObjectPtr fmts((*fields)->getFieldAtPos((int)j)); std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > tmp(fmts->splitDiscretizations()); - allFMTSLeavesToDisplaySafe.insert(allFMTSLeavesToDisplaySafe.end(),tmp.begin(),tmp.end()); + // EDF 8655 + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > >::const_iterator it=tmp.begin();it!=tmp.end();it++) + { + if(!(*it)->presenceOfMultiDiscPerGeoType()) + allFMTSLeavesToDisplaySafe.push_back(*it); + else + {// The case of some parts of field have more than one discretization per geo type. + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > subTmp((*it)->splitMultiDiscrPerGeoTypes()); + std::size_t it0Cnt(0); + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > >::iterator it0=subTmp.begin();it0!=subTmp.end();it0++,it0Cnt++)//not const because setName + { + std::ostringstream oss; oss << (*it0)->getName() << "_" << std::setfill('M') << std::setw(3) << it0Cnt; + (*it0)->setName(oss.str()); + allFMTSLeavesToDisplaySafe.push_back(*it0); + } + } + } + // end EDF 8655 } } std::vector< MEDFileAnyTypeFieldMultiTS *> allFMTSLeavesToDisplay(allFMTSLeavesToDisplaySafe.size()); @@ -1176,12 +1205,12 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam this->_data_structure.resize(allFMTSLeavesPerTimeSeriesSafe.size()); for(std::size_t i=0;i meshNamesLoc; + std::vector< std::string > meshNamesLoc; std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > splitByMeshName; for(std::size_t j=0;jgetMeshName()); - vtksys_stl::vector< vtksys_stl::string >::iterator it(std::find(meshNamesLoc.begin(),meshNamesLoc.end(),meshName)); + std::vector< std::string >::iterator it(std::find(meshNamesLoc.begin(),meshNamesLoc.end(),meshName)); if(it==meshNamesLoc.end()) { meshNamesLoc.push_back(meshName); @@ -1368,8 +1397,20 @@ void MEDFileFieldRepresentationTree::printMySelf(std::ostream& os) const os << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; } +std::map MEDFileFieldRepresentationTree::dumpState() const +{ + std::map ret; + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + (*it2).dumpState(ret); + return ret; +} + void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms, ParaMEDMEM::MEDFileFields *ret) { + if(!ret) + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationTree::AppendFieldFromMeshes : internal error ! NULL ret !"); for(int i=0;igetNumberOfMeshes();i++) { MEDFileMesh *mm(ms->getMeshAtPos(i)); @@ -1377,53 +1418,53 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MED ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f1tsMultiLev(ParaMEDMEM::MEDFileField1TS::New()); MEDFileUMesh *mmu(dynamic_cast(mm)); if(mmu) - { - for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) - { - std::vector gts(mmu->getGeoTypesAtLevel(*it)); - for(std::vector::const_iterator gt=gts.begin();gt!=gts.end();gt++) - { - ParaMEDMEM::MEDCouplingMesh *m(mmu->getDirectUndergroundSingleGeoTypeMesh(*gt)); - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS)); - f->setMesh(m); - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); - arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); - arr->iota(); - f->setArray(arr); - f->setName(mm->getName()); - f1tsMultiLev->setFieldNoProfileSBT(f); - } - } - if(levs.empty()) - { - std::vector levsExt(mm->getNonEmptyLevelsExt()); - if(levsExt.size()==levs.size()+1) - { - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr m(mm->getGenMeshAtLevel(1)); - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES)); - f->setMesh(m); - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes()); - arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); - arr->iota(); f->setArray(arr); - f->setName(mm->getName()); - f1tsMultiLev->setFieldNoProfileSBT(f); - } - else - continue; - } - } + { + for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) + { + std::vector gts(mmu->getGeoTypesAtLevel(*it)); + for(std::vector::const_iterator gt=gts.begin();gt!=gts.end();gt++) + { + ParaMEDMEM::MEDCouplingMesh *m(mmu->getDirectUndergroundSingleGeoTypeMesh(*gt)); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS)); + f->setMesh(m); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); + arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); + arr->iota(); + f->setArray(arr); + f->setName(BuildAUniqueArrayNameForMesh(mm->getName(),ret)); + f1tsMultiLev->setFieldNoProfileSBT(f); + } + } + if(levs.empty()) + { + std::vector levsExt(mm->getNonEmptyLevelsExt()); + if(levsExt.size()==levs.size()+1) + { + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr m(mm->getMeshAtLevel(1)); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES)); + f->setMesh(m); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes()); + arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); + arr->iota(); f->setArray(arr); + f->setName(BuildAUniqueArrayNameForMesh(mm->getName(),ret)); + f1tsMultiLev->setFieldNoProfileSBT(f); + } + else + continue; + } + } else - { - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr m(mm->getGenMeshAtLevel(0)); - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS)); - f->setMesh(m); - ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); - arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); - arr->iota(); - f->setArray(arr); - f->setName(mm->getName()); - f1tsMultiLev->setFieldNoProfileSBT(f); - } + { + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr m(mm->getMeshAtLevel(0)); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS)); + f->setMesh(m); + ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); + arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); + arr->iota(); + f->setArray(arr); + f->setName(BuildAUniqueArrayNameForMesh(mm->getName(),ret)); + f1tsMultiLev->setFieldNoProfileSBT(f); + } // ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr fmtsMultiLev(ParaMEDMEM::MEDFileFieldMultiTS::New()); fmtsMultiLev->pushBackTimeStep(f1tsMultiLev); @@ -1431,6 +1472,20 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MED } } +std::string MEDFileFieldRepresentationTree::BuildAUniqueArrayNameForMesh(const std::string& meshName, const ParaMEDMEM::MEDFileFields *ret) +{ + const char KEY_STR_TO_AVOID_COLLIDE[]="MESH@"; + if(!ret) + throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationTree::BuildAUniqueArrayNameForMesh : internal error ! NULL ret !"); + std::vector fieldNamesAlreadyExisting(ret->getFieldsNames()); + if(std::find(fieldNamesAlreadyExisting.begin(),fieldNamesAlreadyExisting.end(),meshName)==fieldNamesAlreadyExisting.end()) + return meshName; + std::string tmpName(KEY_STR_TO_AVOID_COLLIDE); tmpName+=meshName; + while(std::find(fieldNamesAlreadyExisting.begin(),fieldNamesAlreadyExisting.end(),tmpName)!=fieldNamesAlreadyExisting.end()) + tmpName=std::string(KEY_STR_TO_AVOID_COLLIDE)+tmpName; + return tmpName; +} + ParaMEDMEM::MEDFileFields *MEDFileFieldRepresentationTree::BuildFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms) { ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr ret(ParaMEDMEM::MEDFileFields::New()); @@ -1479,7 +1534,7 @@ std::vector MEDFileFieldRepresentationTree::SplitFieldNameIntoParts */ std::string MEDFileFieldRepresentationTree::PostProcessFieldName(const std::string& fullFieldName) { - static const char SEP('_'); + const char SEP('_'); std::vector v(SplitFieldNameIntoParts(fullFieldName,SEP)); if(v.empty()) return fullFieldName;//should never happen