X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileField.cxx;h=3cb2da239d9b8fb74d964460d76b5813812da5ed;hb=0b187729ac99d3e9e9bb9d2be8cb8600a783be6c;hp=31812cb580399c189896548076994926718debba;hpb=aa60c5c907c78293330a22ecee21476f72a9ec34;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 31812cb58..3cb2da239 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -22,6 +22,7 @@ #include "MEDFileMesh.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileUtilities.hxx" +#include "MEDFileSafeCaller.txx" #include "MEDFileFieldOverView.hxx" #include "MEDCouplingFieldDouble.hxx" @@ -38,7 +39,7 @@ extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO]; extern med_geometry_type typmainoeud[1]; extern med_geometry_type typmai3[34]; -using namespace ParaMEDMEM; +using namespace MEDCoupling; const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64"; const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32"; @@ -114,7 +115,7 @@ std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity(); } -std::vector MEDFileFieldLoc::getDirectChildren() const +std::vector MEDFileFieldLoc::getDirectChildrenWithNull() const { return std::vector(); } @@ -280,13 +281,19 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int off * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points. * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored. */ -void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { _profile.clear(); _type=field->getTypeOfField(); std::string pflName(multiTypePfl->getName()); std::ostringstream oss; oss << pflName; - if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; } + if(_type!=ON_NODES) + { + if(!isPflAlone) + { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } + } + else + { oss << "_NODE"; } if(locIds) { if(pflName.empty()) @@ -365,7 +372,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const Dat } else { - if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity()) + if(!da3->isIdentity2(nbOfEltsInWholeMesh)) { da3->setName(oss.str().c_str()); glob.appendProfile(da3); @@ -392,9 +399,9 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, con start=_end; } -MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) +MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd) { - return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt); + return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd); } MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId) @@ -409,12 +416,14 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const { - return _profile.capacity()+_localization.capacity()+5*sizeof(int); + return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc); } -std::vector MEDFileFieldPerMeshPerTypePerDisc::getDirectChildren() const +std::vector MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const { - return std::vector(); + std::vector ret(1); + ret[0]=(const PartDefinition*)_pd; + return ret; } MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const @@ -424,9 +433,11 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(ME return ret.retn(); } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) -try:_type(atype),_father(fath),_profile_it(profileIt) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd) +try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast(pd)) { + if(pd) + pd->incrRef(); } catch(INTERP_KERNEL::Exception& e) { @@ -437,7 +448,7 @@ MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFiel { } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1) { } @@ -446,6 +457,71 @@ MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_ { } +void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr) +{ + const PartDefinition *pd(_pd); + if(!pd) + { + INTERP_KERNEL::AutoPtr locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + int nbi,tmp1; + med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi)); + if(_end-_start!=nbValsInFile*nbi) + { + std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr)); + } + else + { + if(!_profile.empty()) + throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !"); + INTERP_KERNEL::AutoPtr pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + int profilesize,nbi; + int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); + const SlicePartDefinition *spd(dynamic_cast(pd)); + if(spd) + { + int start,stop,step; + spd->getSlice(start,stop,step); + int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile")); + med_filter filter=MED_FILTER_INIT; + MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo, + MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE, + /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad, + /*lastblocksize=useless because count=1*/0,&filter); + MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr)); + MEDfilterClose(&filter); + return ; + } + const DataArrayPartDefinition *dpd(dynamic_cast(pd)); + if(dpd) + { + dpd->checkCoherency(); + MEDCouplingAutoRefCountObjectPtr myIds(dpd->toDAI()); + int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray()); + myIds->applyLin(1,-a); + int nbOfEltsToLoad(b-a+1); + med_filter filter=MED_FILTER_INIT; + {//TODO : manage int32 ! + MEDCouplingAutoRefCountObjectPtr tmp(DataArrayDouble::New()); + tmp->alloc(nbOfEltsToLoad,nbOfCompo); + MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo, + MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE, + /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad, + /*lastblocksize=useless because count=1*/0,&filter); + MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast(tmp->getPointer()))); + MEDCouplingAutoRefCountObjectPtr feeder(DataArrayDouble::New()); + feeder->useExternalArrayWithRWAccess(reinterpret_cast(startFeedingPtr),_nval,nbOfCompo); + feeder->setContigPartOfSelectedValues(0,tmp,myIds); + } + MEDfilterClose(&filter); + } + else + throw INTERP_KERNEL::Exception("Not implemented yet for not slices!"); + } +} + const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const { return _father; @@ -453,21 +529,29 @@ const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) { - INTERP_KERNEL::AutoPtr locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - INTERP_KERNEL::AutoPtr pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - std::string fieldName=nasc.getName(); - std::string meshName=getMeshName(); - int iteration=getIteration(); - int order=getOrder(); - TypeOfField type=getType(); - INTERP_KERNEL::NormalizedCellType geoType=getGeoType(); + INTERP_KERNEL::AutoPtr locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + std::string fieldName(nasc.getName()),meshName(getMeshName()); + int iteration(getIteration()),order(getOrder()); + TypeOfField type(getType()); + INTERP_KERNEL::NormalizedCellType geoType(getGeoType()); int profilesize,nbi; med_geometry_type mgeoti; - med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti); - _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it,MED_COMPACT_PFLMODE, - pflname,&profilesize,locname,&nbi); + med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti)); + int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE); _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE); + const PartDefinition *pd(_pd); + if(!pd) + { + _nval=zeNVal; + } + else + { + if(!_profile.empty()) + throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !"); + _nval=pd->getNumberOfElems(); + } _start=start; _end=start+_nval*nbi; start=_end; @@ -485,19 +569,17 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_i void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc) { - std::string fieldName=nasc.getName(); - std::string meshName=getMeshName(); - int iteration=getIteration(); - int order=getOrder(); - TypeOfField type=getType(); - INTERP_KERNEL::NormalizedCellType geoType=getGeoType(); + std::string fieldName(nasc.getName()),meshName(getMeshName()); + int iteration(getIteration()),order(getOrder()); + TypeOfField type(getType()); + INTERP_KERNEL::NormalizedCellType geoType(getGeoType()); med_geometry_type mgeoti; - med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti); + med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti)); if(_start>_end) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !"); if(_start==_end) return ; - DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray + DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray if(_start<0 || _start>=arr->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !"; @@ -508,29 +590,19 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileF std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - med_int tmp1,nbi; - INTERP_KERNEL::AutoPtr locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi); - int nbOfCompo=arr->getNumberOfComponents(); - if(_end-_start!=nbValsInFile*nbi) - { - std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - DataArrayDouble *arrD=dynamic_cast(arr); + int nbOfCompo(arr->getNumberOfComponents()); + DataArrayDouble *arrD(dynamic_cast(arr)); if(arrD) { - double *startFeeding=arrD->getPointer()+_start*nbOfCompo; - MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE, - _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast(startFeeding)); + double *startFeeding(arrD->getPointer()+_start*nbOfCompo); + goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast(startFeeding)); return ; } - DataArrayInt *arrI=dynamic_cast(arr); + DataArrayInt *arrI(dynamic_cast(arr)); if(arrI) { - int *startFeeding=arrI->getPointer()+_start*nbOfCompo; - MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE, - _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast(startFeeding)); + int *startFeeding(arrI->getPointer()+_start*nbOfCompo); + goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast(startFeeding)); return ; } throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !"); @@ -714,9 +786,9 @@ void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldN locToWrite=reinterpret_cast(arrI->getConstPointer()+_start*arr->getNumberOfComponents()); else throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !"); - MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti, - MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval, - locToWrite); + MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti, + MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval, + locToWrite)); } void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair& dad, std::string& pfl, std::string& loc) const @@ -887,7 +959,7 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::ve int nbEntityElts=subIds->getNumberOfTuples(); bool ret2; MEDCouplingAutoRefCountObjectPtr eltToAdd=MEDFileFieldPerMeshPerTypePerDisc:: - NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi, + NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity2(newCode[3*(*idIt)+1]),nbi, offset+offset2, li,glob,ret2); ret=ret || ret2; @@ -968,9 +1040,9 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectO } -MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) +MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd) { - return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc); + return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd); } MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) @@ -983,15 +1055,11 @@ std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); } -std::vector MEDFileFieldPerMeshPerType::getDirectChildren() const +std::vector MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const { std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - { - const MEDFileFieldPerMeshPerTypePerDisc *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it); return ret; } @@ -1024,11 +1092,11 @@ void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, in * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored. */ -void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { std::vector pos=addNewEntryIfNecessary(field,idsInPfl); for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) - _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc); + _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc); } void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) @@ -1045,7 +1113,7 @@ void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataAr throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !"); _field_pm_pt_pd.resize(1); _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3); - _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send. + _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send. } std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) @@ -1289,6 +1357,18 @@ int MEDFileFieldPerMeshPerType::getNumberOfComponents() const return _father->getNumberOfComponents(); } +bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const +{ + std::size_t nb(0); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) + { + const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it); + if(fmtd) + nb++; + } + return nb>1; +} + DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() { return _father->getOrCreateAndGetArray(); @@ -1445,7 +1525,7 @@ void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRef */ bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its) { - bool ret=false; + bool ret(false); std::vector< MEDCouplingAutoRefCountObjectPtr > newPmPtPd; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) if((*it)->getType()==tof) @@ -1462,28 +1542,46 @@ bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, return ret; } +/*! + * \param [in,out] globalNum a global numbering counter for the renumbering. + * \param [out] its - list of pair (start,stop) kept + * \return bool - false if the type of field \a tof is not contained in \a this. + */ +bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its) +{ + if(_field_pm_pt_pd.size()<=idOfDisc) + return false; + MEDCouplingAutoRefCountObjectPtr elt(_field_pm_pt_pd[idOfDisc]); + std::vector< MEDCouplingAutoRefCountObjectPtr > newPmPtPd(1,elt); + std::pair bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd(); + elt->setNewStart(globalNum); + globalNum=elt->getEnd(); + its.push_back(bgEnd); + _field_pm_pt_pd=newPmPtPd; + return true; +} + MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType) { } -MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc):_father(fath),_geo_type(geoType) +MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType) { INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_geometry_type mgeoti; - med_entity_type menti; - menti=ConvertIntoMEDFileType(type,geoType,mgeoti); - int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName); + med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti)); + int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName)); _field_pm_pt_pd.resize(nbProfiles); for(int i=0;i > *entities) { - return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc); + return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities); } MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh) @@ -1545,15 +1643,11 @@ std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >); } -std::vector MEDFileFieldPerMesh::getDirectChildren() const +std::vector MEDFileFieldPerMesh::getDirectChildrenWithNull() const { std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - { - const MEDFileFieldPerMeshPerType *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const MEDFileFieldPerMeshPerType *)*it); return ret; } @@ -1619,7 +1713,7 @@ void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vec */ void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - int nbOfTypes=code.size()/3; + int nbOfTypes(code.size()/3); for(int i=0;iassignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc); + _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc); } } @@ -1718,6 +1812,19 @@ int MEDFileFieldPerMesh::getNumberOfComponents() const return _father->getNumberOfComponents(); } +bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + { + const MEDFileFieldPerMeshPerType *fpmt(*it); + if(!fpmt) + continue; + if(fpmt->presenceOfMultiDiscPerGeoType()) + return true; + } + return false; +} + DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() { if(!_father) @@ -2005,6 +2112,25 @@ void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &gl _field_pm_pt=ret; } +/*! + * \param [in,out] globalNum a global numbering counter for the renumbering. + * \param [out] its - list of pair (start,stop) kept + */ +void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its) +{ + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + { + std::vector< std::pair > its2; + if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2)) + { + ret.push_back(*it); + its.insert(its.end(),its2.begin(),its2.end()); + } + } + _field_pm_pt=ret; +} + void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) { std::map > > types; @@ -2259,12 +2385,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, cons const std::vector& geoTypes, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr& arrOut, const MEDFileFieldNameScope& nasc) const { - if(da->isIdentity()) - { - int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==mesh->getNumberOfCells()) - return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc); - } + if(da->isIdentity2(mesh->getNumberOfCells())) + return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc); MEDCouplingAutoRefCountObjectPtr m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); m2->setName(mesh->getName().c_str()); MEDCouplingAutoRefCountObjectPtr ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc); @@ -2279,12 +2401,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField const std::vector >& dads, const std::vector& locs, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr& arrOut, const MEDFileFieldNameScope& nasc) const { - if(da->isIdentity()) - { - int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node - return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc); - } + if(da->isIdentity2(mesh->getNumberOfNodes())) + return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc); // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1. const MEDCouplingUMesh *meshu=dynamic_cast(mesh); if(meshu) @@ -2361,32 +2479,128 @@ DataArray *MEDFileFieldPerMesh::finishField4(const std::vector meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - INTERP_KERNEL::AutoPtr locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - for(int i=0;i > *entities); + static bool IsPresenceOfNode(const std::vector< std::pair > *entities); + virtual ~MFFPMIter() { } + virtual void begin() = 0; + virtual bool finished() const = 0; + virtual void next() = 0; + virtual int current() const = 0; +}; + +class MFFPMIterSimple : public MFFPMIter +{ +public: + MFFPMIterSimple():_pos(0) { } + void begin() { _pos=0; } + bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; } + void next() { _pos++; } + int current() const { return _pos; } +private: + int _pos; +}; + +class MFFPMIter2 : public MFFPMIter +{ +public: + MFFPMIter2(const std::vector& cts); + void begin() { _it=_ids.begin(); } + bool finished() const { return _it==_ids.end(); } + void next() { _it++; } + int current() const { return *_it; } +private: + std::vector _ids; + std::vector::const_iterator _it; +}; + +MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair > *entities) +{ + if(!entities) + return new MFFPMIterSimple; + else + { + std::vector tmp; + for(std::vector< std::pair >::const_iterator it=(*entities).begin();it!=(*entities).end();it++) + { + if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT) + tmp.push_back((*it).second); + } + return new MFFPMIter2(tmp); + } +} + +bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair > *entities) +{ + if(!entities) + return true; + else + { + for(std::vector< std::pair >::const_iterator it=(*entities).begin();it!=(*entities).end();it++) + if((*it).first==ON_NODES) + return true; + return false; + } +} + +MFFPMIter2::MFFPMIter2(const std::vector& cts) +{ + std::size_t sz(cts.size()); + _ids.resize(sz); + for(std::size_t i=0;i > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder), + _father(fath) +{ + INTERP_KERNEL::AutoPtr meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + const MEDFileUMesh *mmu(dynamic_cast(mm)); + INTERP_KERNEL::AutoCppPtr iter0(MFFPMIter::NewCell(entities)); + for(iter0->begin();!iter0->finished();iter0->next()) + { + int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); - int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName); + int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); if(nbProfile>0 || nbProfile2>0) { - _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc)); + const PartDefinition *pd(0); + if(mmu) + pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]); + _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd)); if(nbProfile>0) _mesh_name=name0; else _mesh_name=name1; } } - int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName); - if(nbProfile>0) + if(MFFPMIter::IsPresenceOfNode(entities)) { - _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc)); - _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1); + int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName)); + if(nbProfile>0) + { + const PartDefinition *pd(0); + if(mmu) + pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR); + _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd)); + _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1); + } } } @@ -2400,10 +2614,10 @@ void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string if(id>=(int)_pfls.size()) _pfls.resize(id+1); _pfls[id]=DataArrayInt::New(); - int lgth=MEDprofileSizeByName(fid,pflName.c_str()); + int lgth(MEDprofileSizeByName(fid,pflName.c_str())); _pfls[id]->setName(pflName); _pfls[id]->alloc(lgth,1); - MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer()); + MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer())); _pfls[id]->applyLin(1,-1,0);//Converting into C format } @@ -2411,14 +2625,14 @@ void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i) { INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); int sz; - MEDprofileInfo(fid,i+1,pflName,&sz); + MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz)); std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE); if(i>=(int)_pfls.size()) _pfls.resize(i+1); _pfls[i]=DataArrayInt::New(); _pfls[i]->alloc(sz,1); _pfls[i]->setName(pflCpp.c_str()); - MEDprofileRd(fid,pflName,_pfls[i]->getPointer()); + MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer())); _pfls[i]->applyLin(1,-1,0);//Converting into C format } @@ -2431,7 +2645,7 @@ void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) co cpy->applyLin(1,1,0); INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy()); - MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()); + MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer())); } // int nbOfLocs=_locs.size(); @@ -2534,21 +2748,13 @@ std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); } -std::vector MEDFileFieldGlobs::getDirectChildren() const +std::vector MEDFileFieldGlobs::getDirectChildrenWithNull() const { std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++) - { - const DataArrayInt *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const DataArrayInt *)*it); for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_locs.begin();it!=_locs.end();it++) - { - const MEDFileFieldLoc *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const MEDFileFieldLoc *)*it); return ret; } @@ -2728,7 +2934,8 @@ const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const return *_locs[locId]; } -namespace ParaMEDMEMImpl +/// @cond INTERNAL +namespace MEDCouplingImpl { class LocFinder { @@ -2748,10 +2955,11 @@ namespace ParaMEDMEMImpl const std::string& _pfl; }; } +/// @endcond int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const { - std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc)); + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc)); if(it==_locs.end()) { std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : "; @@ -2768,7 +2976,7 @@ int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const { std::string pflNameCpp(pflName); - std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp)); + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp)); if(it==_pfls.end()) { std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : "; @@ -2804,7 +3012,7 @@ MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) { std::string pflNameCpp(pflName); - std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp)); + std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp)); if(it==_pfls.end()) { std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : "; @@ -3003,11 +3211,10 @@ std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const return 0; } -std::vector MEDFileFieldGlobsReal::getDirectChildren() const +std::vector MEDFileFieldGlobsReal::getDirectChildrenWithNull() const { std::vector ret; - if((const MEDFileFieldGlobs *)_globals) - ret.push_back((const MEDFileFieldGlobs *)_globals); + ret.push_back((const MEDFileFieldGlobs *)_globals); return ret; } @@ -3904,7 +4111,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector * Thus all sequences returned by this method are of the same length equal to number * of different types of supporting entities.
* A field part can include sub-parts with several different spatial discretizations, - * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" + * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" * for example. Hence, some of the returned sequences contains nested sequences, and an item * of a nested sequence corresponds to a type of spatial discretization.
* This method allows for iteration over MEDFile DataStructure without any overhead. @@ -3943,11 +4150,11 @@ std::vector< std::vector< std::pair > > MEDFileAnyTypeField1TSWithoutSD * maximal absolute dimension and values returned via the out parameter \a levs are * dimensions relative to the maximal absolute dimension.
* This method is designed for MEDFileField1TS instances that have a discretization - * \ref ParaMEDMEM::ON_CELLS "ON_CELLS", - * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT", - * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE". + * \ref MEDCoupling::ON_CELLS "ON_CELLS", + * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", + * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE". * Only these 3 discretizations will be taken into account here. If \a this is - * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.
+ * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.
* This method is useful to make the link between the dimension of the underlying mesh * and the levels of \a this, because it is possible that the highest dimension of \a this * field is not equal to the dimension of the underlying mesh. @@ -4086,12 +4293,18 @@ bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::st return ret; } +/*! + * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal + * splitting that leads to single spatial discretization of this. + * + * \sa splitMultiDiscrPerGeoTypes + */ std::vector< MEDCouplingAutoRefCountObjectPtr > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const { std::vector types; std::vector< std::vector > typesF; std::vector< std::vector > pfls,locs; - std::vector< std::vector > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs); + std::vector< std::vector > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs)); std::set allEnt; for(std::vector< std::vector >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++) for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) @@ -4102,7 +4315,48 @@ std::vector< MEDCouplingAutoRefCountObjectPtr { std::vector< std::pair > its; ret[i]=shallowCpy(); - int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its); + int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its)); + ret[i]->updateData(newLgth,its); + } + return ret; +} + +/*! + * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done. + * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type. + * + * \sa splitDiscretizations + */ +std::vector< MEDCouplingAutoRefCountObjectPtr > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const +{ + std::vector types; + std::vector< std::vector > typesF; + std::vector< std::vector > pfls,locs; + std::vector< std::vector > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs)); + std::set allEnt; + std::size_t nbOfMDPGT(0),ii(0); + for(std::vector< std::vector >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++) + { + nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size()); + for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + allEnt.insert(*it2); + } + if(allEnt.size()!=1) + throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !"); + if(nbOfMDPGT==0) + throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !"); + if(nbOfMDPGT==1) + { + std::vector< MEDCouplingAutoRefCountObjectPtr > ret0(1); + ret0[0]=const_cast(this); this->incrRef(); + return ret0; + } + std::vector< MEDCouplingAutoRefCountObjectPtr > ret(nbOfMDPGT); + for(std::size_t i=0;i > its; + ret[i]=shallowCpy(); + int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its)); ret[i]->updateData(newLgth,its); } return ret; @@ -4110,12 +4364,20 @@ std::vector< MEDCouplingAutoRefCountObjectPtr int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair >& its) { - int globalCounter=0; + int globalCounter(0); for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its); return globalCounter; } +int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair >& its) +{ + int globalCounter(0); + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its); + return globalCounter; +} + void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair >& oldStartStops) { if(_nb_of_tuples_to_be_allocated>=0) @@ -4187,7 +4449,7 @@ bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFrom throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !"); } -void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) +void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { med_int numdt,numit; med_float dt; @@ -4195,13 +4457,21 @@ void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_id med_bool localMesh; med_int meshnumdt,meshnumit; INTERP_KERNEL::AutoPtr meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt); - MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit); + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt)); + MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); if(_iteration!=numdt || _order!=numit) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !"); _field_per_mesh.resize(nmesh); + // + MEDFileMesh *mm(0); + if(ms) + { + std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + mm=ms->getMeshWithName(meshNameCpp); + } + // for(int i=0;iloadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc); @@ -4221,9 +4491,9 @@ void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_i (*it)->loadBigArraysRecursively(fid,nasc); } -void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) +void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { - loadOnlyStructureOfDataRecursively(fid,nasc); + loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities); loadBigArraysRecursively(fid,nasc); } @@ -4242,17 +4512,13 @@ std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >); } -std::vector MEDFileAnyTypeField1TSWithoutSDA::getDirectChildren() const +std::vector MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const { std::vector ret; if(getUndergroundDataArray()) ret.push_back(getUndergroundDataArray()); for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - { - const MEDFileFieldPerMesh *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const MEDFileFieldPerMesh *)*it); return ret; } @@ -4321,7 +4587,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDou std::vector idsInPflPerType; std::vector idsPerType; std::vector code,code2; - MEDCouplingAutoRefCountObjectPtr m=mesh->getGenMeshAtLevel(meshDimRelToMax); + MEDCouplingAutoRefCountObjectPtr m(mesh->getMeshAtLevel(meshDimRelToMax)); if(type!=ON_NODES) { m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType); @@ -4456,6 +4722,19 @@ std::vector& MEDFileAnyTypeField1TSWithoutSDA::getInfo() return arr->getInfoOnComponents(); } +bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + { + const MEDFileFieldPerMesh *fpm(*it); + if(!fpm) + continue; + if(fpm->presenceOfMultiDiscPerGeoType()) + return true; + } + return false; +} + /*! * Returns a new MEDCouplingFieldDouble of given type lying on a given support. * \param [in] type - a spatial discretization of the new field. @@ -4509,7 +4788,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOf */ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr& arrOut, const MEDFileFieldNameScope& nasc) const { - MEDCouplingAutoRefCountObjectPtr m=mesh->getGenMeshAtLevel(meshDimRelToMax,false); + MEDCouplingAutoRefCountObjectPtr m(mesh->getMeshAtLevel(meshDimRelToMax,false)); const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax); const DataArrayInt *e=mesh->getNumberFieldAtLevel(1); if(meshDimRelToMax==1) @@ -4651,7 +4930,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel( */ DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const { - MEDCouplingAutoRefCountObjectPtr m=mesh->getGenMeshAtLevel(meshDimRelToMax); + MEDCouplingAutoRefCountObjectPtr m(mesh->getMeshAtLevel(meshDimRelToMax)); int meshId=getMeshIdFromMeshName(mesh->getName().c_str()); MEDCouplingAutoRefCountObjectPtr ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc); ret->setName(nasc.getName().c_str()); @@ -4727,7 +5006,7 @@ MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fie * Thus all sequences returned by this method are of the same length equal to number * of different types of supporting entities.
* A field part can include sub-parts with several different spatial discretizations, - * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" + * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" * for example. Hence, some of the returned sequences contains nested sequences, and an item * of a nested sequence corresponds to a type of spatial discretization.
* This method allows for iteration over MEDFile DataStructure with a reduced overhead. @@ -4739,8 +5018,8 @@ MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fie * a field part is returned. * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations. * A field part can include sub-parts with several different spatial discretizations, - * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and - * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example. + * \ref MEDCoupling::ON_CELLS "ON_CELLS" and + * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example. * This sequence is of the same length as \a types. * \param [in,out] pfls - a sequence returning a profile name per each type of spatial * discretization. A profile name can be empty. @@ -4873,10 +5152,9 @@ DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< st return getUndergroundDataArrayDoubleExt(entries); } -MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, - const std::vector& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order) +MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order) { - DataArrayDouble *arr=getOrCreateAndGetArrayDouble(); + DataArrayDouble *arr(getOrCreateAndGetArrayDouble()); arr->setInfoAndChangeNbOfCompo(infos); } @@ -4952,8 +5230,7 @@ const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const //= MEDFileIntField1TSWithoutSDA -MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, - const std::vector& infos) +MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector& infos) { return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos); } @@ -4965,7 +5242,7 @@ MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order) { - DataArrayInt *arr=getOrCreateAndGetArrayInt(); + DataArrayInt *arr(getOrCreateAndGetArrayInt()); arr->setInfoAndChangeNbOfCompo(infos); } @@ -5135,7 +5412,7 @@ MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS() //= MEDFileAnyTypeField1TS -MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll) +MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) { med_field_type typcha; // @@ -5166,22 +5443,22 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i // med_int numdt,numit; med_float dt; - MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt); + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt)); ret->setTime(numdt,numit,dt); ret->_csit=1; if(loadAll) - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); else - ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) try:MEDFileFieldGlobsReal(fileName) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName,loadAll); + _content=BuildContentFrom(fid,fileName,loadAll,ms); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -5189,7 +5466,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll) +MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) { med_field_type typcha; std::vector infos; @@ -5226,22 +5503,22 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i // med_int numdt,numit; med_float dt; - MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt); + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt)); ret->setTime(numdt,numit,dt); ret->_csit=1; if(loadAll) - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); else - ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) try:MEDFileFieldGlobsReal(fileName) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName,fieldName,loadAll); + _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -5274,7 +5551,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,loadAll); + MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,loadAll,0); MEDCouplingAutoRefCountObjectPtr ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); @@ -5284,7 +5561,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName,loadAll); + MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName,loadAll,0); MEDCouplingAutoRefCountObjectPtr ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); @@ -5294,13 +5571,13 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll); + MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0); MEDCouplingAutoRefCountObjectPtr ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); } -MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) +MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) { med_field_type typcha; std::vector infos; @@ -5335,7 +5612,7 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i { med_int numdt,numit; med_float dt; - MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt); + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt)); if(numdt==iteration && numit==order) { found=true; @@ -5352,18 +5629,18 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i throw INTERP_KERNEL::Exception(oss.str().c_str()); } if(loadAll) - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); else - ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) try:MEDFileFieldGlobsReal(fileName) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll); + _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -5402,7 +5679,7 @@ int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileNam throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1); + int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1)); INTERP_KERNEL::AutoPtr comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); @@ -5410,7 +5687,7 @@ int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileNam INTERP_KERNEL::AutoPtr nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_bool localMesh; int nbOfStep; - MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep)); fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE); dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE); infos.clear(); infos.resize(ncomp); @@ -5631,7 +5908,7 @@ void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const } if(getName().empty()) throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !"); - MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()); + MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str())); writeGlobals(fid,*this); contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase()); } @@ -5641,11 +5918,10 @@ std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren(); } -std::vector MEDFileAnyTypeField1TS::getDirectChildren() const +std::vector MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const { - std::vector ret(MEDFileFieldGlobsReal::getDirectChildren()); - if((const MEDFileAnyTypeField1TSWithoutSDA *)_content) - ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content); + std::vector ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull()); + ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content); return ret; } @@ -5822,6 +6098,11 @@ std::vector& MEDFileAnyTypeField1TS::getInfo() return contentNotNullBase()->getInfo(); } +bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const +{ + return contentNotNullBase()->presenceOfMultiDiscPerGeoType(); +} + MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) { return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId); @@ -5871,14 +6152,34 @@ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFil /*! * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this. - * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this. + * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this. */ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const { const MEDFileAnyTypeField1TSWithoutSDA *content(_content); if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !"); - std::vector< MEDCouplingAutoRefCountObjectPtr > contentsSplit=content->splitDiscretizations(); + std::vector< MEDCouplingAutoRefCountObjectPtr > contentsSplit(content->splitDiscretizations()); + std::size_t sz(contentsSplit.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz); + for(std::size_t i=0;i_content=contentsSplit[i]; + } + return ret; +} + +/*! + * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this. + * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this. + */ +std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const +{ + const MEDFileAnyTypeField1TSWithoutSDA *content(_content); + if(!content) + throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !"); + std::vector< MEDCouplingAutoRefCountObjectPtr > contentsSplit(content->splitMultiDiscrPerGeoTypes()); std::size_t sz(contentsSplit.size()); std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz); for(std::size_t i=0;i ret=new MEDFileField1TS(fileName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileField1TS(fileName,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -5932,7 +6233,7 @@ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll) */ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileField1TS(fileName,fieldName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileField1TS(fileName,fieldName,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -5952,7 +6253,7 @@ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::st */ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll); + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -6062,22 +6363,22 @@ DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRef return arrOutC; } -MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll) -try:MEDFileAnyTypeField1TS(fileName,loadAll) +MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fileName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll) -try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll) +MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) -try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll) +MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) @@ -6360,21 +6661,21 @@ MEDFileIntField1TS *MEDFileIntField1TS::New() MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntField1TS(fileName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileIntField1TS(fileName,loadAll,0)); ret->contentNotNull(); return ret.retn(); } MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntField1TS(fileName,fieldName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0)); ret->contentNotNull(); return ret.retn(); } MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll); + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -6391,22 +6692,22 @@ MEDFileIntField1TS::MEDFileIntField1TS() _content=new MEDFileIntField1TSWithoutSDA; } -MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll) -try:MEDFileAnyTypeField1TS(fileName,loadAll) +MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fileName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll) -try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll) +MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) -try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll) +MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) @@ -6526,6 +6827,7 @@ MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, in if(!arrOutC) throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !"); arrOut=arrOutC; + arrOut->incrRef(); // arrOut2 dies at the end of the func return ret.retn(); } @@ -6720,20 +7022,20 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const /*! * \param [in] fieldId field id in C mode */ -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { med_field_type typcha; std::string dtunitOut; int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut); setDtUnit(dtunitOut.c_str()); - loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll); + loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities); } -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) try:MEDFileFieldNameScope(fieldName),_infos(infos) { setDtUnit(dtunit.c_str()); - loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll); + loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities); } catch(INTERP_KERNEL::Exception& e) { @@ -6748,15 +7050,11 @@ std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildr return ret; } -std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildren() const +std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const { std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - { - const MEDFileAnyTypeField1TSWithoutSDA *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it); return ret; } @@ -6865,6 +7163,19 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::part return buildFromTimeStepIds(ids->begin(),ids->end()); } +bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + { + const MEDFileAnyTypeField1TSWithoutSDA *cur(*it); + if(!cur) + continue; + if(cur->presenceOfMultiDiscPerGeoType()) + return true; + } + return false; +} + const std::vector& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const { return _infos; @@ -7038,7 +7349,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() } } -void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) +void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { _time_steps.resize(nbPdt); for(int i=0;iloadStructureAndBigArraysRecursively(fid,*this); + _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities); else - _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this); + _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities); } } @@ -7089,7 +7400,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWri } if(_name.empty()) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !"); - MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()); + MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str())); int nbOfTS=_time_steps.size(); for(int i=0;iwriteLL(fid,opts,*this); @@ -7469,7 +7780,7 @@ std::vector< MEDCouplingAutoRefCountObjectPtr elt=createNew(); + MEDCouplingAutoRefCountObjectPtr elt(createNew()); for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++) elt->pushBackTimeStep(*it1);//also updates infos in elt ret[i]=elt; @@ -7478,6 +7789,43 @@ std::vector< MEDCouplingAutoRefCountObjectPtr > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const +{ + std::size_t sz(_time_steps.size()); + std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > items(sz); + std::size_t szOut(std::numeric_limits::max()); + for(std::size_t i=0;isplitMultiDiscrPerGeoTypes(); + if(szOut==std::numeric_limits::max()) + szOut=items[i].size(); + else + if(items[i].size()!=szOut) + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !"); + } + if(szOut==std::numeric_limits::max()) + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !"); + std::vector< MEDCouplingAutoRefCountObjectPtr > ret(szOut); + for(std::size_t i=0;i elt(createNew()); + for(std::size_t j=0;jpushBackTimeStep(items[j][i]); + ret[i]=elt; + elt->MEDFileFieldNameScope::operator=(*this); + } + return ret; +} + void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) { _name=field->getName(); @@ -7587,9 +7935,9 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRe //= MEDFileFieldMultiTSWithoutSDA -MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) +MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { - return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll); + return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); } MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA() @@ -7603,15 +7951,15 @@ MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& /*! * \param [in] fieldId field id in C mode */ -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll) +MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll) +MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -7685,12 +8033,12 @@ MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS() { } -MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll) +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) try:MEDFileFieldGlobsReal(fileName) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName,loadAll); + _content=BuildContentFrom(fid,fileName,loadAll,ms); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -7698,7 +8046,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll) +MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { med_field_type typcha; std::vector infos; @@ -7710,12 +8058,12 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr { case MED_FLOAT64: { - ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll); + ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); break; } case MED_INT32: { - ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll); + ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); break; } default: @@ -7728,7 +8076,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr return ret.retn(); } -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll) +MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) { med_field_type typcha; // @@ -7740,12 +8088,12 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr { case MED_FLOAT64: { - ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll); + ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); break; } case MED_INT32: { - ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll); + ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); break; } default: @@ -7779,12 +8127,12 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !"); } -MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll) +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) try:MEDFileFieldGlobsReal(fileName) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName,fieldName,loadAll); + _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -7794,9 +8142,9 @@ catch(INTERP_KERNEL::Exception& e) //= MEDFileIntFieldMultiTSWithoutSDA -MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) +MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { - return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll); + return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); } MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA() @@ -7807,8 +8155,8 @@ MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::st { } -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll) +MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -7817,8 +8165,8 @@ catch(INTERP_KERNEL::Exception& e) /*! * \param [in] fieldId field id in C mode */ -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll) +MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -7887,7 +8235,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& f { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,loadAll); + MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,loadAll,0); MEDCouplingAutoRefCountObjectPtr ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); @@ -7907,7 +8255,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& f { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName,loadAll); + MEDCouplingAutoRefCountObjectPtr c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0)); MEDCouplingAutoRefCountObjectPtr ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); @@ -8026,6 +8374,18 @@ void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vectorgetNumberOfTS()); + for(int i=0;i elt(fmts->getTimeStepAtPos(i)); + pushBackTimeStep(elt); + } +} + void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) { if(!f1ts) @@ -8122,6 +8482,11 @@ const std::vector& MEDFileAnyTypeFieldMultiTS::getInfo() const return contentNotNullBase()->getInfo(); } +bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const +{ + return contentNotNullBase()->presenceOfMultiDiscPerGeoType(); +} + void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector& info) { return contentNotNullBase()->setInfo(info); @@ -8226,11 +8591,10 @@ std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren(); } -std::vector MEDFileAnyTypeFieldMultiTS::getDirectChildren() const +std::vector MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const { - std::vector ret(MEDFileFieldGlobsReal::getDirectChildren()); - if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content) - ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content); + std::vector ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull()); + ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content); return ret; } @@ -8257,14 +8621,34 @@ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ME /*! * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this. - * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this. + * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this. */ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const { const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content); if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !"); - std::vector< MEDCouplingAutoRefCountObjectPtr > contentsSplit=content->splitDiscretizations(); + std::vector< MEDCouplingAutoRefCountObjectPtr > contentsSplit(content->splitDiscretizations()); + std::size_t sz(contentsSplit.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz); + for(std::size_t i=0;i_content=contentsSplit[i]; + } + return ret; +} + +/*! + * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this. + * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this. + */ +std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const +{ + const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content); + if(!content) + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !"); + std::vector< MEDCouplingAutoRefCountObjectPtr > contentsSplit(content->splitMultiDiscrPerGeoTypes()); std::size_t sz(contentsSplit.size()); std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz); for(std::size_t i=0;i ret=new MEDFileFieldMultiTS(fileName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret=new MEDFileFieldMultiTS(fileName,loadAll,0); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -8571,7 +8955,7 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool */ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -8593,6 +8977,13 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSD return new MEDFileFieldMultiTS(other,shallowCopyOfContent); } +MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) +{ + MEDCouplingAutoRefCountObjectPtr ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities)); + ret->contentNotNull();//to check that content type matches with \a this type. + return ret.retn(); +} + MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const { return new MEDFileFieldMultiTS(*this); @@ -8917,15 +9308,15 @@ MEDFileFieldMultiTS::MEDFileFieldMultiTS() _content=new MEDFileFieldMultiTSWithoutSDA; } -MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll) -try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll) +MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll) -try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll) +MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -9001,7 +9392,7 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New() */ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntFieldMultiTS(fileName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9018,7 +9409,7 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, */ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll); + MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9040,6 +9431,13 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTS return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent); } +MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) +{ + MEDCouplingAutoRefCountObjectPtr ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities); + ret->contentNotNull();//to check that content type matches with \a this type. + return ret.retn(); +} + /*! * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied * following the given input policy. @@ -9367,15 +9765,15 @@ MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWitho { } -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll) -try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll) +MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll) -try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll) +MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -9395,7 +9793,17 @@ MEDFileFields *MEDFileFields::New() MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll) { - return new MEDFileFields(fileName,loadAll); + return new MEDFileFields(fileName,loadAll,0,0); +} + +MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) +{ + return new MEDFileFields(fileName,loadAll,ms,0); +} + +MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair >& entities, bool loadAll) +{ + return new MEDFileFields(fileName,loadAll,0,&entities); } std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const @@ -9405,15 +9813,11 @@ std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const return ret; } -std::vector MEDFileFields::getDirectChildren() const +std::vector MEDFileFields::getDirectChildrenWithNull() const { std::vector ret; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fields.begin();it!=_fields.end();it++) - { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); - if(cur) - ret.push_back(cur); - } + ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it); return ret; } @@ -9557,29 +9961,29 @@ MEDFileFields::MEDFileFields() { } -MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll) +MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) try:MEDFileFieldGlobsReal(fileName) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); + int nbFields(MEDnField(fid)); _fields.resize(nbFields); med_field_type typcha; for(int i=0;i infos; std::string fieldName,dtunit; - int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit); + int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit)); switch(typcha) { case MED_FLOAT64: { - _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll); + _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities); break; } case MED_INT32: { - _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll); + _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities); break; } default: