X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FMEDReader%2FIO%2FMEDFileFieldRepresentationTree.cxx;h=d87827ac17478b2e3e508c24d7c5623c31aed991;hb=4ab5dda497ba014354de12bc85562e314c73c62c;hp=f905bfda4078ba6c5929b36014fc9ebfad678ef4;hpb=a5ac0fba964d2184d46ea330bc2de0b0e141093a;p=modules%2Fparavis.git diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index f905bfda..d87827ac 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -77,7 +77,7 @@ const char MEDFileFieldRepresentationTree::ROOT_OF_FAM_IDS_IN_TREE[]="zeFamIds"; const char MEDFileFieldRepresentationTree::COMPO_STR_TO_LOCATE_MESH_DA[]="-@?|*_"; -vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew) const +vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew, ExportedTinyInfo *internalInfo) const { vtkIdTypeArray *try0(isExisting(locsReallyUsed,vtkd)); if(try0) @@ -88,7 +88,7 @@ vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal * else { isNew=true; - return createNew(globs,locsReallyUsed,vtkd,ds); + return createNew(globs,locsReallyUsed,vtkd,ds,internalInfo); } } @@ -108,7 +108,7 @@ vtkIdTypeArray *ELGACmp::isExisting(const std::vector& locsReallyUs return ret; } -vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const +vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const { const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; std::vector< std::vector > locNames(_loc_names); @@ -128,11 +128,14 @@ vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *glo vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New()); const MEDFileFieldLoc& loc(globs->getLocalization((*it).c_str())); INTERP_KERNEL::NormalizedCellType ct(loc.getGeoType()); + unsigned char vtkType(MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[ct]); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(ct)); int nbGaussPt(loc.getNbOfGaussPtPerCell()),nbPtsPerCell((int)cm.getNumberOfNodes()),dimLoc(loc.getDimension()); // WARNING : these 2 lines are a workaround, due to users that write a ref element with dimension not equal to dimension of the geometric element. std::vector gsCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getGaussCoords())); std::vector refCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getRefCoords())); + if(internalInfo) + internalInfo->pushGaussAdditionnalInfo(vtkType,dimLoc,refCoods2,gsCoods2); double *shape(new double[nbPtsPerCell*nbGaussPt]); INTERP_KERNEL::GaussInfo calculator(ct,gsCoods2,nbGaussPt,refCoods2,nbPtsPerCell); calculator.initLocalInfo(); @@ -148,7 +151,6 @@ vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *glo shape[nbPtsPerCell*i+j]=pt0[MEDMeshMultiLev::HEXA27_PERM_ARRAY[j]]; } } - unsigned char vtkType(MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[ct]); m[vtkType]=nbGaussPt; def->Initialize(vtkType,nbPtsPerCell,nbGaussPt,shape,const_cast(&wgths[0])); delete [] shape; @@ -317,7 +319,7 @@ bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const return ret; } -void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds) const +void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const { const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; tr->setNumberOfTS((operator->())->getNumberOfTS()); @@ -384,7 +386,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, if(discs[0]==ON_GAUSS_PT) { bool tmp; - _elga_cmp.findOrCreate(globs,f1ts->getLocsReallyUsed(),vtkd,ds,tmp); + _elga_cmp.findOrCreate(globs,f1ts->getLocsReallyUsed(),vtkd,ds,tmp,internalInfo); } if(discs[0]==ON_GAUSS_NE) { @@ -421,7 +423,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New()); double *shape(new double[nbGaussPt*nbGaussPt]); std::size_t dummy; - const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(ct,dummy)); + const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy));//GetLocsFromGeometricType const double *refCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy)); const double *weights(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(ct,dummy)); std::vector gsCoords2(gsCoords,gsCoords+nbGaussPt*dim),refCoords2(refCoords,refCoords+nbGaussPt*dim); @@ -648,7 +650,7 @@ std::string MEDFileFieldRepresentationLeaves::getHumanReadableOverviewOfTS() con return oss.str(); } -void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshes *meshes, vtkDataSet *ds) const +void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshes *meshes, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const { if(_arrays.size()<1) throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeaves::appendFields : internal error !"); @@ -656,7 +658,7 @@ void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) if((*it).getStatus()) { - (*it).appendFields(tr,globs,mml,mst,ds); + (*it).appendFields(tr,globs,mml,mst,ds,internalInfo); (*it).appendELGAIfAny(ds); } } @@ -787,7 +789,7 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter return ret; } -vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes) const +vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes, ExportedTinyInfo *internalInfo) const { vtkDataSet *ret(0); //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs); @@ -823,7 +825,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio ret->ShallowCopy(_cached_ds); } // - appendFields(tr,globs,mml,meshes,ret); + appendFields(tr,globs,mml,meshes,ret,internalInfo); // The arrays links to mesh DataArrayInt *famCells(0),*numCells(0); bool noCpyFamCells(false),noCpyNumCells(false); @@ -995,6 +997,13 @@ void MEDFileFieldRepresentationTree::feedSIL(vtkMutableDirectedGraph* sil, vtkId } } +std::string MEDFileFieldRepresentationTree::getActiveMeshName() const +{ + int dummy0(0),dummy1(0),dummy2(0); + const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(dummy0,dummy1,dummy2)); + return leaf.getMeshName(); +} + std::string MEDFileFieldRepresentationTree::feedSILForFamsAndGrps(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector& names) const { int dummy0(0),dummy1(0),dummy2(0); @@ -1101,52 +1110,15 @@ int MEDFileFieldRepresentationTree::getMaxNumberOfTimeSteps() const /*! * */ -void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv, int iPart, int nbOfParts) +void MEDFileFieldRepresentationTree::loadInMemory(MEDCoupling::MEDFileFields *fields, MEDCoupling::MEDFileMeshes *meshes) { - if(isMEDOrSauv) - { - if((iPart==-1 && nbOfParts==-1) || (iPart==0 && nbOfParts==1)) - { - _ms=MEDFileMeshes::New(fileName); - _fields=MEDFileFields::New(fileName,false);//false is important to not read the values - } - else - { -#ifdef MEDREADER_USE_MPI - _ms=ParaMEDFileMeshes::New(iPart,nbOfParts,fileName); - int nbMeshes(_ms->getNumberOfMeshes()); - for(int i=0;igetMeshAtPos(i)); - MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); - if(tmp2) - MCAuto 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 !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); -#endif - } - } - else - { - MCAuto sr(MEDCoupling::SauvReader::New(fileName)); - MCAuto mfd(sr->loadInMEDFileDS()); - _ms=mfd->getMeshes(); _ms->incrRef(); - int nbMeshes(_ms->getNumberOfMeshes()); - for(int i=0;igetMeshAtPos(i)); - MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); - if(tmp2) - tmp2->forceComputationOfParts(); - } - _fields=mfd->getFields(); - if((MEDCoupling::MEDFileFields *)_fields) - _fields->incrRef(); - } - if(!((MEDCoupling::MEDFileFields *)_fields)) + _fields=fields; _ms=meshes; + if(_fields.isNotNull()) + _fields->incrRef(); + if(_ms.isNotNull()) + _ms->incrRef(); + // + if(_fields.isNull()) { _fields=BuildFieldFromMeshes(_ms); } @@ -1256,6 +1228,71 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam this->computeFullNameInLeaves(); } +void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv, int iPart, int nbOfParts) +{ + MCAuto ms; + MCAuto fields; + if(isMEDOrSauv) + { + if((iPart==-1 && nbOfParts==-1) || (iPart==0 && nbOfParts==1)) + { + MCAuto msups(MEDFileMeshSupports::New(fileName)); + MCAuto mse(MEDFileStructureElements::New(fileName,msups)); + ms=MEDFileMeshes::New(fileName); + fields=MEDFileFields::NewWithDynGT(fileName,mse,false);//false is important to not read the values + if(ms->presenceOfStructureElements()) + {// pre traitement + fields->loadArrays(); + fields->blowUpSE(ms,mse); + } + int nbMeshes(ms->getNumberOfMeshes()); + for(int i=0;igetMeshAtPos(i)); + MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); + if(tmp2) + tmp2->forceComputationOfParts(); + } + } + else + { +#ifdef MEDREADER_USE_MPI + ms=ParaMEDFileMeshes::New(iPart,nbOfParts,fileName); + int nbMeshes(ms->getNumberOfMeshes()); + for(int i=0;igetMeshAtPos(i)); + MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); + if(tmp2) + MCAuto 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 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +#endif + } + } + else + { + MCAuto sr(MEDCoupling::SauvReader::New(fileName)); + MCAuto mfd(sr->loadInMEDFileDS()); + ms=mfd->getMeshes(); ms->incrRef(); + int nbMeshes(ms->getNumberOfMeshes()); + for(int i=0;igetMeshAtPos(i)); + MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); + if(tmp2) + tmp2->forceComputationOfParts(); + } + fields=mfd->getFields(); + if(fields.isNotNull()) + fields->incrRef(); + } + loadInMemory(fields,ms); +} + void MEDFileFieldRepresentationTree::removeEmptyLeaves() { std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > > newSD; @@ -1295,7 +1332,7 @@ std::vector MEDFileFieldRepresentationTree::getTimeSteps(int& lev0, cons return leaf.getTimeSteps(tk); } -vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk) const +vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk, ExportedTinyInfo *internalInfo) const { int lev0,lev1,lev2; const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(lev0,lev1,lev2)); @@ -1351,7 +1388,7 @@ vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, d tr=new MEDStdTimeReq((int)zeTimeId); else tr=new MEDModeTimeReq(tk.getTheVectOfBool(),tk.getPostProcessedTime()); - vtkDataSet *ret(leaf.buildVTKInstanceNoTimeInterpolation(tr,_fields,_ms)); + vtkDataSet *ret(leaf.buildVTKInstanceNoTimeInterpolation(tr,_fields,_ms,internalInfo)); delete tr; return ret; }