1 // Copyright (C) 2017 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 MEDFileAnyTypeField1TSWithoutSDA *objC(createNew1TSWithoutSDAEmptyInstance());
1044 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
1046 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
1047 objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
1049 copyTinyInfoFrom(field,arr);
1050 _time_steps.push_back(obj);
1053 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
1056 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1057 if(!_time_steps.empty())
1058 checkCoherencyOfTinyInfo(field,arr);
1059 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
1060 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
1062 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
1063 objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this);
1065 copyTinyInfoFrom(field,arr);
1066 setMeshName(objC->getMeshName());
1067 _time_steps.push_back(obj);
1070 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
1072 int sz=(int)_time_steps.size();
1075 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
1076 throw INTERP_KERNEL::Exception(oss.str());
1078 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
1081 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
1083 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
1084 throw INTERP_KERNEL::Exception(oss.str());
1090 //= MEDFileFieldMultiTSWithoutSDA
1093 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
1094 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
1096 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
1098 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
1099 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
1101 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
1102 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
1105 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
1107 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
1108 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
1110 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
1112 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
1115 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
1117 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
1118 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
1119 ret->setIteration(i,elt);
1125 //= MEDFileAnyTypeFieldMultiTS
1127 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
1131 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1132 try:MEDFileFieldGlobsReal(fid)
1134 _content=BuildContentFrom(fid,loadAll,ms);
1137 catch(INTERP_KERNEL::Exception& e)
1142 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1144 med_field_type typcha;
1145 std::vector<std::string> infos;
1147 std::string meshName;
1149 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
1150 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1155 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1160 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1165 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1170 if(sizeof(med_int)==sizeof(int))
1172 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1178 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] !";
1179 throw INTERP_KERNEL::Exception(oss.str());
1182 ret->setMeshName(meshName);
1183 ret->setDtUnit(dtunit.c_str());
1187 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1189 med_field_type typcha;
1191 std::vector<std::string> infos;
1192 std::string dtunit,fieldName,meshName;
1193 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1194 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1199 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1204 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1209 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1214 if(sizeof(med_int)==sizeof(int))
1216 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1222 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] !";
1223 throw INTERP_KERNEL::Exception(oss.str());
1226 ret->setMeshName(meshName);
1227 ret->setDtUnit(dtunit.c_str());
1231 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
1234 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1235 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
1237 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1238 ret->_content=c; c->incrRef();
1241 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
1243 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
1244 ret->_content=c; c->incrRef();
1247 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
1249 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1250 ret->_content=c; c->incrRef();
1253 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1256 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
1258 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
1259 std::string fileName(FileNameFromFID(fid));
1260 ret->setFileName(fileName);
1264 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1265 try:MEDFileFieldGlobsReal(fid)
1267 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1270 catch(INTERP_KERNEL::Exception& e)
1275 //= MEDFileAnyTypeFieldMultiTS
1278 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
1279 * that has been read from a specified MED file.
1280 * \param [in] fileName - the name of the MED file to read.
1281 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1282 * is to delete this field using decrRef() as it is no more needed.
1283 * \throw If reading the file fails.
1285 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
1287 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1288 return New(fid,loadAll);
1291 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
1293 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
1294 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1295 ret->loadGlobals(fid);
1300 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
1301 * that has been read from a specified MED file.
1302 * \param [in] fileName - the name of the MED file to read.
1303 * \param [in] fieldName - the name of the field to read.
1304 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1305 * is to delete this field using decrRef() as it is no more needed.
1306 * \throw If reading the file fails.
1307 * \throw If there is no field named \a fieldName in the file.
1309 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1311 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1312 return New(fid,fieldName,loadAll);
1315 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1317 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1318 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1319 ret->loadGlobals(fid);
1324 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1325 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1327 * \warning this is a shallow copy constructor
1329 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
1331 if(!shallowCopyOfContent)
1333 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
1334 otherPtr->incrRef();
1335 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
1339 _content=other.shallowCpy();
1343 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
1345 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1347 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
1351 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
1353 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1355 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
1359 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
1361 return contentNotNullBase()->getPflsReallyUsed2();
1364 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
1366 return contentNotNullBase()->getLocsReallyUsed2();
1369 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
1371 return contentNotNullBase()->getPflsReallyUsedMulti2();
1374 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
1376 return contentNotNullBase()->getLocsReallyUsedMulti2();
1379 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1381 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
1384 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1386 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
1389 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
1391 return contentNotNullBase()->getNumberOfTS();
1394 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
1396 contentNotNullBase()->eraseEmptyTS();
1399 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
1401 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
1404 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
1406 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
1409 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
1411 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
1412 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1417 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
1419 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
1420 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1425 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
1427 return contentNotNullBase()->getIterations();
1430 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
1432 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
1433 pushBackTimeStep(*it);
1436 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
1439 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
1440 int nbOfTS(fmts->getNumberOfTS());
1441 for(int i=0;i<nbOfTS;i++)
1443 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
1444 pushBackTimeStep(elt);
1448 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
1451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
1452 checkCoherencyOfType(f1ts);
1454 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
1455 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
1457 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
1458 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
1459 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
1460 _content->pushBackTimeStep(cSafe);
1461 appendGlobs(*f1ts,1e-12);
1464 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
1466 contentNotNullBase()->synchronizeNameScope();
1469 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
1471 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
1474 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
1476 return contentNotNullBase()->getPosGivenTime(time,eps);
1479 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
1481 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
1484 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
1486 return contentNotNullBase()->getTypesOfFieldAvailable();
1489 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
1491 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1494 std::string MEDFileAnyTypeFieldMultiTS::getName() const
1496 return contentNotNullBase()->getName();
1499 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
1501 contentNotNullBase()->setName(name);
1504 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
1506 return contentNotNullBase()->getDtUnit();
1509 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
1511 contentNotNullBase()->setDtUnit(dtUnit);
1514 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
1516 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
1519 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
1521 return contentNotNullBase()->getTimeSteps(ret1);
1524 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
1526 return contentNotNullBase()->getMeshName();
1529 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
1531 contentNotNullBase()->setMeshName(newMeshName);
1534 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1536 return contentNotNullBase()->changeMeshNames(modifTab);
1539 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
1541 return contentNotNullBase()->getInfo();
1544 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
1546 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
1549 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
1551 return contentNotNullBase()->setInfo(info);
1554 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
1556 const std::vector<std::string> ret=getInfo();
1557 return (int)ret.size();
1560 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
1562 writeGlobals(fid,*this);
1563 contentNotNullBase()->writeLL(fid,*this);
1567 * This method alloc the arrays and load potentially huge arrays contained in this field.
1568 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
1569 * This method can be also called to refresh or reinit values from a file.
1571 * \throw If the fileName is not set or points to a non readable MED file.
1573 void MEDFileAnyTypeFieldMultiTS::loadArrays()
1575 if(getFileName().empty())
1576 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
1577 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1578 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
1582 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
1583 * But once data loaded once, this method does nothing.
1585 * \throw If the fileName is not set or points to a non readable MED file.
1586 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
1588 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
1590 if(!getFileName().empty())
1592 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1593 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
1598 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
1599 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
1600 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
1602 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
1604 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
1606 contentNotNullBase()->unloadArrays();
1610 * 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.
1611 * This method is the symmetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
1612 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
1614 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
1616 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
1618 if(!getFileName().empty())
1619 contentNotNullBase()->unloadArrays();
1622 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
1624 std::ostringstream oss;
1625 contentNotNullBase()->simpleRepr(0,oss,-1);
1626 simpleReprGlobs(oss);
1630 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
1632 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
1635 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
1637 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
1638 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
1643 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
1644 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
1645 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
1647 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
1649 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1651 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
1652 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
1653 std::size_t sz(contentsSplit.size());
1654 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1655 for(std::size_t i=0;i<sz;i++)
1657 ret[i]=shallowCpy();
1658 ret[i]->_content=contentsSplit[i];
1664 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
1665 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1667 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
1669 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1671 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
1672 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
1673 std::size_t sz(contentsSplit.size());
1674 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1675 for(std::size_t i=0;i<sz;i++)
1677 ret[i]=shallowCpy();
1678 ret[i]->_content=contentsSplit[i];
1684 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
1685 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1687 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
1689 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1691 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
1692 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
1693 std::size_t sz(contentsSplit.size());
1694 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1695 for(std::size_t i=0;i<sz;i++)
1697 ret[i]=shallowCpy();
1698 ret[i]->_content=contentsSplit[i];
1703 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
1705 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1706 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
1707 ret->_content=_content->deepCopy();
1708 ret->deepCpyGlobs(*this);
1712 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
1718 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1719 * \param [in] iteration - the iteration number of a required time step.
1720 * \param [in] order - the iteration order number of required time step.
1721 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
1722 * delete this field using decrRef() as it is no more needed.
1723 * \throw If there is no required time step in \a this field.
1725 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
1727 int pos=getPosOfTimeStep(iteration,order);
1728 return getTimeStepAtPos(pos);
1732 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1733 * \param [in] time - the time of the time step of interest.
1734 * \param [in] eps - a precision used to compare time values.
1735 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
1736 * delete this field using decrRef() as it is no more needed.
1737 * \throw If there is no required time step in \a this field.
1739 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
1741 int pos=getPosGivenTime(time,eps);
1742 return getTimeStepAtPos(pos);
1746 * 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.
1747 * The float64 value of time attached to the pair of integers are not considered here.
1748 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
1750 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
1751 * \throw If there is a null pointer in \a vectFMTS.
1753 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
1755 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
1756 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1757 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1758 while(!lstFMTS.empty())
1760 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1761 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1763 throw INTERP_KERNEL::Exception(msg);
1764 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
1765 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1766 elt.push_back(curIt); it=lstFMTS.erase(it);
1767 while(it!=lstFMTS.end())
1771 throw INTERP_KERNEL::Exception(msg);
1772 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
1774 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1784 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
1785 * All returned instances in a subvector can be safely loaded, rendered along time
1786 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
1787 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
1788 * 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).
1789 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
1790 * 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.
1792 * \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().
1793 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
1794 * \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.
1795 * \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.
1797 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
1798 * \throw If an element in \a vectFMTS change of spatial discretization along time.
1799 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
1800 * \thorw If some elements in \a vectFMTS do not have the same times steps.
1801 * \throw If mesh is null.
1802 * \throw If an element in \a vectFMTS is null.
1803 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
1805 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
1807 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
1809 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
1810 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1811 if(vectFMTS.empty())
1813 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
1814 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
1816 throw INTERP_KERNEL::Exception(msg);
1818 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
1819 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
1820 for(;it!=vectFMTS.end();it++,i++)
1823 throw INTERP_KERNEL::Exception(msg);
1824 TypeOfField tof0,tof1;
1825 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
1828 vectFMTSNotNodes.push_back(*it);
1830 vectFMTSNodes.push_back(*it);
1833 vectFMTSNotNodes.push_back(*it);
1835 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
1836 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
1838 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
1841 bool isFetched(false);
1842 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
1845 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
1846 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
1847 { ret[i].push_back(*it2); isFetched=true; }
1851 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
1852 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
1853 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
1861 * 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.
1862 * \param [out] cmps - same size than the returned vector.
1864 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
1866 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1867 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1868 while(!lstFMTS.empty())
1870 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1871 MEDFileAnyTypeFieldMultiTS *ref(*it);
1872 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1873 elt.push_back(ref); it=lstFMTS.erase(it);
1874 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
1875 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
1876 while(it!=lstFMTS.end())
1878 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1879 if(cmp->isEqual(curIt))
1880 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1884 ret.push_back(elt); cmps.push_back(cmp);
1890 * 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.
1891 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
1893 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
1894 * \throw If \a f0 or \a f1 change of spatial discretization along time.
1895 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
1896 * \thorw If \a f0 and \a f1 do not have the same times steps.
1897 * \throw If mesh is null.
1898 * \throw If \a f0 or \a f1 is null.
1899 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
1901 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
1904 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
1906 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
1907 if(f0->getMeshName()!=mesh->getName())
1909 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1910 throw INTERP_KERNEL::Exception(oss.str());
1912 if(f1->getMeshName()!=mesh->getName())
1914 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1915 throw INTERP_KERNEL::Exception(oss.str());
1917 int nts=f0->getNumberOfTS();
1918 if(nts!=f1->getNumberOfTS())
1919 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
1922 for(int i=0;i<nts;i++)
1924 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
1925 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
1926 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
1927 if(tofs0.size()!=1 || tofs1.size()!=1)
1928 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
1931 if(tof0!=tofs0[0] || tof1!=tofs1[0])
1932 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
1935 { tof0=tofs0[0]; tof1=tofs1[0]; }
1936 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
1938 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() << ") !";
1939 throw INTERP_KERNEL::Exception(oss.str());
1941 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
1943 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() << ") !";
1944 throw INTERP_KERNEL::Exception(oss.str());
1946 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
1948 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() << ") !";
1949 throw INTERP_KERNEL::Exception(oss.str());
1956 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
1958 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
1960 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
1961 std::size_t sz(f1tss.size()),i(0);
1962 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
1963 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
1965 typename MLFieldTraits<T>::F1TSType const *elt(*it);
1967 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
1968 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
1970 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
1972 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
1973 retc->aggregate(f1tsw,dts);
1974 ret->setDtUnit(f1tss[0]->getDtUnit());
1975 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
1979 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
1981 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
1983 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
1984 std::size_t sz(fmtss.size());
1985 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
1987 typename MLFieldTraits<T>::FMTSType const *elt(*it);
1989 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
1991 int nbTS(fmtss[0]->getNumberOfTS());
1992 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
1993 if((*it)->getNumberOfTS()!=nbTS)
1994 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
1995 for(int iterTS=0;iterTS<nbTS;iterTS++)
1998 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
1999 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
2000 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
2001 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
2002 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
2003 ret->pushBackTimeStep(f1ts);
2004 ret->setDtUnit(f1ts->getDtUnit());
2006 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
2010 * \a dts and \a ftmss are expected to have same size.
2012 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
2015 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
2016 std::size_t sz(fmtss.size());
2017 std::vector<const MEDFileFieldMultiTS *> fmtss1;
2018 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
2019 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2022 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
2023 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
2026 fmtss1.push_back(elt1);
2029 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
2032 fmtss2.push_back(elt2);
2035 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
2037 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
2038 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
2039 if(fmtss1.size()==sz)
2040 return AggregateHelperFMTS<double>(fmtss1,dts);
2041 if(fmtss2.size()!=sz)
2042 return AggregateHelperFMTS<int>(fmtss2,dts);
2043 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
2046 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
2048 return new MEDFileAnyTypeFieldMultiTSIterator(this);
2051 //= MEDFileFieldMultiTS
2053 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
2055 return new MEDFileFieldMultiTS(*this);
2059 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2060 * following the given input policy.
2062 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2063 * By default (true) the globals are deeply copied.
2064 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
2066 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
2068 MCAuto<MEDFileIntFieldMultiTS> ret;
2069 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
2072 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
2074 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2075 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
2076 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
2079 ret=MEDFileIntFieldMultiTS::New();
2081 ret->deepCpyGlobs(*this);
2083 ret->shallowCpyGlobs(*this);
2087 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2088 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
2091 catch(INTERP_KERNEL::Exception& e)
2094 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2095 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
2098 catch(INTERP_KERNEL::Exception& e)
2101 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
2105 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
2107 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
2110 //= MEDFileAnyTypeFieldMultiTSIterator
2112 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
2117 _nb_iter=fmts->getNumberOfTS();
2121 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
2125 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
2127 if(_iter_id<_nb_iter)
2129 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
2131 return fmts->getTimeStepAtPos(_iter_id++);
2139 //= MEDFileIntFieldMultiTS