-// 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
{
if(!_profile.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
+ INTERP_KERNEL::AutoPtr<char> 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<const SlicePartDefinition *>(pd));
if(spd)
{
- int profilesize,nbi,start,stop,step;
+ int start,stop,step;
spd->getSlice(start,stop,step);
- INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
- int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
med_filter filter=MED_FILTER_INIT;
MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
MEDfilterClose(&filter);
return ;
}
+ const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
+ if(dpd)
+ {
+ dpd->checkCoherency();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArrayDouble> 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);
+ MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer()));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> feeder(DataArrayDouble::New());
+ feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
+ feeder->setContigPartOfSelectedValues(0,tmp,myIds);
+ }
+ MEDfilterClose(&filter);
+ }
else
throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
}
}
else
{
- const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
- if(!spd)
- throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : Part def only implemented for split one !");
if(!_profile.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
- int start,stop,step;
- spd->getSlice(start,stop,step);
- _nval=DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively");
+ _nval=pd->getNumberOfElems();
}
_start=start;
_end=start+_nval*nbi;
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;
int nbOfCompo(arr->getNumberOfComponents());
DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
if(arrD)
return _father->getNumberOfComponents();
}
+bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
+{
+ std::size_t nb(0);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::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();
*/
bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
{
- bool ret=false;
+ bool ret(false);
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
if((*it)->getType()==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<int,int> >& its)
+{
+ if(_field_pm_pt_pd.size()<=idOfDisc)
+ return false;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
+ std::pair<int,int> 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)
{
}
return MED_UNDEF_ENTITY_TYPE;
}
-MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
- return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
+ return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
}
MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
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)
_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<int,int> >& 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<int,int> > 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<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
return da.retn();
}
-MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
+
+/// @cond INTERNAL
+
+class MFFPMIter
+{
+public:
+ static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *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<INTERP_KERNEL::NormalizedCellType>& cts);
+ void begin() { _it=_ids.begin(); }
+ bool finished() const { return _it==_ids.end(); }
+ void next() { _it++; }
+ int current() const { return *_it; }
+private:
+ std::vector<int> _ids;
+ std::vector<int>::const_iterator _it;
+};
+
+MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+{
+ if(!entities)
+ return new MFFPMIterSimple;
+ else
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
+ for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::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<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+{
+ if(!entities)
+ return true;
+ else
+ {
+ for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
+ if((*it).first==ON_NODES)
+ return true;
+ return false;
+ }
+}
+
+MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
+{
+ std::size_t sz(cts.size());
+ _ids.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
+ if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
+ _ids[i]=(int)std::distance(typmai2,loc);
+ else
+ throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
+ }
+}
+
+/// @cond INTERNAL
+
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
_father(fath)
{
INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
- for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
+ INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
+ for(iter0->begin();!iter0->finished();iter0->next())
{
- int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
+ 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],meshCsit+1,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)
{
- const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
const PartDefinition *pd(0);
if(mmu)
- pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
+ 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,meshCsit+1,meshName,pflName,locName);
- if(nbProfile>0)
+ if(MFFPMIter::IsPresenceOfNode(entities))
{
- 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);
+ 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);
+ }
}
}
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> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
{
std::vector<INTERP_KERNEL::NormalizedCellType> types;
std::vector< std::vector<TypeOfField> > typesF;
std::vector< std::vector<std::string> > pfls,locs;
- std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
+ std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
std::set<TypeOfField> allEnt;
for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
{
std::vector< std::pair<int,int> > 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> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> types;
+ std::vector< std::vector<TypeOfField> > typesF;
+ std::vector< std::vector<std::string> > pfls,locs;
+ std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
+ std::set<TypeOfField> allEnt;
+ std::size_t nbOfMDPGT(0),ii(0);
+ for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
+ {
+ nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
+ for(std::vector<TypeOfField>::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<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
+ ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
+ return ret0;
+ }
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
+ for(std::size_t i=0;i<nbOfMDPGT;i++)
+ {
+ std::vector< std::pair<int,int> > its;
+ ret[i]=shallowCpy();
+ int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
ret[i]->updateData(newLgth,its);
}
return ret;
int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& 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<int,int> >& 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<int,int> >& oldStartStops)
{
if(_nb_of_tuples_to_be_allocated>=0)
throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
}
-void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
+void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
med_int numdt,numit;
med_float dt;
}
//
for(int i=0;i<nmesh;i++)
- _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
+ _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
_nb_of_tuples_to_be_allocated=0;
for(int i=0;i<nmesh;i++)
_field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
(*it)->loadBigArraysRecursively(fid,nasc);
}
-void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
+void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
- loadOnlyStructureOfDataRecursively(fid,nasc,ms);
+ loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
loadBigArraysRecursively(fid,nasc);
}
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.
ret->setTime(numdt,numit,dt);
ret->_csit=1;
if(loadAll)
- ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
+ ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
else
- ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
+ ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
return ret.retn();
}
ret->setTime(numdt,numit,dt);
ret->_csit=1;
if(loadAll)
- ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
+ ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
else
- ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
+ ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
return ret.retn();
}
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
if(loadAll)
- ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
+ ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
else
- ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
+ ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
return ret.retn();
}
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);
/*!
* 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<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
+ std::size_t sz(contentsSplit.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ ret[i]=shallowCpy();
+ ret[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<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
std::size_t sz(contentsSplit.size());
std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
for(std::size_t i=0;i<sz;i++)
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();
}
/*!
* \param [in] fieldId field id in C mode
*/
-MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *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,ms);
+ loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
try:MEDFileFieldNameScope(fieldName),_infos(infos)
{
setDtUnit(dtunit.c_str());
- loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
+ loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
}
catch(INTERP_KERNEL::Exception& e)
{
return buildFromTimeStepIds(ids->begin(),ids->end());
}
+bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::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<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
{
return _infos;
}
}
-void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
_time_steps.resize(nbPdt);
for(int i=0;i<nbPdt;i++)
throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
}
if(loadAll)
- _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
+ _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
else
- _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
+ _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
}
}
}
for(std::size_t i=0;i<types.size();i++)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
elt->pushBackTimeStep(*it1);//also updates infos in elt
ret[i]=elt;
return ret;
}
+/*!
+ * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
+ */
+std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
+{
+ std::size_t sz(_time_steps.size());
+ std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
+ std::size_t szOut(std::numeric_limits<std::size_t>::max());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
+ if(!timeStep)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ items[i]=timeStep->splitMultiDiscrPerGeoTypes();
+ if(szOut==std::numeric_limits<std::size_t>::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<std::size_t>::max())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
+ for(std::size_t i=0;i<szOut;i++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
+ for(std::size_t j=0;j<sz;j++)
+ elt->pushBackTimeStep(items[j][i]);
+ ret[i]=elt;
+ elt->MEDFileFieldNameScope::operator=(*this);
+ }
+ return ret;
+}
+
void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
{
_name=field->getName();
//= MEDFileFieldMultiTSWithoutSDA
-MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
+MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
- return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
+ return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
}
MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
/*!
* \param [in] fieldId field id in C mode
*/
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
-try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *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<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
-try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
{
}
catch(INTERP_KERNEL::Exception& e)
throw e;
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
med_field_type typcha;
std::vector<std::string> infos;
{
case MED_FLOAT64:
{
- ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
+ ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
break;
}
case MED_INT32:
{
- ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
+ ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
break;
}
default:
{
case MED_FLOAT64:
{
- ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
+ ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
break;
}
case MED_INT32:
{
- ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
+ ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
break;
}
default:
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, const MEDFileMeshes *ms)
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
+ _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
loadGlobals(fid);
}
catch(INTERP_KERNEL::Exception& e)
//= MEDFileIntFieldMultiTSWithoutSDA
-MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
+MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
{
- return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
+ return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
}
MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
{
}
-MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
-try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
{
}
catch(INTERP_KERNEL::Exception& e)
/*!
* \param [in] fieldId field id in C mode
*/
-MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
-try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
{
}
catch(INTERP_KERNEL::Exception& e)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
ret->loadGlobals(fid);
return ret.retn();
pushBackTimeStep(*it);
}
+void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
+{
+ if(!fmts)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
+ int nbOfTS(fmts->getNumberOfTS());
+ for(int i=0;i<nbOfTS;i++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
+ pushBackTimeStep(elt);
+ }
+}
+
void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
{
if(!f1ts)
return contentNotNullBase()->getInfo();
}
+bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
+{
+ return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
+}
+
void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
{
return contentNotNullBase()->setInfo(info);
/*!
* 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<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
+ std::size_t sz(contentsSplit.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ ret[i]=shallowCpy();
+ ret[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<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
std::size_t sz(contentsSplit.size());
std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
for(std::size_t i=0;i<sz;i++)
return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
}
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> 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);
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
-try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
{
}
catch(INTERP_KERNEL::Exception& e)
return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
}
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> 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.
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
-try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
{
}
catch(INTERP_KERNEL::Exception& e)
MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
{
- return new MEDFileFields(fileName,loadAll,0);
+ 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);
+ return new MEDFileFields(fileName,loadAll,ms,0);
+}
+
+MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
+{
+ return new MEDFileFields(fileName,loadAll,0,&entities);
}
std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
{
}
-MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
+MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
{
case MED_FLOAT64:
{
- _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
+ _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,ms);
+ _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
break;
}
default: