1 // Copyright (C) 2017-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #include "MEDFileFieldMultiTS.hxx"
22 #include "MEDFileFieldVisitor.hxx"
23 #include "MEDFileSafeCaller.txx"
24 #include "MEDLoaderBase.hxx"
25 #include "MEDFileField.txx"
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldTemplate.hxx"
32 using namespace MEDCoupling;
34 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<int>;
35 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<float>;
36 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<double>;
37 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<int>;
38 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<float>;
39 template class MEDCoupling::MEDFileTemplateFieldMultiTS<int>;
40 template class MEDCoupling::MEDFileTemplateFieldMultiTS<float>;
41 template class MEDCoupling::MEDFileTemplateFieldMultiTS<double>;
42 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<int>;
43 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<float>;
45 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
47 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
51 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
56 * \param [in] fieldId field id in C mode
58 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
60 med_field_type typcha;
61 std::string dtunitOut,meshName;
62 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
63 setMeshName(meshName);
64 setDtUnit(dtunitOut.c_str());
65 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
68 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
69 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
71 setDtUnit(dtunit.c_str());
72 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
74 catch(INTERP_KERNEL::Exception& e)
79 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
81 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
82 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
83 ret+=(*it).capacity();
87 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
89 std::vector<const BigMemoryObject *> ret;
90 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
91 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
96 * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not
99 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
101 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
102 ret->setInfo(_infos);
103 int sz=(int)_time_steps.size();
104 for(const int *id=startIds;id!=endIds;id++)
108 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
109 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
113 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
115 ret->pushBackTimeStep(tse2);
119 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
120 oss << " ! Should be in [0," << sz << ") !";
121 throw INTERP_KERNEL::Exception(oss.str());
124 if(ret->getNumberOfTS()>0)
125 ret->synchronizeNameScope();
126 ret->copyNameScope(*this);
131 * If one of the id in the input range points to a null element, there is not throw. Simply, this empty element is added as if it were not
134 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
136 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
137 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
138 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
139 ret->setInfo(_infos);
140 int sz=(int)_time_steps.size();
142 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
146 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
147 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
151 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
153 ret->pushBackTimeStep(tse2);
157 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
158 oss << " ! Should be in [0," << sz << ") !";
159 throw INTERP_KERNEL::Exception(oss.str());
162 if(ret->getNumberOfTS()>0)
163 ret->synchronizeNameScope();
164 ret->copyNameScope(*this);
168 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
171 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
172 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
174 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
177 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
178 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
179 ids->pushBackSilent(id);
181 return buildFromTimeStepIds(ids->begin(),ids->end());
184 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
187 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
188 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
190 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
193 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
194 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
195 ids->pushBackSilent(id);
197 return buildFromTimeStepIds(ids->begin(),ids->end());
200 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
202 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
203 if((*it).isNotNull())
204 if((*it)->presenceOfStructureElements())
209 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
211 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
212 if((*it).isNotNull())
213 if(!(*it)->onlyStructureElements())
218 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
220 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
221 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
222 if((*it).isNotNull())
224 if((*it)->presenceOfStructureElements())
226 if(!(*it)->onlyStructureElements())
228 (*it)->killStructureElements();
240 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
242 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
243 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
244 if((*it).isNotNull())
246 if((*it)->presenceOfStructureElements())
248 if(!(*it)->onlyStructureElements())
249 (*it)->keepOnlyStructureElements();
256 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
258 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
259 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
260 if((*it).isNotNull())
261 (*it)->keepOnlyOnSE(seName);
264 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
266 std::vector< std::pair<std::string,std::string> > ps2;
267 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
268 if((*it).isNotNull())
270 (*it)->getMeshSENames(ps2);
274 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
275 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
276 if((*it).isNotNull())
278 std::vector< std::pair<std::string,std::string> > ps3;
279 (*it)->getMeshSENames(ps3);
281 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
283 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
285 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
291 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
293 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
295 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
298 if(cur->presenceOfMultiDiscPerGeoType())
304 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
309 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
314 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
317 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
319 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
320 if(pt->isDealingTS(iteration,order))
323 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
324 std::vector< std::pair<int,int> > vp=getIterations();
325 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
326 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
327 throw INTERP_KERNEL::Exception(oss.str());
330 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
332 return *_time_steps[getTimeStepPos(iteration,order)];
335 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
337 return *_time_steps[getTimeStepPos(iteration,order)];
340 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
343 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
345 if((*it).first==getMeshName())
347 setMeshName((*it).second);
351 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
353 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
355 ret=cur->changeMeshNames(modifTab) || ret;
361 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
363 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
365 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
369 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
371 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
373 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
376 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
377 MEDFileFieldGlobsReal& glob)
380 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
382 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
384 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
389 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
391 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
392 if((*it).isNotNull())
394 visitor.newTimeStepEntry(*it);
395 (*it)->accept(visitor);
396 visitor.endTimeStepEntry(*it);
400 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
402 std::string startLine(bkOffset,' ');
403 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
405 oss << " (" << fmtsId << ")";
406 oss << " has the following name: \"" << _name << "\"." << std::endl;
407 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
408 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
410 oss << startLine << " - \"" << *it << "\"" << std::endl;
413 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
415 std::string chapter(17,'0'+i);
416 oss << startLine << chapter << std::endl;
417 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
419 cur->simpleRepr(bkOffset+2,oss,i);
421 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
422 oss << startLine << chapter << std::endl;
426 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
428 std::size_t sz=_time_steps.size();
429 std::vector< std::pair<int,int> > ret(sz);
431 for(std::size_t i=0;i<sz;i++)
433 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
436 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
440 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
441 throw INTERP_KERNEL::Exception(oss.str());
447 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
449 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
452 checkCoherencyOfType(tse2);
453 if(_time_steps.empty())
455 setName(tse2->getName());
456 setMeshName(tse2->getMeshName());
457 setInfo(tse2->getInfo());
459 checkThatComponentsMatch(tse2->getInfo());
460 if(getDtUnit().empty() && !tse->getDtUnit().empty())
461 setDtUnit(tse->getDtUnit());
462 _time_steps.push_back(tse);
465 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
467 std::size_t nbOfCompo=_infos.size();
468 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
470 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
473 if((cur->getInfo()).size()!=nbOfCompo)
475 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
476 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
477 throw INTERP_KERNEL::Exception(oss.str());
479 cur->copyNameScope(*this);
484 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
486 _time_steps.resize(nbPdt);
487 for(int i=0;i<nbPdt;i++)
489 std::vector< std::pair<int,int> > ts;
490 med_int numdt=0,numo=0;
492 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
497 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
502 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
507 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
512 if(sizeof(med_int)==sizeof(int))
514 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
519 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
522 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
524 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
525 synchronizeNameScope();
529 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
531 if(_time_steps.empty())
532 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
533 checkThatNbOfCompoOfTSMatchThis();
534 std::vector<std::string> infos(getInfo());
535 int nbComp=infos.size();
536 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
537 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
538 for(int i=0;i<nbComp;i++)
540 std::string info=infos[i];
542 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
543 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
544 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
547 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
548 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
549 int nbOfTS=_time_steps.size();
550 for(int i=0;i<nbOfTS;i++)
551 _time_steps[i]->writeLL(fid,opts,*this);
554 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
556 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
558 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
560 elt->loadBigArraysRecursively(fid,nasc);
564 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
566 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
568 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
570 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
574 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
576 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
578 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
584 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
586 return _time_steps.size();
589 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
591 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
592 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
594 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
596 newTS.push_back(*it);
601 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
603 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
604 int maxId=(int)_time_steps.size();
606 std::set<int> idsToDel;
607 for(const int *id=startIds;id!=endIds;id++,ii++)
609 if(*id>=0 && *id<maxId)
611 idsToDel.insert(*id);
615 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
616 throw INTERP_KERNEL::Exception(oss.str());
619 for(int iii=0;iii<maxId;iii++)
620 if(idsToDel.find(iii)==idsToDel.end())
621 newTS.push_back(_time_steps[iii]);
625 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
627 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
628 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
629 if(nbOfEntriesToKill==0)
631 std::size_t sz=_time_steps.size();
632 std::vector<bool> b(sz,true);
634 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
636 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
637 for(std::size_t i=0;i<sz;i++)
639 newTS.push_back(_time_steps[i]);
643 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
646 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
647 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
649 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
653 tmp->getTime(it2,ord);
654 if(it2==iteration && order==ord)
657 oss << "(" << it2 << "," << ord << "), ";
660 throw INTERP_KERNEL::Exception(oss.str());
663 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
666 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
668 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
670 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
674 double ti=tmp->getTime(it2,ord);
675 if(fabs(time-ti)<eps)
681 throw INTERP_KERNEL::Exception(oss.str());
684 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
686 int lgth=_time_steps.size();
687 std::vector< std::pair<int,int> > ret(lgth);
688 for(int i=0;i<lgth;i++)
689 _time_steps[i]->fillIteration(ret[i]);
694 * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
695 * This method returns two things.
696 * - The absolute dimension of 'this' in first parameter.
697 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
698 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
700 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
701 * Only these 3 discretizations will be taken into account here.
703 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
704 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
705 * case the caller has to know the underlying mesh it refers to. By default it is the level 0 of the corresponding mesh.
707 * This method is useful to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
708 * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
710 * Let's consider the typical following case :
711 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
712 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
713 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
715 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
717 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
719 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
720 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
721 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
722 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
724 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
726 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
729 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
731 if(pos<0 || pos>=(int)_time_steps.size())
733 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
734 throw INTERP_KERNEL::Exception(oss.str());
736 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
739 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
740 oss << "\nTry to use following method eraseEmptyTS !";
741 throw INTERP_KERNEL::Exception(oss.str());
746 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
748 if(pos<0 || pos>=(int)_time_steps.size())
750 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
751 throw INTERP_KERNEL::Exception(oss.str());
753 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
756 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
757 oss << "\nTry to use following method eraseEmptyTS !";
758 throw INTERP_KERNEL::Exception(oss.str());
763 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
765 std::vector<std::string> ret;
766 std::set<std::string> ret2;
767 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
769 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
770 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
771 if(ret2.find(*it2)==ret2.end())
780 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
782 std::vector<std::string> ret;
783 std::set<std::string> ret2;
784 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
786 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
787 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
788 if(ret2.find(*it2)==ret2.end())
797 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
799 std::vector<std::string> ret;
800 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
802 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
803 ret.insert(ret.end(),tmp.begin(),tmp.end());
808 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
810 std::vector<std::string> ret;
811 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
813 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
814 ret.insert(ret.end(),tmp.begin(),tmp.end());
819 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
821 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
822 (*it)->changePflsRefsNamesGen2(mapOfModif);
825 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
827 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
828 (*it)->changeLocsRefsNamesGen2(mapOfModif);
831 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
833 int lgth=_time_steps.size();
834 std::vector< std::vector<TypeOfField> > ret(lgth);
835 for(int i=0;i<lgth;i++)
836 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
841 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
843 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
845 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
848 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
850 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
852 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
854 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
855 ret->_time_steps[i]=(*it)->deepCopy();
860 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
862 std::size_t sz(_infos.size()),sz2(_time_steps.size());
863 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
864 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
865 for(std::size_t i=0;i<sz;i++)
868 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
870 for(std::size_t i=0;i<sz2;i++)
872 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
875 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
876 throw INTERP_KERNEL::Exception(oss.str());
880 for(std::size_t i=0;i<sz;i++)
881 for(std::size_t j=0;j<sz2;j++)
882 ret[i]->_time_steps[j]=ts[j][i];
887 * This method splits into discretization each time steps in \a this.
888 * ** WARNING ** the returned instances are not compulsory defined on the same time steps series !
890 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
892 std::size_t sz(_time_steps.size());
893 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
894 for(std::size_t i=0;i<sz;i++)
896 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
899 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
900 throw INTERP_KERNEL::Exception(oss.str());
902 items[i]=timeStep->splitDiscretizations();
905 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
906 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
907 std::vector< TypeOfField > types;
908 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
909 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
911 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
913 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
914 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
916 types.push_back(ts[0]);
918 ret.resize(types.size()); ret2.resize(types.size());
919 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
920 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
922 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
923 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
924 ret2[pos].push_back(*it1);
926 for(std::size_t i=0;i<types.size();i++)
928 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
929 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
930 elt->pushBackTimeStep(*it1);//also updates infos in elt
932 elt->MEDFileFieldNameScope::operator=(*this);
938 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
940 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
942 std::size_t sz(_time_steps.size());
943 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
944 std::size_t szOut(std::numeric_limits<std::size_t>::max());
945 for(std::size_t i=0;i<sz;i++)
947 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
950 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
951 throw INTERP_KERNEL::Exception(oss.str());
953 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
954 if(szOut==std::numeric_limits<std::size_t>::max())
955 szOut=items[i].size();
957 if(items[i].size()!=szOut)
958 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
960 if(szOut==std::numeric_limits<std::size_t>::max())
961 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
962 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
963 for(std::size_t i=0;i<szOut;i++)
965 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
966 for(std::size_t j=0;j<sz;j++)
967 elt->pushBackTimeStep(items[j][i]);
969 elt->MEDFileFieldNameScope::operator=(*this);
974 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
976 setName(field->getName());
978 setMeshName(field->getMesh()->getName());
980 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
982 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
983 _infos=arr->getInfoOnComponents();
986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
988 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
989 if(_name!=field->getName())
991 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
992 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
993 throw INTERP_KERNEL::Exception(oss.str());
996 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
997 checkThatComponentsMatch(arr->getInfoOnComponents());
1000 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
1002 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
1003 if(getInfo().size()!=compos.size())
1005 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
1006 oss << " number of components of element to append (" << compos.size() << ") !";
1007 throw INTERP_KERNEL::Exception(oss.str());
1011 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
1012 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
1013 oss << " But compo in input fields are : ";
1014 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
1016 throw INTERP_KERNEL::Exception(oss.str());
1020 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
1022 std::size_t sz=_infos.size();
1024 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
1026 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
1028 if(elt->getInfo().size()!=sz)
1030 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
1031 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
1032 throw INTERP_KERNEL::Exception(oss.str());
1037 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1040 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1041 if(!_time_steps.empty())
1042 checkCoherencyOfTinyInfo(field,arr);
1043 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(createNew1TSWithoutSDAEmptyInstance());
1045 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
1046 obj->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
1048 copyTinyInfoFrom(field,arr);
1049 _time_steps.push_back(obj);
1052 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, bool smartPflKiller)
1055 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1056 if(!_time_steps.empty())
1057 checkCoherencyOfTinyInfo(field,arr);
1058 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(createNew1TSWithoutSDAEmptyInstance());
1060 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
1061 obj->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this,smartPflKiller);
1063 copyTinyInfoFrom(field,arr);
1064 setMeshName(obj->getMeshName());
1065 _time_steps.push_back(obj);
1068 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
1070 int sz=(int)_time_steps.size();
1073 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
1074 throw INTERP_KERNEL::Exception(oss.str());
1076 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
1079 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
1081 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
1082 throw INTERP_KERNEL::Exception(oss.str());
1088 //= MEDFileFieldMultiTSWithoutSDA
1091 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
1092 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
1094 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
1096 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
1097 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
1099 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
1100 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
1103 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
1105 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
1106 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
1108 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
1110 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
1113 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
1115 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
1116 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
1117 ret->setIteration(i,elt);
1123 //= MEDFileAnyTypeFieldMultiTS
1125 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
1129 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1130 try:MEDFileFieldGlobsReal(fid)
1132 _content=BuildContentFrom(fid,loadAll,ms);
1135 catch(INTERP_KERNEL::Exception& e)
1140 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1142 med_field_type typcha;
1143 std::vector<std::string> infos;
1145 std::string meshName;
1147 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
1148 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1153 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1158 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1163 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1168 if(sizeof(med_int)==sizeof(int))
1170 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1176 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !";
1177 throw INTERP_KERNEL::Exception(oss.str());
1180 ret->setMeshName(meshName);
1181 ret->setDtUnit(dtunit.c_str());
1185 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1187 med_field_type typcha;
1189 std::vector<std::string> infos;
1190 std::string dtunit,fieldName,meshName;
1191 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1192 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1197 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1202 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1207 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1212 if(sizeof(med_int)==sizeof(int))
1214 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1220 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !";
1221 throw INTERP_KERNEL::Exception(oss.str());
1224 ret->setMeshName(meshName);
1225 ret->setDtUnit(dtunit.c_str());
1229 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
1232 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1233 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
1235 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1236 ret->_content=c; c->incrRef();
1239 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
1241 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
1242 ret->_content=c; c->incrRef();
1245 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
1247 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1248 ret->_content=c; c->incrRef();
1251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1254 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
1256 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
1257 std::string fileName(FileNameFromFID(fid));
1258 ret->setFileName(fileName);
1262 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1263 try:MEDFileFieldGlobsReal(fid)
1265 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1268 catch(INTERP_KERNEL::Exception& e)
1273 //= MEDFileAnyTypeFieldMultiTS
1276 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
1277 * that has been read from a specified MED file.
1278 * \param [in] fileName - the name of the MED file to read.
1279 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1280 * is to delete this field using decrRef() as it is no more needed.
1281 * \throw If reading the file fails.
1283 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
1285 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1286 return New(fid,loadAll);
1289 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
1291 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
1292 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1293 ret->loadGlobals(fid);
1298 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
1299 * that has been read from a specified MED file.
1300 * \param [in] fileName - the name of the MED file to read.
1301 * \param [in] fieldName - the name of the field to read.
1302 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1303 * is to delete this field using decrRef() as it is no more needed.
1304 * \throw If reading the file fails.
1305 * \throw If there is no field named \a fieldName in the file.
1307 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1309 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1310 return New(fid,fieldName,loadAll);
1313 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1315 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1316 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1317 ret->loadGlobals(fid);
1322 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1323 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1325 * \warning this is a shallow copy constructor
1327 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
1329 if(!shallowCopyOfContent)
1331 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
1332 otherPtr->incrRef();
1333 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
1337 _content=other.shallowCpy();
1341 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
1343 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1345 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
1349 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
1351 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1353 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
1357 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
1359 return contentNotNullBase()->getPflsReallyUsed2();
1362 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
1364 return contentNotNullBase()->getLocsReallyUsed2();
1367 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
1369 return contentNotNullBase()->getPflsReallyUsedMulti2();
1372 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
1374 return contentNotNullBase()->getLocsReallyUsedMulti2();
1377 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1379 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
1382 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1384 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
1387 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
1389 return contentNotNullBase()->getNumberOfTS();
1392 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
1394 contentNotNullBase()->eraseEmptyTS();
1397 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
1399 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
1402 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
1404 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
1407 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
1409 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
1410 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1415 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
1417 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
1418 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1423 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
1425 return contentNotNullBase()->getIterations();
1428 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
1430 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
1431 pushBackTimeStep(*it);
1434 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
1437 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
1438 int nbOfTS(fmts->getNumberOfTS());
1439 for(int i=0;i<nbOfTS;i++)
1441 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
1442 pushBackTimeStep(elt);
1446 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
1449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
1450 checkCoherencyOfType(f1ts);
1452 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
1453 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
1455 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
1456 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
1457 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
1458 _content->pushBackTimeStep(cSafe);
1459 appendGlobs(*f1ts,1e-12);
1462 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
1464 contentNotNullBase()->synchronizeNameScope();
1467 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
1469 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
1472 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
1474 return contentNotNullBase()->getPosGivenTime(time,eps);
1477 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
1479 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
1482 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
1484 return contentNotNullBase()->getTypesOfFieldAvailable();
1487 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
1489 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1492 std::string MEDFileAnyTypeFieldMultiTS::getName() const
1494 return contentNotNullBase()->getName();
1497 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
1499 contentNotNullBase()->setName(name);
1502 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
1504 return contentNotNullBase()->getDtUnit();
1507 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
1509 contentNotNullBase()->setDtUnit(dtUnit);
1512 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
1514 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
1517 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
1519 return contentNotNullBase()->getTimeSteps(ret1);
1522 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
1524 return contentNotNullBase()->getMeshName();
1527 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
1529 contentNotNullBase()->setMeshName(newMeshName);
1532 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1534 return contentNotNullBase()->changeMeshNames(modifTab);
1537 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
1539 return contentNotNullBase()->getInfo();
1542 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
1544 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
1547 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
1549 return contentNotNullBase()->setInfo(info);
1552 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
1554 const std::vector<std::string> ret=getInfo();
1555 return (int)ret.size();
1558 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
1560 writeGlobals(fid,*this);
1561 contentNotNullBase()->writeLL(fid,*this);
1565 * This method alloc the arrays and load potentially huge arrays contained in this field.
1566 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
1567 * This method can be also called to refresh or reinit values from a file.
1569 * \throw If the fileName is not set or points to a non readable MED file.
1571 void MEDFileAnyTypeFieldMultiTS::loadArrays()
1573 if(getFileName().empty())
1574 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
1575 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1576 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
1580 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
1581 * But once data loaded once, this method does nothing.
1583 * \throw If the fileName is not set or points to a non readable MED file.
1584 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
1586 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
1588 if(!getFileName().empty())
1590 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1591 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
1596 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
1597 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
1598 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
1600 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
1602 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
1604 contentNotNullBase()->unloadArrays();
1608 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
1609 * This method is the symmetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
1610 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
1612 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
1614 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
1616 if(!getFileName().empty())
1617 contentNotNullBase()->unloadArrays();
1620 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
1622 std::ostringstream oss;
1623 contentNotNullBase()->simpleRepr(0,oss,-1);
1624 simpleReprGlobs(oss);
1628 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
1630 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
1633 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
1635 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
1636 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
1641 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
1642 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
1643 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
1645 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
1647 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1649 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
1650 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
1651 std::size_t sz(contentsSplit.size());
1652 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1653 for(std::size_t i=0;i<sz;i++)
1655 ret[i]=shallowCpy();
1656 ret[i]->_content=contentsSplit[i];
1662 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
1663 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1665 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
1667 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1669 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
1670 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
1671 std::size_t sz(contentsSplit.size());
1672 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1673 for(std::size_t i=0;i<sz;i++)
1675 ret[i]=shallowCpy();
1676 ret[i]->_content=contentsSplit[i];
1682 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
1683 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1685 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
1687 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1689 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
1690 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
1691 std::size_t sz(contentsSplit.size());
1692 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1693 for(std::size_t i=0;i<sz;i++)
1695 ret[i]=shallowCpy();
1696 ret[i]->_content=contentsSplit[i];
1701 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
1703 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1704 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
1705 ret->_content=_content->deepCopy();
1706 ret->deepCpyGlobs(*this);
1710 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
1716 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1717 * \param [in] iteration - the iteration number of a required time step.
1718 * \param [in] order - the iteration order number of required time step.
1719 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
1720 * delete this field using decrRef() as it is no more needed.
1721 * \throw If there is no required time step in \a this field.
1723 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
1725 int pos=getPosOfTimeStep(iteration,order);
1726 return getTimeStepAtPos(pos);
1730 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1731 * \param [in] time - the time of the time step of interest.
1732 * \param [in] eps - a precision used to compare time values.
1733 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
1734 * delete this field using decrRef() as it is no more needed.
1735 * \throw If there is no required time step in \a this field.
1737 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
1739 int pos=getPosGivenTime(time,eps);
1740 return getTimeStepAtPos(pos);
1744 * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
1745 * The float64 value of time attached to the pair of integers are not considered here.
1746 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
1748 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
1749 * \throw If there is a null pointer in \a vectFMTS.
1751 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
1753 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
1754 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1755 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1756 while(!lstFMTS.empty())
1758 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1759 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1761 throw INTERP_KERNEL::Exception(msg);
1762 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
1763 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1764 elt.push_back(curIt); it=lstFMTS.erase(it);
1765 while(it!=lstFMTS.end())
1769 throw INTERP_KERNEL::Exception(msg);
1770 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
1772 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1782 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
1783 * All returned instances in a subvector can be safely loaded, rendered along time
1784 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
1785 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
1786 * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
1787 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
1788 * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
1790 * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
1791 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
1792 * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
1793 * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
1795 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
1796 * \throw If an element in \a vectFMTS change of spatial discretization along time.
1797 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
1798 * \thorw If some elements in \a vectFMTS do not have the same times steps.
1799 * \throw If mesh is null.
1800 * \throw If an element in \a vectFMTS is null.
1801 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
1803 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
1805 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
1807 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
1808 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1809 if(vectFMTS.empty())
1811 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
1812 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
1814 throw INTERP_KERNEL::Exception(msg);
1816 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
1817 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
1818 for(;it!=vectFMTS.end();it++,i++)
1821 throw INTERP_KERNEL::Exception(msg);
1822 TypeOfField tof0,tof1;
1823 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
1826 vectFMTSNotNodes.push_back(*it);
1828 vectFMTSNodes.push_back(*it);
1831 vectFMTSNotNodes.push_back(*it);
1833 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
1834 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
1836 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
1839 bool isFetched(false);
1840 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
1843 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
1844 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
1845 { ret[i].push_back(*it2); isFetched=true; }
1849 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
1850 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
1851 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
1859 * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
1860 * \param [out] cmps - same size than the returned vector.
1862 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
1864 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1865 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1866 while(!lstFMTS.empty())
1868 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1869 MEDFileAnyTypeFieldMultiTS *ref(*it);
1870 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1871 elt.push_back(ref); it=lstFMTS.erase(it);
1872 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
1873 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
1874 while(it!=lstFMTS.end())
1876 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1877 if(cmp->isEqual(curIt))
1878 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1882 ret.push_back(elt); cmps.push_back(cmp);
1888 * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
1889 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
1891 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
1892 * \throw If \a f0 or \a f1 change of spatial discretization along time.
1893 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
1894 * \thorw If \a f0 and \a f1 do not have the same times steps.
1895 * \throw If mesh is null.
1896 * \throw If \a f0 or \a f1 is null.
1897 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
1899 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
1902 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
1904 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
1905 if(f0->getMeshName()!=mesh->getName())
1907 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1908 throw INTERP_KERNEL::Exception(oss.str());
1910 if(f1->getMeshName()!=mesh->getName())
1912 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1913 throw INTERP_KERNEL::Exception(oss.str());
1915 int nts=f0->getNumberOfTS();
1916 if(nts!=f1->getNumberOfTS())
1917 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
1920 for(int i=0;i<nts;i++)
1922 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
1923 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
1924 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
1925 if(tofs0.size()!=1 || tofs1.size()!=1)
1926 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
1929 if(tof0!=tofs0[0] || tof1!=tofs1[0])
1930 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
1933 { tof0=tofs0[0]; tof1=tofs1[0]; }
1934 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
1936 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
1937 throw INTERP_KERNEL::Exception(oss.str());
1939 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
1941 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
1942 throw INTERP_KERNEL::Exception(oss.str());
1944 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
1946 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
1947 throw INTERP_KERNEL::Exception(oss.str());
1954 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
1956 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
1958 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
1959 std::size_t sz(f1tss.size()),i(0);
1960 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
1961 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
1963 typename MLFieldTraits<T>::F1TSType const *elt(*it);
1965 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
1966 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
1968 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
1970 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
1971 retc->aggregate(f1tsw,dts);
1972 ret->setDtUnit(f1tss[0]->getDtUnit());
1973 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
1977 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
1979 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
1981 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
1982 std::size_t sz(fmtss.size());
1983 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
1985 typename MLFieldTraits<T>::FMTSType const *elt(*it);
1987 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
1989 int nbTS(fmtss[0]->getNumberOfTS());
1990 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
1991 if((*it)->getNumberOfTS()!=nbTS)
1992 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
1993 for(int iterTS=0;iterTS<nbTS;iterTS++)
1996 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
1997 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
1998 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
1999 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
2000 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
2001 ret->pushBackTimeStep(f1ts);
2002 ret->setDtUnit(f1ts->getDtUnit());
2004 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
2008 * \a dts and \a ftmss are expected to have same size.
2010 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
2013 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
2014 std::size_t sz(fmtss.size());
2015 std::vector<const MEDFileFieldMultiTS *> fmtss1;
2016 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
2017 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2020 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
2021 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
2024 fmtss1.push_back(elt1);
2027 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
2030 fmtss2.push_back(elt2);
2033 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
2035 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
2036 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
2037 if(fmtss1.size()==sz)
2038 return AggregateHelperFMTS<double>(fmtss1,dts);
2039 if(fmtss2.size()!=sz)
2040 return AggregateHelperFMTS<int>(fmtss2,dts);
2041 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
2044 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
2046 return new MEDFileAnyTypeFieldMultiTSIterator(this);
2049 //= MEDFileFieldMultiTS
2051 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
2053 return new MEDFileFieldMultiTS(*this);
2057 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2058 * following the given input policy.
2060 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2061 * By default (true) the globals are deeply copied.
2062 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
2064 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
2066 MCAuto<MEDFileIntFieldMultiTS> ret;
2067 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
2070 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
2072 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2073 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
2074 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
2077 ret=MEDFileIntFieldMultiTS::New();
2079 ret->deepCpyGlobs(*this);
2081 ret->shallowCpyGlobs(*this);
2085 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2086 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
2089 catch(INTERP_KERNEL::Exception& e)
2092 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2093 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
2096 catch(INTERP_KERNEL::Exception& e)
2099 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
2103 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2105 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
2108 //= MEDFileAnyTypeFieldMultiTSIterator
2110 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
2115 _nb_iter=fmts->getNumberOfTS();
2119 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
2123 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
2125 if(_iter_id<_nb_iter)
2127 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
2129 return fmts->getTimeStepAtPos(_iter_id++);
2137 //= MEDFileIntFieldMultiTS