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 extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype);
47 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
49 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
53 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
58 * \param [in] fieldId field id in C mode
60 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
62 med_field_type typcha;
63 std::string dtunitOut,meshName;
64 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
65 setMeshName(meshName);
66 setDtUnit(dtunitOut.c_str());
67 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
70 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)
71 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
73 setDtUnit(dtunit.c_str());
74 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
76 catch(INTERP_KERNEL::Exception& e)
81 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
83 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
84 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
85 ret+=(*it).capacity();
89 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
91 std::vector<const BigMemoryObject *> ret;
92 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
93 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
98 * 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
101 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
103 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
104 ret->setInfo(_infos);
105 int sz=(int)_time_steps.size();
106 for(const int *id=startIds;id!=endIds;id++)
110 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
111 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
115 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
117 ret->pushBackTimeStep(tse2);
121 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
122 oss << " ! Should be in [0," << sz << ") !";
123 throw INTERP_KERNEL::Exception(oss.str());
126 if(ret->getNumberOfTS()>0)
127 ret->synchronizeNameScope();
128 ret->copyNameScope(*this);
133 * 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
136 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
138 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
139 mcIdType nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
140 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
141 ret->setInfo(_infos);
142 std::size_t sz=_time_steps.size();
144 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
148 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
149 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
153 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
155 ret->pushBackTimeStep(tse2);
159 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
160 oss << " ! Should be in [0," << sz << ") !";
161 throw INTERP_KERNEL::Exception(oss.str());
164 if(ret->getNumberOfTS()>0)
165 ret->synchronizeNameScope();
166 ret->copyNameScope(*this);
170 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
173 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
174 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
176 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
179 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
180 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
181 ids->pushBackSilent(id);
183 return buildFromTimeStepIds(ids->begin(),ids->end());
186 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
189 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
190 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
192 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
195 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
196 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
197 ids->pushBackSilent(id);
199 return buildFromTimeStepIds(ids->begin(),ids->end());
202 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
204 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
205 if((*it).isNotNull())
206 if((*it)->presenceOfStructureElements())
211 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
213 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
214 if((*it).isNotNull())
215 if(!(*it)->onlyStructureElements())
220 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
222 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
223 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
224 if((*it).isNotNull())
226 if((*it)->presenceOfStructureElements())
228 if(!(*it)->onlyStructureElements())
230 (*it)->killStructureElements();
242 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
244 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
245 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
246 if((*it).isNotNull())
248 if((*it)->presenceOfStructureElements())
250 if(!(*it)->onlyStructureElements())
251 (*it)->keepOnlyStructureElements();
258 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
260 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
261 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
262 if((*it).isNotNull())
263 (*it)->keepOnlyOnSE(seName);
266 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
268 std::vector< std::pair<std::string,std::string> > ps2;
269 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
270 if((*it).isNotNull())
272 (*it)->getMeshSENames(ps2);
276 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
277 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
278 if((*it).isNotNull())
280 std::vector< std::pair<std::string,std::string> > ps3;
281 (*it)->getMeshSENames(ps3);
283 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
285 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
287 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
293 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
295 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
297 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
300 if(cur->presenceOfMultiDiscPerGeoType())
306 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
311 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
316 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
319 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
321 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
322 if(pt->isDealingTS(iteration,order))
325 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
326 std::vector< std::pair<int,int> > vp=getIterations();
327 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
328 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
329 throw INTERP_KERNEL::Exception(oss.str());
332 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
334 return *_time_steps[getTimeStepPos(iteration,order)];
337 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
339 return *_time_steps[getTimeStepPos(iteration,order)];
342 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
345 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
347 if((*it).first==getMeshName())
349 setMeshName((*it).second);
353 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
355 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
357 ret=cur->changeMeshNames(modifTab) || ret;
363 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
365 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
367 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
371 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
373 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
375 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
378 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<mcIdType>& oldCode, const std::vector<mcIdType>& newCode, const DataArrayIdType *renumO2N,
379 MEDFileFieldGlobsReal& glob)
382 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
384 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
386 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
391 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
393 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
394 if((*it).isNotNull())
396 visitor.newTimeStepEntry(*it);
397 (*it)->accept(visitor);
398 visitor.endTimeStepEntry(*it);
402 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
404 std::string startLine(bkOffset,' ');
405 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
407 oss << " (" << fmtsId << ")";
408 oss << " has the following name: \"" << _name << "\"." << std::endl;
409 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
410 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
412 oss << startLine << " - \"" << *it << "\"" << std::endl;
415 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
417 std::string chapter(17,'0'+i);
418 oss << startLine << chapter << std::endl;
419 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
421 cur->simpleRepr(bkOffset+2,oss,i);
423 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
424 oss << startLine << chapter << std::endl;
428 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
430 std::size_t sz=_time_steps.size();
431 std::vector< std::pair<int,int> > ret(sz);
433 for(std::size_t i=0;i<sz;i++)
435 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
438 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
442 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
443 throw INTERP_KERNEL::Exception(oss.str());
449 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
451 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
453 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
454 checkCoherencyOfType(tse2);
455 if(_time_steps.empty())
457 setName(tse2->getName());
458 setMeshName(tse2->getMeshName());
459 setInfo(tse2->getInfo());
461 checkThatComponentsMatch(tse2->getInfo());
462 if(getDtUnit().empty() && !tse->getDtUnit().empty())
463 setDtUnit(tse->getDtUnit());
464 _time_steps.push_back(tse);
467 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
469 std::size_t nbOfCompo=_infos.size();
470 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
472 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
475 if((cur->getInfo()).size()!=nbOfCompo)
477 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
478 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
479 throw INTERP_KERNEL::Exception(oss.str());
481 cur->copyNameScope(*this);
486 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
488 _time_steps.resize(nbPdt);
490 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entitiesFast;
491 const MEDFileEntities *entitiesForSubInstances(entities);
492 MEDFileCapability mfcap(fid);
493 if( ( !entities || entities->areAllStaticPresentAndNoDyn() ) && mfcap.isFastReader())
495 int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT));
496 INTERP_KERNEL::AutoPtr<med_entity_type> types(new med_entity_type[nentitype]);
498 MEDFILESAFECALLERRD0(MEDfieldEntityType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types,&usedbyncs));
499 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > entitiesFastP;
500 for(int i=0;i<nentitype;i++)
502 int ngeotype(MEDfieldnGeometryType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i]));
503 INTERP_KERNEL::AutoPtr<med_geometry_type> geotypes(new med_geometry_type[ngeotype]);
504 med_int geousedbyncs;
505 MEDFILESAFECALLERRD0(MEDfieldGeometryType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i],geotypes,&geousedbyncs));
506 for(int j=0;j<ngeotype;j++)
508 std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j]));
509 entitiesFastP.push_back(p);
512 entitiesFast=new MEDFileStaticEntities(entitiesFastP);
513 entitiesForSubInstances=entitiesFast;
515 for(int i=0;i<nbPdt;i++)
517 std::vector< std::pair<int,int> > ts;
518 med_int numdt=0,numo=0;
520 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
525 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
530 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
535 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
540 if(sizeof(med_int)==sizeof(int))
542 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
547 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
550 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entitiesForSubInstances);
552 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entitiesForSubInstances,&mfcap);
554 synchronizeNameScope();
557 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
559 if(_time_steps.empty())
560 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
561 checkThatNbOfCompoOfTSMatchThis();
562 std::vector<std::string> infos(getInfo());
563 std::size_t nbComp=infos.size();
564 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
565 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
566 for(unsigned int i=0;i<nbComp;i++)
568 std::string info=infos[i];
570 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
571 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
572 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
575 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
576 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),ToMedInt(nbComp),comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
577 std::size_t nbOfTS=_time_steps.size();
578 for(std::size_t i=0;i<nbOfTS;i++)
579 _time_steps[i]->writeLL(fid,opts,*this);
582 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
584 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
586 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
588 elt->loadBigArraysRecursively(fid,nasc);
592 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
594 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
596 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
598 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
602 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
604 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
606 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
612 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
614 return (int)_time_steps.size();
617 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
619 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
620 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
622 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
624 newTS.push_back(*it);
629 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
631 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
632 int maxId=(int)_time_steps.size();
634 std::set<int> idsToDel;
635 for(const int *id=startIds;id!=endIds;id++,ii++)
637 if(*id>=0 && *id<maxId)
639 idsToDel.insert(*id);
643 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
644 throw INTERP_KERNEL::Exception(oss.str());
647 for(int iii=0;iii<maxId;iii++)
648 if(idsToDel.find(iii)==idsToDel.end())
649 newTS.push_back(_time_steps[iii]);
653 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
655 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
656 mcIdType nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
657 if(nbOfEntriesToKill==0)
659 std::size_t sz=_time_steps.size();
660 std::vector<bool> b(sz,true);
662 for(mcIdType i=0;i<nbOfEntriesToKill;i++,j+=step)
664 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
665 for(std::size_t i=0;i<sz;i++)
667 newTS.push_back(_time_steps[i]);
671 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
674 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
675 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
677 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
681 tmp->getTime(it2,ord);
682 if(it2==iteration && order==ord)
685 oss << "(" << it2 << "," << ord << "), ";
688 throw INTERP_KERNEL::Exception(oss.str());
691 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
694 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
696 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
698 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
702 double ti=tmp->getTime(it2,ord);
703 if(fabs(time-ti)<eps)
709 throw INTERP_KERNEL::Exception(oss.str());
712 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
714 std::size_t lgth=_time_steps.size();
715 std::vector< std::pair<int,int> > ret(lgth);
716 for(std::size_t i=0;i<lgth;i++)
717 _time_steps[i]->fillIteration(ret[i]);
722 * 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'
723 * This method returns two things.
724 * - The absolute dimension of 'this' in first parameter.
725 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
726 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
728 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
729 * Only these 3 discretizations will be taken into account here.
731 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
732 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
733 * case the caller has to know the underlying mesh it refers to. By default it is the level 0 of the corresponding mesh.
735 * This method is useful to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
736 * 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'.
738 * Let's consider the typical following case :
739 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
740 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
741 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
743 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
745 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
747 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
748 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
749 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
750 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
752 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
754 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
757 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
759 if(pos<0 || pos>=(int)_time_steps.size())
761 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
762 throw INTERP_KERNEL::Exception(oss.str());
764 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
767 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
768 oss << "\nTry to use following method eraseEmptyTS !";
769 throw INTERP_KERNEL::Exception(oss.str());
774 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
776 if(pos<0 || pos>=(int)_time_steps.size())
778 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
779 throw INTERP_KERNEL::Exception(oss.str());
781 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
784 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
785 oss << "\nTry to use following method eraseEmptyTS !";
786 throw INTERP_KERNEL::Exception(oss.str());
791 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
793 std::vector<std::string> ret;
794 std::set<std::string> ret2;
795 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
797 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
798 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
799 if(ret2.find(*it2)==ret2.end())
808 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
810 std::vector<std::string> ret;
811 std::set<std::string> ret2;
812 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
814 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
815 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
816 if(ret2.find(*it2)==ret2.end())
825 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
827 std::vector<std::string> ret;
828 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
830 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
831 ret.insert(ret.end(),tmp.begin(),tmp.end());
836 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
838 std::vector<std::string> ret;
839 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
841 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
842 ret.insert(ret.end(),tmp.begin(),tmp.end());
847 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
849 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
850 (*it)->changePflsRefsNamesGen2(mapOfModif);
853 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
855 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
856 (*it)->changeLocsRefsNamesGen2(mapOfModif);
859 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
861 std::size_t lgth=_time_steps.size();
862 std::vector< std::vector<TypeOfField> > ret(lgth);
863 for(std::size_t i=0;i<lgth;i++)
864 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
869 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
871 std::vector< std::vector< std::pair<mcIdType,mcIdType> > > 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
873 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
876 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
878 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
880 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
882 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
883 ret->_time_steps[i]=(*it)->deepCopy();
888 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
890 std::size_t sz(_infos.size()),sz2(_time_steps.size());
891 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
892 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
893 for(std::size_t i=0;i<sz;i++)
896 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
898 for(std::size_t i=0;i<sz2;i++)
900 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
903 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
904 throw INTERP_KERNEL::Exception(oss.str());
908 for(std::size_t i=0;i<sz;i++)
909 for(std::size_t j=0;j<sz2;j++)
910 ret[i]->_time_steps[j]=ts[j][i];
915 * This method splits into discretization each time steps in \a this.
916 * ** WARNING ** the returned instances are not compulsory defined on the same time steps series !
918 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
920 std::size_t sz(_time_steps.size());
921 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
922 for(std::size_t i=0;i<sz;i++)
924 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
927 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
928 throw INTERP_KERNEL::Exception(oss.str());
930 items[i]=timeStep->splitDiscretizations();
933 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
934 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
935 std::vector< TypeOfField > types;
936 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
937 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
939 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
941 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
942 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
944 types.push_back(ts[0]);
946 ret.resize(types.size()); ret2.resize(types.size());
947 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
948 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
950 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
951 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
952 ret2[pos].push_back(*it1);
954 for(std::size_t i=0;i<types.size();i++)
956 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
957 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
958 elt->pushBackTimeStep(*it1);//also updates infos in elt
960 elt->MEDFileFieldNameScope::operator=(*this);
966 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
968 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
970 std::size_t sz(_time_steps.size());
971 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
972 std::size_t szOut(std::numeric_limits<std::size_t>::max());
973 for(std::size_t i=0;i<sz;i++)
975 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
978 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
979 throw INTERP_KERNEL::Exception(oss.str());
981 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
982 if(szOut==std::numeric_limits<std::size_t>::max())
983 szOut=items[i].size();
985 if(items[i].size()!=szOut)
986 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
988 if(szOut==std::numeric_limits<std::size_t>::max())
989 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
990 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
991 for(std::size_t i=0;i<szOut;i++)
993 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
994 for(std::size_t j=0;j<sz;j++)
995 elt->pushBackTimeStep(items[j][i]);
997 elt->MEDFileFieldNameScope::operator=(*this);
1002 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
1004 setName(field->getName());
1005 if(field->getMesh())
1006 setMeshName(field->getMesh()->getName());
1008 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
1010 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
1011 _infos=arr->getInfoOnComponents();
1014 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
1016 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
1017 if(_name!=field->getName())
1019 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
1020 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
1021 throw INTERP_KERNEL::Exception(oss.str());
1024 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
1025 checkThatComponentsMatch(arr->getInfoOnComponents());
1028 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
1030 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
1031 if(getInfo().size()!=compos.size())
1033 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
1034 oss << " number of components of element to append (" << compos.size() << ") !";
1035 throw INTERP_KERNEL::Exception(oss.str());
1039 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
1040 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
1041 oss << " But compo in input fields are : ";
1042 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
1044 throw INTERP_KERNEL::Exception(oss.str());
1048 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
1050 std::size_t sz=_infos.size();
1052 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
1054 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
1056 if(elt->getInfo().size()!=sz)
1058 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
1059 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
1060 throw INTERP_KERNEL::Exception(oss.str());
1065 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1068 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1069 if(!_time_steps.empty())
1070 checkCoherencyOfTinyInfo(field,arr);
1071 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(createNew1TSWithoutSDAEmptyInstance());
1073 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
1074 obj->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
1076 copyTinyInfoFrom(field,arr);
1077 _time_steps.push_back(obj);
1080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, MEDFileFieldGlobsReal& glob, bool smartPflKiller)
1083 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1084 if(!_time_steps.empty())
1085 checkCoherencyOfTinyInfo(field,arr);
1086 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(createNew1TSWithoutSDAEmptyInstance());
1088 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
1089 obj->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this,smartPflKiller);
1091 copyTinyInfoFrom(field,arr);
1092 setMeshName(obj->getMeshName());
1093 _time_steps.push_back(obj);
1096 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
1098 int sz=(int)_time_steps.size();
1101 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
1102 throw INTERP_KERNEL::Exception(oss.str());
1104 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
1107 if(tsPtr->getNumberOfComponents()!=_infos.size())
1109 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
1110 throw INTERP_KERNEL::Exception(oss.str());
1116 //= MEDFileFieldMultiTSWithoutSDA
1119 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
1120 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
1122 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
1124 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
1125 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
1127 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
1128 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
1131 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
1133 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
1134 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
1136 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
1138 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
1141 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
1143 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
1144 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
1145 ret->setIteration(i,elt);
1151 //= MEDFileAnyTypeFieldMultiTS
1153 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
1157 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1158 try:MEDFileFieldGlobsReal(fid)
1160 _content=BuildContentFrom(fid,loadAll,ms);
1163 catch(INTERP_KERNEL::Exception& e)
1168 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1170 med_field_type typcha;
1171 std::vector<std::string> infos;
1173 std::string meshName;
1175 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
1176 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1181 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1186 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1191 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1196 if(sizeof(med_int)==sizeof(int))
1198 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1204 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] !";
1205 throw INTERP_KERNEL::Exception(oss.str());
1208 ret->setMeshName(meshName);
1209 ret->setDtUnit(dtunit.c_str());
1213 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1215 med_field_type typcha;
1217 std::vector<std::string> infos;
1218 std::string dtunit,fieldName,meshName;
1219 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1220 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1225 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1230 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1235 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1240 if(sizeof(med_int)==sizeof(int))
1242 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1248 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] !";
1249 throw INTERP_KERNEL::Exception(oss.str());
1252 ret->setMeshName(meshName);
1253 ret->setDtUnit(dtunit.c_str());
1257 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
1260 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1261 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
1263 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1264 ret->_content=c; c->incrRef();
1267 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
1269 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
1270 ret->_content=c; c->incrRef();
1273 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
1275 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1276 ret->_content=c; c->incrRef();
1279 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1282 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
1284 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
1285 std::string fileName(FileNameFromFID(fid));
1286 ret->setFileName(fileName);
1290 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1291 try:MEDFileFieldGlobsReal(fid)
1293 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1296 catch(INTERP_KERNEL::Exception& e)
1301 //= MEDFileAnyTypeFieldMultiTS
1304 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
1305 * that has been read from a specified MED file.
1306 * \param [in] fileName - the name of the MED file to read.
1307 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1308 * is to delete this field using decrRef() as it is no more needed.
1309 * \throw If reading the file fails.
1311 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
1313 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1314 return New(fid,loadAll);
1317 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
1319 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
1320 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1321 ret->loadGlobals(fid);
1326 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
1327 * that has been read from a specified MED file.
1328 * \param [in] fileName - the name of the MED file to read.
1329 * \param [in] fieldName - the name of the field to read.
1330 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1331 * is to delete this field using decrRef() as it is no more needed.
1332 * \throw If reading the file fails.
1333 * \throw If there is no field named \a fieldName in the file.
1335 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1337 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1338 return New(fid,fieldName,loadAll);
1341 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1343 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1344 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1345 ret->loadGlobals(fid);
1350 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1351 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1353 * \warning this is a shallow copy constructor
1355 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
1357 if(!shallowCopyOfContent)
1359 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
1360 otherPtr->incrRef();
1361 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
1365 _content=other.shallowCpy();
1369 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
1371 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1373 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
1377 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
1379 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1381 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
1385 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
1387 return contentNotNullBase()->getPflsReallyUsed2();
1390 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
1392 return contentNotNullBase()->getLocsReallyUsed2();
1395 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
1397 return contentNotNullBase()->getPflsReallyUsedMulti2();
1400 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
1402 return contentNotNullBase()->getLocsReallyUsedMulti2();
1405 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1407 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
1410 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1412 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
1415 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
1417 return contentNotNullBase()->getNumberOfTS();
1420 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
1422 contentNotNullBase()->eraseEmptyTS();
1425 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
1427 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
1430 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
1432 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
1435 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
1437 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
1438 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1443 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
1445 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
1446 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1451 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
1453 return contentNotNullBase()->getIterations();
1456 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
1458 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
1459 pushBackTimeStep(*it);
1462 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
1465 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
1466 int nbOfTS(fmts->getNumberOfTS());
1467 for(int i=0;i<nbOfTS;i++)
1469 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
1470 pushBackTimeStep(elt);
1474 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
1477 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
1478 checkCoherencyOfType(f1ts);
1480 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
1481 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
1483 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
1484 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
1485 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
1486 _content->pushBackTimeStep(cSafe);
1487 appendGlobs(*f1ts,1e-12);
1490 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
1492 contentNotNullBase()->synchronizeNameScope();
1495 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
1497 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
1500 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
1502 return contentNotNullBase()->getPosGivenTime(time,eps);
1505 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
1507 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
1510 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
1512 return contentNotNullBase()->getTypesOfFieldAvailable();
1515 std::vector< std::vector< std::pair<mcIdType,mcIdType> > > 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
1517 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1520 std::string MEDFileAnyTypeFieldMultiTS::getName() const
1522 return contentNotNullBase()->getName();
1525 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
1527 contentNotNullBase()->setName(name);
1530 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
1532 return contentNotNullBase()->getDtUnit();
1535 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
1537 contentNotNullBase()->setDtUnit(dtUnit);
1540 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
1542 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
1545 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
1547 return contentNotNullBase()->getTimeSteps(ret1);
1550 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
1552 return contentNotNullBase()->getMeshName();
1555 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
1557 contentNotNullBase()->setMeshName(newMeshName);
1560 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1562 return contentNotNullBase()->changeMeshNames(modifTab);
1565 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
1567 return contentNotNullBase()->getInfo();
1570 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
1572 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
1575 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
1577 return contentNotNullBase()->setInfo(info);
1580 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
1582 const std::vector<std::string> ret=getInfo();
1583 return (int)ret.size();
1586 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
1588 writeGlobals(fid,*this);
1589 contentNotNullBase()->writeLL(fid,*this);
1593 * This method alloc the arrays and load potentially huge arrays contained in this field.
1594 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
1595 * This method can be also called to refresh or reinit values from a file.
1597 * \throw If the fileName is not set or points to a non readable MED file.
1599 void MEDFileAnyTypeFieldMultiTS::loadArrays()
1601 if(getFileName().empty())
1602 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
1603 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1604 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
1608 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
1609 * But once data loaded once, this method does nothing.
1611 * \throw If the fileName is not set or points to a non readable MED file.
1612 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
1614 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
1616 if(!getFileName().empty())
1618 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1619 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
1624 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
1625 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
1626 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
1628 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
1630 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
1632 contentNotNullBase()->unloadArrays();
1636 * 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.
1637 * This method is the symmetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
1638 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
1640 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
1642 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
1644 if(!getFileName().empty())
1645 contentNotNullBase()->unloadArrays();
1648 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
1650 std::ostringstream oss;
1651 contentNotNullBase()->simpleRepr(0,oss,-1);
1652 simpleReprGlobs(oss);
1656 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
1658 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
1661 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
1663 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
1664 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
1669 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
1670 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
1671 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
1673 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
1675 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1677 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
1678 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
1679 std::size_t sz(contentsSplit.size());
1680 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1681 for(std::size_t i=0;i<sz;i++)
1683 ret[i]=shallowCpy();
1684 ret[i]->_content=contentsSplit[i];
1690 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
1691 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1693 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
1695 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1697 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
1698 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
1699 std::size_t sz(contentsSplit.size());
1700 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1701 for(std::size_t i=0;i<sz;i++)
1703 ret[i]=shallowCpy();
1704 ret[i]->_content=contentsSplit[i];
1710 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
1711 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1713 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
1715 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1717 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
1718 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
1719 std::size_t sz(contentsSplit.size());
1720 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1721 for(std::size_t i=0;i<sz;i++)
1723 ret[i]=shallowCpy();
1724 ret[i]->_content=contentsSplit[i];
1729 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
1731 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1732 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
1733 ret->_content=_content->deepCopy();
1734 ret->deepCpyGlobs(*this);
1738 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
1744 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1745 * \param [in] iteration - the iteration number of a required time step.
1746 * \param [in] order - the iteration order number of required time step.
1747 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
1748 * delete this field using decrRef() as it is no more needed.
1749 * \throw If there is no required time step in \a this field.
1751 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
1753 int pos=getPosOfTimeStep(iteration,order);
1754 return getTimeStepAtPos(pos);
1758 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1759 * \param [in] time - the time of the time step of interest.
1760 * \param [in] eps - a precision used to compare time values.
1761 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
1762 * delete this field using decrRef() as it is no more needed.
1763 * \throw If there is no required time step in \a this field.
1765 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
1767 int pos=getPosGivenTime(time,eps);
1768 return getTimeStepAtPos(pos);
1772 * 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.
1773 * The float64 value of time attached to the pair of integers are not considered here.
1774 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
1776 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
1777 * \throw If there is a null pointer in \a vectFMTS.
1779 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
1781 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
1782 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1783 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1784 while(!lstFMTS.empty())
1786 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1787 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1789 throw INTERP_KERNEL::Exception(msg);
1790 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
1791 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1792 elt.push_back(curIt); it=lstFMTS.erase(it);
1793 while(it!=lstFMTS.end())
1797 throw INTERP_KERNEL::Exception(msg);
1798 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
1800 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1810 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
1811 * All returned instances in a subvector can be safely loaded, rendered along time
1812 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
1813 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
1814 * 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).
1815 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
1816 * 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.
1818 * \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().
1819 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
1820 * \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.
1821 * \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.
1823 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
1824 * \throw If an element in \a vectFMTS change of spatial discretization along time.
1825 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
1826 * \thorw If some elements in \a vectFMTS do not have the same times steps.
1827 * \throw If mesh is null.
1828 * \throw If an element in \a vectFMTS is null.
1829 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
1831 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
1833 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
1835 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
1836 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1837 if(vectFMTS.empty())
1839 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
1840 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
1842 throw INTERP_KERNEL::Exception(msg);
1844 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
1845 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
1846 for(;it!=vectFMTS.end();it++,i++)
1849 throw INTERP_KERNEL::Exception(msg);
1850 TypeOfField tof0,tof1;
1851 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
1854 vectFMTSNotNodes.push_back(*it);
1856 vectFMTSNodes.push_back(*it);
1859 vectFMTSNotNodes.push_back(*it);
1861 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
1862 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
1864 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
1867 bool isFetched(false);
1868 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
1871 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
1872 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
1873 { ret[i].push_back(*it2); isFetched=true; }
1877 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
1878 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
1879 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
1887 * 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.
1888 * \param [out] cmps - same size than the returned vector.
1890 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
1892 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1893 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1894 while(!lstFMTS.empty())
1896 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1897 MEDFileAnyTypeFieldMultiTS *ref(*it);
1898 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1899 elt.push_back(ref); it=lstFMTS.erase(it);
1900 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
1901 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
1902 while(it!=lstFMTS.end())
1904 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1905 if(cmp->isEqual(curIt))
1906 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1910 ret.push_back(elt); cmps.push_back(cmp);
1916 * 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.
1917 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
1919 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
1920 * \throw If \a f0 or \a f1 change of spatial discretization along time.
1921 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
1922 * \thorw If \a f0 and \a f1 do not have the same times steps.
1923 * \throw If mesh is null.
1924 * \throw If \a f0 or \a f1 is null.
1925 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
1927 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
1930 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
1932 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
1933 if(f0->getMeshName()!=mesh->getName())
1935 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1936 throw INTERP_KERNEL::Exception(oss.str());
1938 if(f1->getMeshName()!=mesh->getName())
1940 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1941 throw INTERP_KERNEL::Exception(oss.str());
1943 int nts=f0->getNumberOfTS();
1944 if(nts!=f1->getNumberOfTS())
1945 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
1948 for(int i=0;i<nts;i++)
1950 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
1951 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
1952 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
1953 if(tofs0.size()!=1 || tofs1.size()!=1)
1954 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
1957 if(tof0!=tofs0[0] || tof1!=tofs1[0])
1958 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
1961 { tof0=tofs0[0]; tof1=tofs1[0]; }
1962 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
1964 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() << ") !";
1965 throw INTERP_KERNEL::Exception(oss.str());
1967 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
1969 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() << ") !";
1970 throw INTERP_KERNEL::Exception(oss.str());
1972 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
1974 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() << ") !";
1975 throw INTERP_KERNEL::Exception(oss.str());
1982 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
1984 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
1986 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
1987 std::size_t sz(f1tss.size()),i(0);
1988 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
1989 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
1991 typename MLFieldTraits<T>::F1TSType const *elt(*it);
1993 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
1994 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
1996 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
1998 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
1999 retc->aggregate(f1tsw,dts);
2000 ret->setDtUnit(f1tss[0]->getDtUnit());
2001 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
2005 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2007 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
2009 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
2010 std::size_t sz(fmtss.size());
2011 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2013 typename MLFieldTraits<T>::FMTSType const *elt(*it);
2015 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
2017 int nbTS(fmtss[0]->getNumberOfTS());
2018 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2019 if((*it)->getNumberOfTS()!=nbTS)
2020 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
2021 for(int iterTS=0;iterTS<nbTS;iterTS++)
2024 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
2025 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
2026 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
2027 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
2028 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
2029 ret->pushBackTimeStep(f1ts);
2030 ret->setDtUnit(f1ts->getDtUnit());
2032 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
2036 * \a dts and \a ftmss are expected to have same size.
2038 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2041 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
2042 std::size_t sz(fmtss.size());
2043 std::vector<const MEDFileFieldMultiTS *> fmtss1;
2044 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
2045 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2048 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
2049 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
2052 fmtss1.push_back(elt1);
2055 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
2058 fmtss2.push_back(elt2);
2061 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
2063 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
2064 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
2065 if(fmtss1.size()==sz)
2066 return AggregateHelperFMTS<double>(fmtss1,dts);
2067 if(fmtss2.size()!=sz)
2068 return AggregateHelperFMTS<int>(fmtss2,dts);
2069 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
2072 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
2074 return new MEDFileAnyTypeFieldMultiTSIterator(this);
2077 //= MEDFileFieldMultiTS
2079 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
2081 return new MEDFileFieldMultiTS(*this);
2085 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2086 * following the given input policy.
2088 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2089 * By default (true) the globals are deeply copied.
2090 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
2092 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
2094 MCAuto<MEDFileIntFieldMultiTS> ret;
2095 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
2098 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
2100 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2101 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
2102 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
2105 ret=MEDFileIntFieldMultiTS::New();
2107 ret->deepCpyGlobs(*this);
2109 ret->shallowCpyGlobs(*this);
2113 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2114 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
2117 catch(INTERP_KERNEL::Exception& e)
2120 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2121 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
2124 catch(INTERP_KERNEL::Exception& e)
2127 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
2131 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
2133 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
2136 //= MEDFileAnyTypeFieldMultiTSIterator
2138 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
2143 _nb_iter=fmts->getNumberOfTS();
2147 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
2151 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
2153 if(_iter_id<_nb_iter)
2155 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
2157 return fmts->getTimeStepAtPos(_iter_id++);
2165 //= MEDFileIntFieldMultiTS