1 // Copyright (C) 2017-2021 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<Int32>;
35 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<Int64>;
36 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<float>;
37 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<double>;
38 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<Int32>;
39 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<Int64>;
40 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<float>;
41 template class MEDCoupling::MEDFileTemplateFieldMultiTS<Int32>;
42 template class MEDCoupling::MEDFileTemplateFieldMultiTS<Int64>;
43 template class MEDCoupling::MEDFileTemplateFieldMultiTS<float>;
44 template class MEDCoupling::MEDFileTemplateFieldMultiTS<double>;
45 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<Int32>;
46 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<Int64>;
47 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<float>;
49 extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype);
51 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
53 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
57 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
62 * \param [in] fieldId field id in C mode
64 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
66 med_field_type typcha;
67 std::string dtunitOut,meshName;
68 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
69 setMeshName(meshName);
70 setDtUnit(dtunitOut.c_str());
71 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
74 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)
75 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
77 setDtUnit(dtunit.c_str());
78 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
80 catch(INTERP_KERNEL::Exception& e)
85 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
87 std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
88 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
89 ret+=(*it).capacity();
93 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
95 std::vector<const BigMemoryObject *> ret;
96 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
97 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
102 * 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
105 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
107 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
108 ret->setInfo(_infos);
109 int sz=(int)_time_steps.size();
110 for(const int *id=startIds;id!=endIds;id++)
114 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
115 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
119 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
121 ret->pushBackTimeStep(tse2);
125 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
126 oss << " ! Should be in [0," << sz << ") !";
127 throw INTERP_KERNEL::Exception(oss.str());
130 if(ret->getNumberOfTS()>0)
131 ret->synchronizeNameScope();
132 ret->copyNameScope(*this);
137 * 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
140 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
142 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
143 mcIdType nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
144 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
145 ret->setInfo(_infos);
146 std::size_t sz=_time_steps.size();
148 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
152 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
153 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
157 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
159 ret->pushBackTimeStep(tse2);
163 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
164 oss << " ! Should be in [0," << sz << ") !";
165 throw INTERP_KERNEL::Exception(oss.str());
168 if(ret->getNumberOfTS()>0)
169 ret->synchronizeNameScope();
170 ret->copyNameScope(*this);
174 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
177 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
178 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
180 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
183 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
184 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
185 ids->pushBackSilent(id);
187 return buildFromTimeStepIds(ids->begin(),ids->end());
190 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
193 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
194 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
196 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
199 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
200 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
201 ids->pushBackSilent(id);
203 return buildFromTimeStepIds(ids->begin(),ids->end());
206 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
208 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
209 if((*it).isNotNull())
210 if((*it)->presenceOfStructureElements())
215 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
217 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
218 if((*it).isNotNull())
219 if(!(*it)->onlyStructureElements())
224 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
226 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
227 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
228 if((*it).isNotNull())
230 if((*it)->presenceOfStructureElements())
232 if(!(*it)->onlyStructureElements())
234 (*it)->killStructureElements();
246 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
248 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
249 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
250 if((*it).isNotNull())
252 if((*it)->presenceOfStructureElements())
254 if(!(*it)->onlyStructureElements())
255 (*it)->keepOnlyStructureElements();
262 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
264 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
265 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
266 if((*it).isNotNull())
267 (*it)->keepOnlyOnSE(seName);
270 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
272 std::vector< std::pair<std::string,std::string> > ps2;
273 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
274 if((*it).isNotNull())
276 (*it)->getMeshSENames(ps2);
280 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
281 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
282 if((*it).isNotNull())
284 std::vector< std::pair<std::string,std::string> > ps3;
285 (*it)->getMeshSENames(ps3);
287 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
289 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
291 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
297 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
299 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
301 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
304 if(cur->presenceOfMultiDiscPerGeoType())
310 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
315 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
320 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
323 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
325 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
326 if(pt->isDealingTS(iteration,order))
329 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
330 std::vector< std::pair<int,int> > vp=getIterations();
331 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
332 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
333 throw INTERP_KERNEL::Exception(oss.str());
336 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
338 return *_time_steps[getTimeStepPos(iteration,order)];
341 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
343 return *_time_steps[getTimeStepPos(iteration,order)];
346 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
349 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
351 if((*it).first==getMeshName())
353 setMeshName((*it).second);
357 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
359 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
361 ret=cur->changeMeshNames(modifTab) || ret;
367 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
369 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
371 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
375 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
377 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
379 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
382 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<mcIdType>& oldCode, const std::vector<mcIdType>& newCode, const DataArrayIdType *renumO2N,
383 MEDFileFieldGlobsReal& glob)
386 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
388 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
390 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
395 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
397 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
398 if((*it).isNotNull())
400 visitor.newTimeStepEntry(*it);
401 (*it)->accept(visitor);
402 visitor.endTimeStepEntry(*it);
406 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
408 std::string startLine(bkOffset,' ');
409 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
411 oss << " (" << fmtsId << ")";
412 oss << " has the following name: \"" << _name << "\"." << std::endl;
413 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
414 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
416 oss << startLine << " - \"" << *it << "\"" << std::endl;
419 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
421 std::string chapter(17,(char)('0'+i));
422 oss << startLine << chapter << std::endl;
423 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
425 cur->simpleRepr(bkOffset+2,oss,i);
427 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
428 oss << startLine << chapter << std::endl;
432 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
434 std::size_t sz=_time_steps.size();
435 std::vector< std::pair<int,int> > ret(sz);
437 for(std::size_t i=0;i<sz;i++)
439 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
442 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
446 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
447 throw INTERP_KERNEL::Exception(oss.str());
453 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
455 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
457 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
458 checkCoherencyOfType(tse2);
459 if(_time_steps.empty())
461 setName(tse2->getName());
462 setMeshName(tse2->getMeshName());
463 setInfo(tse2->getInfo());
465 checkThatComponentsMatch(tse2->getInfo());
466 if(getDtUnit().empty() && !tse->getDtUnit().empty())
467 setDtUnit(tse->getDtUnit());
468 _time_steps.push_back(tse);
471 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
473 std::size_t nbOfCompo=_infos.size();
474 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
476 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
479 if((cur->getInfo()).size()!=nbOfCompo)
481 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
482 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
483 throw INTERP_KERNEL::Exception(oss.str());
485 cur->copyNameScope(*this);
490 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
492 _time_steps.resize(nbPdt);
494 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entitiesFast;
495 const MEDFileEntities *entitiesForSubInstances(entities);
496 MEDFileCapability mfcap(fid);
497 if( ( !entities || entities->areAllStaticPresentAndNoDyn() ) && mfcap.isFastReader())
499 med_int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT));
500 INTERP_KERNEL::AutoPtr<med_entity_type> types(new med_entity_type[nentitype]);
502 MEDFILESAFECALLERRD0(MEDfieldEntityType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types,&usedbyncs));
503 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > entitiesFastP;
504 for(int i=0;i<nentitype;i++)
506 med_int ngeotype(MEDfieldnGeometryType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i]));
507 INTERP_KERNEL::AutoPtr<med_geometry_type> geotypes(new med_geometry_type[ngeotype]);
508 med_int geousedbyncs;
509 MEDFILESAFECALLERRD0(MEDfieldGeometryType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i],geotypes,&geousedbyncs));
510 for(med_int j=0;j<ngeotype;j++)
512 std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j]));
513 entitiesFastP.push_back(p);
516 entitiesFast=new MEDFileStaticEntities(entitiesFastP);
517 entitiesForSubInstances=entitiesFast;
519 for(int i=0;i<nbPdt;i++)
521 std::vector< std::pair<int,int> > ts;
522 med_int numdt=0,numo=0;
524 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
529 _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
534 _time_steps[i]=MEDFileInt32Field1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
539 _time_steps[i]=MEDFileInt64Field1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
544 _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
549 if(sizeof(med_int)==sizeof(int))
551 _time_steps[i]=MEDFileInt32Field1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt<int>(numdt),FromMedInt<int>(numo),_infos);
556 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32, INT64 !");
559 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entitiesForSubInstances);
561 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entitiesForSubInstances,&mfcap);
563 synchronizeNameScope();
566 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
568 if(_time_steps.empty())
569 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
570 checkThatNbOfCompoOfTSMatchThis();
571 std::vector<std::string> infos(getInfo());
572 std::size_t nbComp=infos.size();
573 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
574 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
575 for(unsigned int i=0;i<nbComp;i++)
577 std::string info=infos[i];
579 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
580 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
581 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
584 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
585 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),ToMedInt(nbComp),comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
586 std::size_t nbOfTS=_time_steps.size();
587 for(std::size_t i=0;i<nbOfTS;i++)
588 _time_steps[i]->writeLL(fid,opts,*this);
591 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
593 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
595 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
597 elt->loadBigArraysRecursively(fid,nasc);
601 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
603 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
605 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
607 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
611 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
613 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
615 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
621 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
623 return (int)_time_steps.size();
626 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
628 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
629 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
631 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
633 newTS.push_back(*it);
638 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
640 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
641 int maxId=(int)_time_steps.size();
643 std::set<int> idsToDel;
644 for(const int *id=startIds;id!=endIds;id++,ii++)
646 if(*id>=0 && *id<maxId)
648 idsToDel.insert(*id);
652 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
653 throw INTERP_KERNEL::Exception(oss.str());
656 for(int iii=0;iii<maxId;iii++)
657 if(idsToDel.find(iii)==idsToDel.end())
658 newTS.push_back(_time_steps[iii]);
662 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
664 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
665 mcIdType nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
666 if(nbOfEntriesToKill==0)
668 std::size_t sz=_time_steps.size();
669 std::vector<bool> b(sz,true);
671 for(mcIdType i=0;i<nbOfEntriesToKill;i++,j+=step)
673 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
674 for(std::size_t i=0;i<sz;i++)
676 newTS.push_back(_time_steps[i]);
680 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
683 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
684 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
686 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
690 tmp->getTime(it2,ord);
691 if(it2==iteration && order==ord)
694 oss << "(" << it2 << "," << ord << "), ";
697 throw INTERP_KERNEL::Exception(oss.str());
700 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
703 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
705 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
707 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
711 double ti=tmp->getTime(it2,ord);
712 if(fabs(time-ti)<eps)
718 throw INTERP_KERNEL::Exception(oss.str());
721 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
723 std::size_t lgth=_time_steps.size();
724 std::vector< std::pair<int,int> > ret(lgth);
725 for(std::size_t i=0;i<lgth;i++)
726 _time_steps[i]->fillIteration(ret[i]);
731 * 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'
732 * This method returns two things.
733 * - The absolute dimension of 'this' in first parameter.
734 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
735 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
737 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
738 * Only these 3 discretizations will be taken into account here.
740 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
741 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
742 * case the caller has to know the underlying mesh it refers to. By default it is the level 0 of the corresponding mesh.
744 * This method is useful to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
745 * 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'.
747 * Let's consider the typical following case :
748 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
749 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
750 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
752 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
754 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
756 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
757 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
758 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
759 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
761 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
763 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
766 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
768 if(pos<0 || pos>=(int)_time_steps.size())
770 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
771 throw INTERP_KERNEL::Exception(oss.str());
773 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
776 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
777 oss << "\nTry to use following method eraseEmptyTS !";
778 throw INTERP_KERNEL::Exception(oss.str());
783 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
785 if(pos<0 || pos>=(int)_time_steps.size())
787 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
788 throw INTERP_KERNEL::Exception(oss.str());
790 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
793 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
794 oss << "\nTry to use following method eraseEmptyTS !";
795 throw INTERP_KERNEL::Exception(oss.str());
800 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
802 std::vector<std::string> ret;
803 std::set<std::string> ret2;
804 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
806 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
807 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
808 if(ret2.find(*it2)==ret2.end())
817 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
819 std::vector<std::string> ret;
820 std::set<std::string> ret2;
821 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
823 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
824 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
825 if(ret2.find(*it2)==ret2.end())
834 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
836 std::vector<std::string> ret;
837 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
839 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
840 ret.insert(ret.end(),tmp.begin(),tmp.end());
845 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
847 std::vector<std::string> ret;
848 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
850 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
851 ret.insert(ret.end(),tmp.begin(),tmp.end());
856 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
858 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
859 (*it)->changePflsRefsNamesGen2(mapOfModif);
862 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
864 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
865 (*it)->changeLocsRefsNamesGen2(mapOfModif);
868 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
870 std::size_t lgth=_time_steps.size();
871 std::vector< std::vector<TypeOfField> > ret(lgth);
872 for(std::size_t i=0;i<lgth;i++)
873 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
878 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
880 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
882 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
885 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
887 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
889 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
891 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
892 ret->_time_steps[i]=(*it)->deepCopy();
897 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
899 std::size_t sz(_infos.size()),sz2(_time_steps.size());
900 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
901 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
902 for(std::size_t i=0;i<sz;i++)
905 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
907 for(std::size_t i=0;i<sz2;i++)
909 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
912 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
913 throw INTERP_KERNEL::Exception(oss.str());
917 for(std::size_t i=0;i<sz;i++)
918 for(std::size_t j=0;j<sz2;j++)
919 ret[i]->_time_steps[j]=ts[j][i];
924 * This method splits into discretization each time steps in \a this.
925 * ** WARNING ** the returned instances are not compulsory defined on the same time steps series !
927 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
929 std::size_t sz(_time_steps.size());
930 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
931 for(std::size_t i=0;i<sz;i++)
933 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
936 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
937 throw INTERP_KERNEL::Exception(oss.str());
939 items[i]=timeStep->splitDiscretizations();
942 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
943 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
944 std::vector< TypeOfField > types;
945 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
946 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
948 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
950 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
951 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
953 types.push_back(ts[0]);
955 ret.resize(types.size()); ret2.resize(types.size());
956 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
957 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
959 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
960 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
961 ret2[pos].push_back(*it1);
963 for(std::size_t i=0;i<types.size();i++)
965 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
966 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
967 elt->pushBackTimeStep(*it1);//also updates infos in elt
969 elt->MEDFileFieldNameScope::operator=(*this);
975 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
977 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
979 std::size_t sz(_time_steps.size());
980 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
981 std::size_t szOut(std::numeric_limits<std::size_t>::max());
982 for(std::size_t i=0;i<sz;i++)
984 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
987 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
988 throw INTERP_KERNEL::Exception(oss.str());
990 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
991 if(szOut==std::numeric_limits<std::size_t>::max())
992 szOut=items[i].size();
994 if(items[i].size()!=szOut)
995 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
997 if(szOut==std::numeric_limits<std::size_t>::max())
998 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
999 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
1000 for(std::size_t i=0;i<szOut;i++)
1002 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
1003 for(std::size_t j=0;j<sz;j++)
1004 elt->pushBackTimeStep(items[j][i]);
1006 elt->MEDFileFieldNameScope::operator=(*this);
1011 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
1013 setName(field->getName());
1014 if(field->getMesh())
1015 setMeshName(field->getMesh()->getName());
1017 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
1019 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
1020 _infos=arr->getInfoOnComponents();
1023 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
1025 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
1026 if(_name!=field->getName())
1028 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
1029 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
1030 throw INTERP_KERNEL::Exception(oss.str());
1033 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
1034 checkThatComponentsMatch(arr->getInfoOnComponents());
1037 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
1039 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
1040 if(getInfo().size()!=compos.size())
1042 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
1043 oss << " number of components of element to append (" << compos.size() << ") !";
1044 throw INTERP_KERNEL::Exception(oss.str());
1048 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
1049 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
1050 oss << " But compo in input fields are : ";
1051 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
1053 throw INTERP_KERNEL::Exception(oss.str());
1057 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
1059 std::size_t sz=_infos.size();
1061 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
1063 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
1065 if(elt->getInfo().size()!=sz)
1067 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
1068 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
1069 throw INTERP_KERNEL::Exception(oss.str());
1074 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1077 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1078 if(!_time_steps.empty())
1079 checkCoherencyOfTinyInfo(field,arr);
1080 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(createNew1TSWithoutSDAEmptyInstance());
1082 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
1083 obj->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
1085 copyTinyInfoFrom(field,arr);
1086 _time_steps.push_back(obj);
1089 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, MEDFileFieldGlobsReal& glob, bool smartPflKiller)
1092 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1093 if(!_time_steps.empty())
1094 checkCoherencyOfTinyInfo(field,arr);
1095 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(createNew1TSWithoutSDAEmptyInstance());
1097 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
1098 obj->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this,smartPflKiller);
1100 copyTinyInfoFrom(field,arr);
1101 setMeshName(obj->getMeshName());
1102 _time_steps.push_back(obj);
1105 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
1107 int sz=(int)_time_steps.size();
1110 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
1111 throw INTERP_KERNEL::Exception(oss.str());
1113 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
1116 if(tsPtr->getNumberOfComponents()!=_infos.size())
1118 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
1119 throw INTERP_KERNEL::Exception(oss.str());
1125 //= MEDFileFieldMultiTSWithoutSDA
1128 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
1129 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
1131 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
1133 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
1134 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
1136 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
1137 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
1140 MEDFileInt32FieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
1142 MCAuto<MEDFileInt32FieldMultiTSWithoutSDA> ret(new MEDFileInt32FieldMultiTSWithoutSDA);
1143 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
1145 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
1147 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
1150 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
1152 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
1153 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
1154 ret->setIteration(i,elt);
1160 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileFieldMultiTSWithoutSDA::createNewWithSDA() const
1162 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1163 return DynamicCast<MEDFileFieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
1168 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileInt32FieldMultiTSWithoutSDA::createNewWithSDA() const
1170 MCAuto<MEDFileInt32FieldMultiTS> ret(MEDFileInt32FieldMultiTS::New());
1171 return DynamicCast<MEDFileInt32FieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
1176 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileInt64FieldMultiTSWithoutSDA::createNewWithSDA() const
1178 MCAuto<MEDFileInt64FieldMultiTS> ret(MEDFileInt64FieldMultiTS::New());
1179 return DynamicCast<MEDFileInt64FieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
1184 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileFloatFieldMultiTSWithoutSDA::createNewWithSDA() const
1186 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1187 return DynamicCast<MEDFileFloatFieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
1190 //= MEDFileAnyTypeFieldMultiTS
1192 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
1196 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1197 try:MEDFileFieldGlobsReal(fid)
1199 _content=BuildContentFrom(fid,loadAll,ms);
1202 catch(INTERP_KERNEL::Exception& e)
1207 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1209 med_field_type typcha;
1210 std::vector<std::string> infos;
1212 std::string meshName;
1214 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
1215 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1220 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1225 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1230 ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1235 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1240 if(sizeof(med_int)==sizeof(int))
1242 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1248 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, MED_INT64] !";
1249 throw INTERP_KERNEL::Exception(oss.str());
1252 ret->setMeshName(meshName);
1253 ret->setDtUnit(dtunit.c_str());
1257 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1259 med_field_type typcha;
1261 std::vector<std::string> infos;
1262 std::string dtunit,fieldName,meshName;
1263 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1264 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1269 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1274 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1279 ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1284 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1289 if(sizeof(med_int)==sizeof(int))
1291 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1297 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, MED_INT64] !";
1298 throw INTERP_KERNEL::Exception(oss.str());
1301 ret->setMeshName(meshName);
1302 ret->setDtUnit(dtunit.c_str());
1306 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
1309 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1310 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
1312 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1313 ret->_content=c; c->incrRef();
1316 if(dynamic_cast<const MEDFileInt32FieldMultiTSWithoutSDA *>(c))
1318 MCAuto<MEDFileInt32FieldMultiTS> ret(MEDFileInt32FieldMultiTS::New());
1319 ret->_content=c; c->incrRef();
1322 if(dynamic_cast<const MEDFileInt64FieldMultiTSWithoutSDA *>(c))
1324 MCAuto<MEDFileInt64FieldMultiTS> ret(MEDFileInt64FieldMultiTS::New());
1325 ret->_content=c; c->incrRef();
1328 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
1330 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1331 ret->_content=c; c->incrRef();
1334 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1337 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
1339 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
1340 std::string fileName(FileNameFromFID(fid));
1341 ret->setFileName(fileName);
1345 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1346 try:MEDFileFieldGlobsReal(fid)
1348 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1351 catch(INTERP_KERNEL::Exception& e)
1356 //= MEDFileAnyTypeFieldMultiTS
1359 * Returns a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS holding data of the first field
1360 * that has been read from a specified MED file.
1361 * \param [in] fileName - the name of the MED file to read.
1362 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS. The caller
1363 * is to delete this field using decrRef() as it is no more needed.
1364 * \throw If reading the file fails.
1366 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
1368 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1369 return New(fid,loadAll);
1372 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
1374 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
1375 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1376 ret->loadGlobals(fid);
1381 * Returns a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS holding data of a given field
1382 * that has been read from a specified MED file.
1383 * \param [in] fileName - the name of the MED file to read.
1384 * \param [in] fieldName - the name of the field to read.
1385 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS. The caller
1386 * is to delete this field using decrRef() as it is no more needed.
1387 * \throw If reading the file fails.
1388 * \throw If there is no field named \a fieldName in the file.
1390 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1392 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1393 return New(fid,fieldName,loadAll);
1396 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1398 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1399 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1400 ret->loadGlobals(fid);
1405 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1406 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1408 * \warning this is a shallow copy constructor
1410 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
1412 if(!shallowCopyOfContent)
1414 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
1415 otherPtr->incrRef();
1416 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
1420 _content=other.shallowCpy();
1424 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
1426 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1428 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
1432 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
1434 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1436 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
1440 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
1442 return contentNotNullBase()->getPflsReallyUsed2();
1445 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
1447 return contentNotNullBase()->getLocsReallyUsed2();
1450 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
1452 return contentNotNullBase()->getPflsReallyUsedMulti2();
1455 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
1457 return contentNotNullBase()->getLocsReallyUsedMulti2();
1460 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1462 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
1465 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1467 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
1470 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
1472 return contentNotNullBase()->getNumberOfTS();
1475 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
1477 contentNotNullBase()->eraseEmptyTS();
1480 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
1482 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
1485 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
1487 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
1490 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
1492 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
1493 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1498 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
1500 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
1501 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1506 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
1508 return contentNotNullBase()->getIterations();
1511 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
1513 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
1514 pushBackTimeStep(*it);
1517 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
1520 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
1521 int nbOfTS(fmts->getNumberOfTS());
1522 for(int i=0;i<nbOfTS;i++)
1524 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
1525 pushBackTimeStep(elt);
1529 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
1532 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
1533 checkCoherencyOfType(f1ts);
1535 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
1536 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
1538 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
1539 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
1540 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
1541 _content->pushBackTimeStep(cSafe);
1542 appendGlobs(*f1ts,1e-12);
1545 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
1547 contentNotNullBase()->synchronizeNameScope();
1550 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
1552 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
1555 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
1557 return contentNotNullBase()->getPosGivenTime(time,eps);
1560 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
1562 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
1565 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
1567 return contentNotNullBase()->getTypesOfFieldAvailable();
1570 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
1572 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1575 std::string MEDFileAnyTypeFieldMultiTS::getName() const
1577 return contentNotNullBase()->getName();
1580 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
1582 contentNotNullBase()->setName(name);
1585 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
1587 return contentNotNullBase()->getDtUnit();
1590 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
1592 contentNotNullBase()->setDtUnit(dtUnit);
1595 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
1597 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
1600 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
1602 return contentNotNullBase()->getTimeSteps(ret1);
1605 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
1607 return contentNotNullBase()->getMeshName();
1610 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
1612 contentNotNullBase()->setMeshName(newMeshName);
1615 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1617 return contentNotNullBase()->changeMeshNames(modifTab);
1620 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
1622 return contentNotNullBase()->getInfo();
1625 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
1627 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
1630 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
1632 return contentNotNullBase()->setInfo(info);
1635 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
1637 const std::vector<std::string> ret=getInfo();
1638 return (int)ret.size();
1641 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
1643 writeGlobals(fid,*this);
1644 contentNotNullBase()->writeLL(fid,*this);
1648 * This method alloc the arrays and load potentially huge arrays contained in this field.
1649 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
1650 * This method can be also called to refresh or reinit values from a file.
1652 * \throw If the fileName is not set or points to a non readable MED file.
1654 void MEDFileAnyTypeFieldMultiTS::loadArrays()
1656 if(getFileName().empty())
1657 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
1658 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1659 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
1663 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
1664 * But once data loaded once, this method does nothing.
1666 * \throw If the fileName is not set or points to a non readable MED file.
1667 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
1669 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
1671 if(!getFileName().empty())
1673 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1674 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
1679 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
1680 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
1681 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
1683 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
1685 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
1687 contentNotNullBase()->unloadArrays();
1691 * 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.
1692 * This method is the symmetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
1693 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
1695 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
1697 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
1699 if(!getFileName().empty())
1700 contentNotNullBase()->unloadArrays();
1703 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
1705 std::ostringstream oss;
1706 contentNotNullBase()->simpleRepr(0,oss,-1);
1707 simpleReprGlobs(oss);
1711 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
1713 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
1716 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
1718 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
1719 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
1724 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
1725 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
1726 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
1728 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
1730 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1732 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
1733 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
1734 std::size_t sz(contentsSplit.size());
1735 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1736 for(std::size_t i=0;i<sz;i++)
1738 ret[i]=shallowCpy();
1739 ret[i]->_content=contentsSplit[i];
1745 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
1746 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1748 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
1750 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1752 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
1753 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
1754 std::size_t sz(contentsSplit.size());
1755 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1756 for(std::size_t i=0;i<sz;i++)
1758 ret[i]=shallowCpy();
1759 ret[i]->_content=contentsSplit[i];
1765 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
1766 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1768 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
1770 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1772 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
1773 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
1774 std::size_t sz(contentsSplit.size());
1775 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1776 for(std::size_t i=0;i<sz;i++)
1778 ret[i]=shallowCpy();
1779 ret[i]->_content=contentsSplit[i];
1784 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
1786 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1787 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
1788 ret->_content=_content->deepCopy();
1789 ret->deepCpyGlobs(*this);
1793 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
1799 * Returns a new MEDFileField1TS or MEDFileInt32Field1TS holding data of a given time step of \a this field.
1800 * \param [in] iteration - the iteration number of a required time step.
1801 * \param [in] order - the iteration order number of required time step.
1802 * \return MEDFileField1TS * or MEDFileInt32Field1TS *- a new instance of MEDFileField1TS or MEDFileInt32Field1TS. The caller is to
1803 * delete this field using decrRef() as it is no more needed.
1804 * \throw If there is no required time step in \a this field.
1806 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
1808 int pos=getPosOfTimeStep(iteration,order);
1809 return getTimeStepAtPos(pos);
1813 * Returns a new MEDFileField1TS or MEDFileInt32Field1TS holding data of a given time step of \a this field.
1814 * \param [in] time - the time of the time step of interest.
1815 * \param [in] eps - a precision used to compare time values.
1816 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
1817 * delete this field using decrRef() as it is no more needed.
1818 * \throw If there is no required time step in \a this field.
1820 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
1822 int pos=getPosGivenTime(time,eps);
1823 return getTimeStepAtPos(pos);
1827 * 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.
1828 * The float64 value of time attached to the pair of integers are not considered here.
1829 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
1831 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
1832 * \throw If there is a null pointer in \a vectFMTS.
1834 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
1836 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
1837 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1838 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1839 while(!lstFMTS.empty())
1841 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1842 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1844 throw INTERP_KERNEL::Exception(msg);
1845 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
1846 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1847 elt.push_back(curIt); it=lstFMTS.erase(it);
1848 while(it!=lstFMTS.end())
1852 throw INTERP_KERNEL::Exception(msg);
1853 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
1855 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1865 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
1866 * All returned instances in a subvector can be safely loaded, rendered along time
1867 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
1868 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
1869 * 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).
1870 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
1871 * 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.
1873 * \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().
1874 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
1875 * \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.
1876 * \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.
1878 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
1879 * \throw If an element in \a vectFMTS change of spatial discretization along time.
1880 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
1881 * \thorw If some elements in \a vectFMTS do not have the same times steps.
1882 * \throw If mesh is null.
1883 * \throw If an element in \a vectFMTS is null.
1884 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
1886 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
1888 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
1890 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
1891 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1892 if(vectFMTS.empty())
1894 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
1895 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
1897 throw INTERP_KERNEL::Exception(msg);
1899 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
1900 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
1901 for(;it!=vectFMTS.end();it++,i++)
1904 throw INTERP_KERNEL::Exception(msg);
1905 TypeOfField tof0,tof1;
1906 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
1909 vectFMTSNotNodes.push_back(*it);
1911 vectFMTSNodes.push_back(*it);
1914 vectFMTSNotNodes.push_back(*it);
1916 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
1917 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
1919 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
1922 bool isFetched(false);
1923 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
1926 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
1927 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
1928 { ret[i].push_back(*it2); isFetched=true; }
1932 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
1933 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
1934 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
1942 * 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.
1943 * \param [out] cmps - same size than the returned vector.
1945 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
1947 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1948 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1949 while(!lstFMTS.empty())
1951 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1952 MEDFileAnyTypeFieldMultiTS *ref(*it);
1953 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1954 elt.push_back(ref); it=lstFMTS.erase(it);
1955 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
1956 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
1957 while(it!=lstFMTS.end())
1959 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1960 if(cmp->isEqual(curIt))
1961 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1965 ret.push_back(elt); cmps.push_back(cmp);
1971 * 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.
1972 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
1974 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
1975 * \throw If \a f0 or \a f1 change of spatial discretization along time.
1976 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
1977 * \thorw If \a f0 and \a f1 do not have the same times steps.
1978 * \throw If mesh is null.
1979 * \throw If \a f0 or \a f1 is null.
1980 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
1982 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
1985 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
1987 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
1988 if(f0->getMeshName()!=mesh->getName())
1990 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1991 throw INTERP_KERNEL::Exception(oss.str());
1993 if(f1->getMeshName()!=mesh->getName())
1995 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1996 throw INTERP_KERNEL::Exception(oss.str());
1998 int nts=f0->getNumberOfTS();
1999 if(nts!=f1->getNumberOfTS())
2000 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
2003 for(int i=0;i<nts;i++)
2005 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
2006 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
2007 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
2008 if(tofs0.size()!=1 || tofs1.size()!=1)
2009 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
2012 if(tof0!=tofs0[0] || tof1!=tofs1[0])
2013 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
2016 { tof0=tofs0[0]; tof1=tofs1[0]; }
2017 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
2019 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() << ") !";
2020 throw INTERP_KERNEL::Exception(oss.str());
2022 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
2024 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() << ") !";
2025 throw INTERP_KERNEL::Exception(oss.str());
2027 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
2029 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() << ") !";
2030 throw INTERP_KERNEL::Exception(oss.str());
2037 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2039 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
2041 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
2042 std::size_t sz(f1tss.size()),i(0);
2043 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
2044 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
2046 typename MLFieldTraits<T>::F1TSType const *elt(*it);
2048 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
2049 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
2051 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
2053 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
2054 retc->aggregate(f1tsw,dts);
2055 ret->setDtUnit(f1tss[0]->getDtUnit());
2056 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
2060 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2062 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
2064 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
2065 std::size_t sz(fmtss.size());
2066 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2068 typename MLFieldTraits<T>::FMTSType const *elt(*it);
2070 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
2072 int nbTS(fmtss[0]->getNumberOfTS());
2073 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2074 if((*it)->getNumberOfTS()!=nbTS)
2075 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
2076 for(int iterTS=0;iterTS<nbTS;iterTS++)
2079 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
2080 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
2081 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
2082 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
2083 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
2084 ret->pushBackTimeStep(f1ts);
2085 ret->setDtUnit(f1ts->getDtUnit());
2087 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
2091 * \a dts and \a ftmss are expected to have same size.
2092 * see MEDFileFieldPerMeshPerTypePerDisc::Aggregate for description of \a dts.
2094 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2097 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
2098 std::size_t sz(fmtss.size());
2099 std::vector<const MEDFileFieldMultiTS *> fmtss1;
2100 std::vector<const MEDFileInt32FieldMultiTS *> fmtss2;
2101 std::vector<const MEDFileInt64FieldMultiTS *> fmtss3;
2102 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2105 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
2106 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
2109 fmtss1.push_back(elt1);
2112 const MEDFileInt32FieldMultiTS *elt2(dynamic_cast<const MEDFileInt32FieldMultiTS *>(*it));
2115 fmtss2.push_back(elt2);
2118 const MEDFileInt64FieldMultiTS *elt3(dynamic_cast<const MEDFileInt64FieldMultiTS *>(*it));
2121 fmtss3.push_back(elt3);
2124 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
2126 if(fmtss1.size()!=sz && fmtss2.size()!=sz && fmtss3.size()!=sz)
2127 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
2128 if(fmtss1.size()==sz)
2129 return AggregateHelperFMTS<double>(fmtss1,dts);
2130 if(fmtss2.size()!=sz)
2131 return AggregateHelperFMTS<Int32>(fmtss2,dts);
2132 if(fmtss3.size()!=sz)
2133 return AggregateHelperFMTS<Int64>(fmtss3,dts);
2134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
2137 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
2139 return new MEDFileAnyTypeFieldMultiTSIterator(this);
2142 //= MEDFileFieldMultiTS
2144 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
2146 return new MEDFileFieldMultiTS(*this);
2150 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2151 * following the given input policy.
2153 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2154 * By default (true) the globals are deeply copied.
2155 * \return MEDFileInt32FieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
2157 MEDFileInt32FieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
2159 MCAuto<MEDFileInt32FieldMultiTS> ret;
2160 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
2163 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
2165 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2166 MCAuto<MEDFileInt32FieldMultiTSWithoutSDA> newc(contc->convertToInt());
2167 ret=static_cast<MEDFileInt32FieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileInt32FieldMultiTSWithoutSDA *)newc));
2170 ret=MEDFileInt32FieldMultiTS::New();
2172 ret->deepCpyGlobs(*this);
2174 ret->shallowCpyGlobs(*this);
2178 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2179 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
2182 catch(INTERP_KERNEL::Exception& e)
2185 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2186 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
2189 catch(INTERP_KERNEL::Exception& e)
2192 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
2196 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
2198 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
2201 //= MEDFileAnyTypeFieldMultiTSIterator
2203 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
2208 _nb_iter=fmts->getNumberOfTS();
2212 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
2216 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
2218 if(_iter_id<_nb_iter)
2220 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
2222 return fmts->getTimeStepAtPos(_iter_id++);
2230 //= MEDFileInt32FieldMultiTS