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 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 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(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 //= MEDFileAnyTypeFieldMultiTS
1162 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
1166 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1167 try:MEDFileFieldGlobsReal(fid)
1169 _content=BuildContentFrom(fid,loadAll,ms);
1172 catch(INTERP_KERNEL::Exception& e)
1177 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1179 med_field_type typcha;
1180 std::vector<std::string> infos;
1182 std::string meshName;
1184 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
1185 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1190 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1195 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1200 ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1205 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1210 if(sizeof(med_int)==sizeof(int))
1212 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1218 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] !";
1219 throw INTERP_KERNEL::Exception(oss.str());
1222 ret->setMeshName(meshName);
1223 ret->setDtUnit(dtunit.c_str());
1227 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1229 med_field_type typcha;
1231 std::vector<std::string> infos;
1232 std::string dtunit,fieldName,meshName;
1233 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1234 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1239 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1244 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1249 ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1254 ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1259 if(sizeof(med_int)==sizeof(int))
1261 ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1267 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] !";
1268 throw INTERP_KERNEL::Exception(oss.str());
1271 ret->setMeshName(meshName);
1272 ret->setDtUnit(dtunit.c_str());
1276 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
1279 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1280 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
1282 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1283 ret->_content=c; c->incrRef();
1286 if(dynamic_cast<const MEDFileInt32FieldMultiTSWithoutSDA *>(c))
1288 MCAuto<MEDFileInt32FieldMultiTS> ret(MEDFileInt32FieldMultiTS::New());
1289 ret->_content=c; c->incrRef();
1292 if(dynamic_cast<const MEDFileInt64FieldMultiTSWithoutSDA *>(c))
1294 MCAuto<MEDFileInt64FieldMultiTS> ret(MEDFileInt64FieldMultiTS::New());
1295 ret->_content=c; c->incrRef();
1298 if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
1300 MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1301 ret->_content=c; c->incrRef();
1304 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1307 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
1309 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
1310 std::string fileName(FileNameFromFID(fid));
1311 ret->setFileName(fileName);
1315 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1316 try:MEDFileFieldGlobsReal(fid)
1318 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1321 catch(INTERP_KERNEL::Exception& e)
1326 //= MEDFileAnyTypeFieldMultiTS
1329 * Returns a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS holding data of the first field
1330 * that has been read from a specified MED file.
1331 * \param [in] fileName - the name of the MED file to read.
1332 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS. The caller
1333 * is to delete this field using decrRef() as it is no more needed.
1334 * \throw If reading the file fails.
1336 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
1338 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1339 return New(fid,loadAll);
1342 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
1344 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
1345 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1346 ret->loadGlobals(fid);
1351 * Returns a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS holding data of a given field
1352 * that has been read from a specified MED file.
1353 * \param [in] fileName - the name of the MED file to read.
1354 * \param [in] fieldName - the name of the field to read.
1355 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS. The caller
1356 * is to delete this field using decrRef() as it is no more needed.
1357 * \throw If reading the file fails.
1358 * \throw If there is no field named \a fieldName in the file.
1360 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1362 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1363 return New(fid,fieldName,loadAll);
1366 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1368 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1369 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1370 ret->loadGlobals(fid);
1375 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1376 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1378 * \warning this is a shallow copy constructor
1380 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
1382 if(!shallowCopyOfContent)
1384 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
1385 otherPtr->incrRef();
1386 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
1390 _content=other.shallowCpy();
1394 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
1396 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1398 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
1402 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
1404 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1406 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
1410 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
1412 return contentNotNullBase()->getPflsReallyUsed2();
1415 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
1417 return contentNotNullBase()->getLocsReallyUsed2();
1420 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
1422 return contentNotNullBase()->getPflsReallyUsedMulti2();
1425 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
1427 return contentNotNullBase()->getLocsReallyUsedMulti2();
1430 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1432 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
1435 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1437 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
1440 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
1442 return contentNotNullBase()->getNumberOfTS();
1445 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
1447 contentNotNullBase()->eraseEmptyTS();
1450 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
1452 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
1455 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
1457 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
1460 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
1462 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
1463 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1468 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
1470 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
1471 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1476 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
1478 return contentNotNullBase()->getIterations();
1481 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
1483 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
1484 pushBackTimeStep(*it);
1487 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
1490 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
1491 int nbOfTS(fmts->getNumberOfTS());
1492 for(int i=0;i<nbOfTS;i++)
1494 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
1495 pushBackTimeStep(elt);
1499 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
1502 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
1503 checkCoherencyOfType(f1ts);
1505 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
1506 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
1508 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
1509 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
1510 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
1511 _content->pushBackTimeStep(cSafe);
1512 appendGlobs(*f1ts,1e-12);
1515 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
1517 contentNotNullBase()->synchronizeNameScope();
1520 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
1522 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
1525 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
1527 return contentNotNullBase()->getPosGivenTime(time,eps);
1530 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
1532 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
1535 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
1537 return contentNotNullBase()->getTypesOfFieldAvailable();
1540 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
1542 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1545 std::string MEDFileAnyTypeFieldMultiTS::getName() const
1547 return contentNotNullBase()->getName();
1550 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
1552 contentNotNullBase()->setName(name);
1555 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
1557 return contentNotNullBase()->getDtUnit();
1560 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
1562 contentNotNullBase()->setDtUnit(dtUnit);
1565 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
1567 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
1570 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
1572 return contentNotNullBase()->getTimeSteps(ret1);
1575 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
1577 return contentNotNullBase()->getMeshName();
1580 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
1582 contentNotNullBase()->setMeshName(newMeshName);
1585 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1587 return contentNotNullBase()->changeMeshNames(modifTab);
1590 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
1592 return contentNotNullBase()->getInfo();
1595 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
1597 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
1600 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
1602 return contentNotNullBase()->setInfo(info);
1605 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
1607 const std::vector<std::string> ret=getInfo();
1608 return (int)ret.size();
1611 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
1613 writeGlobals(fid,*this);
1614 contentNotNullBase()->writeLL(fid,*this);
1618 * This method alloc the arrays and load potentially huge arrays contained in this field.
1619 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
1620 * This method can be also called to refresh or reinit values from a file.
1622 * \throw If the fileName is not set or points to a non readable MED file.
1624 void MEDFileAnyTypeFieldMultiTS::loadArrays()
1626 if(getFileName().empty())
1627 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
1628 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1629 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
1633 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
1634 * But once data loaded once, this method does nothing.
1636 * \throw If the fileName is not set or points to a non readable MED file.
1637 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
1639 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
1641 if(!getFileName().empty())
1643 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1644 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
1649 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
1650 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
1651 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
1653 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
1655 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
1657 contentNotNullBase()->unloadArrays();
1661 * 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.
1662 * This method is the symmetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
1663 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
1665 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
1667 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
1669 if(!getFileName().empty())
1670 contentNotNullBase()->unloadArrays();
1673 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
1675 std::ostringstream oss;
1676 contentNotNullBase()->simpleRepr(0,oss,-1);
1677 simpleReprGlobs(oss);
1681 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
1683 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
1686 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
1688 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
1689 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
1694 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
1695 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
1696 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
1698 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
1700 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1702 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
1703 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
1704 std::size_t sz(contentsSplit.size());
1705 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1706 for(std::size_t i=0;i<sz;i++)
1708 ret[i]=shallowCpy();
1709 ret[i]->_content=contentsSplit[i];
1715 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
1716 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1718 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
1720 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1722 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
1723 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
1724 std::size_t sz(contentsSplit.size());
1725 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1726 for(std::size_t i=0;i<sz;i++)
1728 ret[i]=shallowCpy();
1729 ret[i]->_content=contentsSplit[i];
1735 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
1736 * The returned instances are shallow copied of \a this included globals that are shared with those contained in \a this.
1738 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
1740 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
1743 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
1744 std::size_t sz(contentsSplit.size());
1745 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1746 for(std::size_t i=0;i<sz;i++)
1748 ret[i]=shallowCpy();
1749 ret[i]->_content=contentsSplit[i];
1754 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
1756 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1757 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
1758 ret->_content=_content->deepCopy();
1759 ret->deepCpyGlobs(*this);
1763 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
1769 * Returns a new MEDFileField1TS or MEDFileInt32Field1TS holding data of a given time step of \a this field.
1770 * \param [in] iteration - the iteration number of a required time step.
1771 * \param [in] order - the iteration order number of required time step.
1772 * \return MEDFileField1TS * or MEDFileInt32Field1TS *- a new instance of MEDFileField1TS or MEDFileInt32Field1TS. The caller is to
1773 * delete this field using decrRef() as it is no more needed.
1774 * \throw If there is no required time step in \a this field.
1776 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
1778 int pos=getPosOfTimeStep(iteration,order);
1779 return getTimeStepAtPos(pos);
1783 * Returns a new MEDFileField1TS or MEDFileInt32Field1TS holding data of a given time step of \a this field.
1784 * \param [in] time - the time of the time step of interest.
1785 * \param [in] eps - a precision used to compare time values.
1786 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
1787 * delete this field using decrRef() as it is no more needed.
1788 * \throw If there is no required time step in \a this field.
1790 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
1792 int pos=getPosGivenTime(time,eps);
1793 return getTimeStepAtPos(pos);
1797 * 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.
1798 * The float64 value of time attached to the pair of integers are not considered here.
1799 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
1801 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
1802 * \throw If there is a null pointer in \a vectFMTS.
1804 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
1806 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
1807 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1808 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1809 while(!lstFMTS.empty())
1811 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1812 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1814 throw INTERP_KERNEL::Exception(msg);
1815 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
1816 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1817 elt.push_back(curIt); it=lstFMTS.erase(it);
1818 while(it!=lstFMTS.end())
1822 throw INTERP_KERNEL::Exception(msg);
1823 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
1825 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1835 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
1836 * All returned instances in a subvector can be safely loaded, rendered along time
1837 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
1838 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
1839 * 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).
1840 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
1841 * 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.
1843 * \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().
1844 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
1845 * \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.
1846 * \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.
1848 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
1849 * \throw If an element in \a vectFMTS change of spatial discretization along time.
1850 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
1851 * \thorw If some elements in \a vectFMTS do not have the same times steps.
1852 * \throw If mesh is null.
1853 * \throw If an element in \a vectFMTS is null.
1854 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
1856 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
1858 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
1860 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
1861 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1862 if(vectFMTS.empty())
1864 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
1865 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
1867 throw INTERP_KERNEL::Exception(msg);
1869 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
1870 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
1871 for(;it!=vectFMTS.end();it++,i++)
1874 throw INTERP_KERNEL::Exception(msg);
1875 TypeOfField tof0,tof1;
1876 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
1879 vectFMTSNotNodes.push_back(*it);
1881 vectFMTSNodes.push_back(*it);
1884 vectFMTSNotNodes.push_back(*it);
1886 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
1887 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
1889 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
1892 bool isFetched(false);
1893 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
1896 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
1897 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
1898 { ret[i].push_back(*it2); isFetched=true; }
1902 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
1903 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
1904 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
1912 * 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.
1913 * \param [out] cmps - same size than the returned vector.
1915 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
1917 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1918 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1919 while(!lstFMTS.empty())
1921 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1922 MEDFileAnyTypeFieldMultiTS *ref(*it);
1923 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1924 elt.push_back(ref); it=lstFMTS.erase(it);
1925 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
1926 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
1927 while(it!=lstFMTS.end())
1929 MEDFileAnyTypeFieldMultiTS *curIt(*it);
1930 if(cmp->isEqual(curIt))
1931 { elt.push_back(curIt); it=lstFMTS.erase(it); }
1935 ret.push_back(elt); cmps.push_back(cmp);
1941 * 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.
1942 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
1944 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
1945 * \throw If \a f0 or \a f1 change of spatial discretization along time.
1946 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
1947 * \thorw If \a f0 and \a f1 do not have the same times steps.
1948 * \throw If mesh is null.
1949 * \throw If \a f0 or \a f1 is null.
1950 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
1952 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
1955 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
1957 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
1958 if(f0->getMeshName()!=mesh->getName())
1960 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1961 throw INTERP_KERNEL::Exception(oss.str());
1963 if(f1->getMeshName()!=mesh->getName())
1965 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1966 throw INTERP_KERNEL::Exception(oss.str());
1968 int nts=f0->getNumberOfTS();
1969 if(nts!=f1->getNumberOfTS())
1970 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
1973 for(int i=0;i<nts;i++)
1975 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
1976 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
1977 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
1978 if(tofs0.size()!=1 || tofs1.size()!=1)
1979 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
1982 if(tof0!=tofs0[0] || tof1!=tofs1[0])
1983 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
1986 { tof0=tofs0[0]; tof1=tofs1[0]; }
1987 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
1989 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() << ") !";
1990 throw INTERP_KERNEL::Exception(oss.str());
1992 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
1994 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() << ") !";
1995 throw INTERP_KERNEL::Exception(oss.str());
1997 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
1999 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() << ") !";
2000 throw INTERP_KERNEL::Exception(oss.str());
2007 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2009 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
2011 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
2012 std::size_t sz(f1tss.size()),i(0);
2013 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
2014 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
2016 typename MLFieldTraits<T>::F1TSType const *elt(*it);
2018 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
2019 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
2021 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
2023 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
2024 retc->aggregate(f1tsw,dts);
2025 ret->setDtUnit(f1tss[0]->getDtUnit());
2026 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
2030 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2032 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
2034 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
2035 std::size_t sz(fmtss.size());
2036 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2038 typename MLFieldTraits<T>::FMTSType const *elt(*it);
2040 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
2042 int nbTS(fmtss[0]->getNumberOfTS());
2043 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2044 if((*it)->getNumberOfTS()!=nbTS)
2045 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
2046 for(int iterTS=0;iterTS<nbTS;iterTS++)
2049 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
2050 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
2051 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
2052 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
2053 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
2054 ret->pushBackTimeStep(f1ts);
2055 ret->setDtUnit(f1ts->getDtUnit());
2057 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
2061 * \a dts and \a ftmss are expected to have same size.
2063 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
2066 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
2067 std::size_t sz(fmtss.size());
2068 std::vector<const MEDFileFieldMultiTS *> fmtss1;
2069 std::vector<const MEDFileInt32FieldMultiTS *> fmtss2;
2070 std::vector<const MEDFileInt64FieldMultiTS *> fmtss3;
2071 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2074 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
2075 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
2078 fmtss1.push_back(elt1);
2081 const MEDFileInt32FieldMultiTS *elt2(dynamic_cast<const MEDFileInt32FieldMultiTS *>(*it));
2084 fmtss2.push_back(elt2);
2087 const MEDFileInt64FieldMultiTS *elt3(dynamic_cast<const MEDFileInt64FieldMultiTS *>(*it));
2090 fmtss3.push_back(elt3);
2093 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
2095 if(fmtss1.size()!=sz && fmtss2.size()!=sz && fmtss3.size()!=sz)
2096 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
2097 if(fmtss1.size()==sz)
2098 return AggregateHelperFMTS<double>(fmtss1,dts);
2099 if(fmtss2.size()!=sz)
2100 return AggregateHelperFMTS<Int32>(fmtss2,dts);
2101 if(fmtss3.size()!=sz)
2102 return AggregateHelperFMTS<Int64>(fmtss3,dts);
2103 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
2106 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
2108 return new MEDFileAnyTypeFieldMultiTSIterator(this);
2111 //= MEDFileFieldMultiTS
2113 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
2115 return new MEDFileFieldMultiTS(*this);
2119 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2120 * following the given input policy.
2122 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2123 * By default (true) the globals are deeply copied.
2124 * \return MEDFileInt32FieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
2126 MEDFileInt32FieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
2128 MCAuto<MEDFileInt32FieldMultiTS> ret;
2129 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
2132 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
2134 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2135 MCAuto<MEDFileInt32FieldMultiTSWithoutSDA> newc(contc->convertToInt());
2136 ret=static_cast<MEDFileInt32FieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileInt32FieldMultiTSWithoutSDA *)newc));
2139 ret=MEDFileInt32FieldMultiTS::New();
2141 ret->deepCpyGlobs(*this);
2143 ret->shallowCpyGlobs(*this);
2147 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2148 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
2151 catch(INTERP_KERNEL::Exception& e)
2154 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2155 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
2158 catch(INTERP_KERNEL::Exception& e)
2161 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
2165 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
2167 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
2170 //= MEDFileAnyTypeFieldMultiTSIterator
2172 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
2177 _nb_iter=fmts->getNumberOfTS();
2181 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
2185 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
2187 if(_iter_id<_nb_iter)
2189 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
2191 return fmts->getTimeStepAtPos(_iter_id++);
2199 //= MEDFileInt32FieldMultiTS