Salome HOME
Split MEDFileField implementation into several parts to make eclipse and developper...
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldMultiTS.cxx
1 // Copyright (C) 2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #include "MEDFileFieldMultiTS.hxx"
22 #include "MEDFileFieldVisitor.hxx"
23 #include "MEDFileSafeCaller.txx"
24 #include "MEDLoaderBase.hxx"
25 #include "MEDFileField.txx"
26
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldTemplate.hxx"
29
30 #include <sstream>
31
32 using namespace MEDCoupling;
33
34 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<int>;
35 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<float>;
36 template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA<double>;
37 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<int>;
38 template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA<float>;
39 template class MEDCoupling::MEDFileTemplateFieldMultiTS<int>;
40 template class MEDCoupling::MEDFileTemplateFieldMultiTS<float>;
41 template class MEDCoupling::MEDFileTemplateFieldMultiTS<double>;
42 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<int>;
43 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<float>;
44
45 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
46
47 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
48 {
49 }
50
51 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName)
52 {
53 }
54
55 /*!
56  * \param [in] fieldId field id in C mode
57  */
58 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
59 {
60   med_field_type typcha;
61   std::string dtunitOut,meshName;
62   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName));
63   setMeshName(meshName);
64   setDtUnit(dtunitOut.c_str());
65   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
66 }
67
68 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
69 try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos)
70 {
71   setDtUnit(dtunit.c_str());
72   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
73 }
74 catch(INTERP_KERNEL::Exception& e)
75 {
76     throw e;
77 }
78
79 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
80 {
81   std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
82   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
83     ret+=(*it).capacity();
84   return ret;
85 }
86
87 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
88 {
89   std::vector<const BigMemoryObject *> ret;
90   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
91     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
92   return ret;
93 }
94
95 /*!
96  * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not
97  * NULL.
98  */
99 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
100 {
101   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
102   ret->setInfo(_infos);
103   int sz=(int)_time_steps.size();
104   for(const int *id=startIds;id!=endIds;id++)
105     {
106       if(*id>=0 && *id<sz)
107         {
108           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
109           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
110           if(tse)
111             {
112               tse->incrRef();
113               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
114             }
115           ret->pushBackTimeStep(tse2);
116         }
117       else
118         {
119           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
120           oss << " ! Should be in [0," << sz << ") !";
121           throw INTERP_KERNEL::Exception(oss.str());
122         }
123     }
124   if(ret->getNumberOfTS()>0)
125     ret->synchronizeNameScope();
126   ret->copyNameScope(*this);
127   return ret.retn();
128 }
129
130 /*!
131  * If one of the id in the input range points to a null element, there is not throw. Simply, this empty element is added as if it were not
132  * NULL.
133  */
134 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
135 {
136   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
137   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
138   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
139   ret->setInfo(_infos);
140   int sz=(int)_time_steps.size();
141   int j=bg;
142   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
143     {
144       if(j>=0 && j<sz)
145         {
146           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
147           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
148           if(tse)
149             {
150               tse->incrRef();
151               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
152             }
153           ret->pushBackTimeStep(tse2);
154         }
155       else
156         {
157           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
158           oss << " ! Should be in [0," << sz << ") !";
159           throw INTERP_KERNEL::Exception(oss.str());
160         }
161     }
162   if(ret->getNumberOfTS()>0)
163     ret->synchronizeNameScope();
164   ret->copyNameScope(*this);
165   return ret.retn();
166 }
167
168 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
169 {
170   int id=0;
171   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
172   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
173     {
174       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
175       if(!cur)
176         continue;
177       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
178       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
179         ids->pushBackSilent(id);
180     }
181   return buildFromTimeStepIds(ids->begin(),ids->end());
182 }
183
184 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
185 {
186   int id=0;
187   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
188   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
189     {
190       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
191       if(!cur)
192         continue;
193       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
194       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
195         ids->pushBackSilent(id);
196     }
197   return buildFromTimeStepIds(ids->begin(),ids->end());
198 }
199
200 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
201 {
202   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
203     if((*it).isNotNull())
204       if((*it)->presenceOfStructureElements())
205         return true;
206   return false;
207 }
208
209 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
210 {
211   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
212     if((*it).isNotNull())
213       if(!(*it)->onlyStructureElements())
214         return false;
215   return true;
216 }
217
218 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
219 {
220   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
221   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
222     if((*it).isNotNull())
223       {
224         if((*it)->presenceOfStructureElements())
225           {
226             if(!(*it)->onlyStructureElements())
227               {
228                 (*it)->killStructureElements();
229                 ret.push_back(*it);
230               }
231           }
232         else
233           {
234             ret.push_back(*it);
235           }
236       }
237   _time_steps=ret;
238 }
239
240 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
241 {
242   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
243   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
244     if((*it).isNotNull())
245       {
246         if((*it)->presenceOfStructureElements())
247           {
248             if(!(*it)->onlyStructureElements())
249               (*it)->keepOnlyStructureElements();
250             ret.push_back(*it);
251           }
252       }
253   _time_steps=ret;
254 }
255
256 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
257 {
258   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
259   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
260     if((*it).isNotNull())
261       (*it)->keepOnlyOnSE(seName);
262 }
263
264 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
265 {
266   std::vector< std::pair<std::string,std::string> > ps2;
267   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
268     if((*it).isNotNull())
269       {
270         (*it)->getMeshSENames(ps2);
271         break;
272       }
273   if(ps2.empty())
274     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
275   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
276     if((*it).isNotNull())
277       {
278         std::vector< std::pair<std::string,std::string> > ps3;
279         (*it)->getMeshSENames(ps3);
280         if(ps2!=ps3)
281           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
282       }
283   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
284     {
285       std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
286       if(it2==ps.end())
287         ps.push_back(*it);
288     }
289 }
290
291 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
292 {
293   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
294     {
295       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
296       if(!cur)
297         continue;
298       if(cur->presenceOfMultiDiscPerGeoType())
299         return true;
300     }
301   return false;
302 }
303
304 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
305 {
306   return _infos;
307 }
308
309 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
310 {
311   _infos=info;
312 }
313
314 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
315 {
316   int ret=0;
317   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
318     {
319       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
320       if(pt->isDealingTS(iteration,order))
321         return ret;
322     }
323   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
324   std::vector< std::pair<int,int> > vp=getIterations();
325   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
326     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
327   throw INTERP_KERNEL::Exception(oss.str());
328 }
329
330 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
331 {
332   return *_time_steps[getTimeStepPos(iteration,order)];
333 }
334
335 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
336 {
337   return *_time_steps[getTimeStepPos(iteration,order)];
338 }
339
340 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
341 {
342   bool ret(false);
343   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
344     {
345       if((*it).first==getMeshName())
346         {
347           setMeshName((*it).second);
348           ret=true;
349         }
350     }
351   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
352     {
353       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
354       if(cur)
355         ret=cur->changeMeshNames(modifTab) || ret;
356     }
357   return ret;
358 }
359
360 /*!
361  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
362  */
363 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
364 {
365   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
366 }
367
368 /*!
369  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
370  */
371 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
372 {
373   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
374 }
375
376 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
377                                                                        MEDFileFieldGlobsReal& glob)
378 {
379   bool ret=false;
380   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
381     {
382       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
383       if(f1ts)
384         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
385     }
386   return ret;
387 }
388
389 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
390 {
391   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
392     if((*it).isNotNull())
393       {
394         visitor.newTimeStepEntry(*it);
395         (*it)->accept(visitor);
396         visitor.endTimeStepEntry(*it);
397       }
398 }
399
400 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
401 {
402   std::string startLine(bkOffset,' ');
403   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
404   if(fmtsId>=0)
405     oss << " (" << fmtsId << ")";
406   oss << " has the following name: \"" << _name << "\"." << std::endl;
407   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
408   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
409     {
410       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
411     }
412   int i=0;
413   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
414     {
415       std::string chapter(17,'0'+i);
416       oss << startLine << chapter << std::endl;
417       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
418       if(cur)
419         cur->simpleRepr(bkOffset+2,oss,i);
420       else
421         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
422       oss << startLine << chapter << std::endl;
423     }
424 }
425
426 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
427 {
428   std::size_t sz=_time_steps.size();
429   std::vector< std::pair<int,int> > ret(sz);
430   ret1.resize(sz);
431   for(std::size_t i=0;i<sz;i++)
432     {
433       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
434       if(f1ts)
435         {
436           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
437         }
438       else
439         {
440           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
441           throw INTERP_KERNEL::Exception(oss.str());
442         }
443     }
444   return ret;
445 }
446
447 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
448 {
449   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
450   if(!tse2)
451     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
452   checkCoherencyOfType(tse2);
453   if(_time_steps.empty())
454     {
455       setName(tse2->getName());
456       setMeshName(tse2->getMeshName());
457       setInfo(tse2->getInfo());
458     }
459   checkThatComponentsMatch(tse2->getInfo());
460   if(getDtUnit().empty() && !tse->getDtUnit().empty())
461     setDtUnit(tse->getDtUnit());
462   _time_steps.push_back(tse);
463 }
464
465 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
466 {
467   std::size_t nbOfCompo=_infos.size();
468   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
469     {
470       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
471       if(cur)
472         {
473           if((cur->getInfo()).size()!=nbOfCompo)
474             {
475               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
476               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
477               throw INTERP_KERNEL::Exception(oss.str());
478             }
479           cur->copyNameScope(*this);
480         }
481     }
482 }
483
484 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
485 {
486   _time_steps.resize(nbPdt);
487   for(int i=0;i<nbPdt;i++)
488     {
489       std::vector< std::pair<int,int> > ts;
490       med_int numdt=0,numo=0;
491       med_float dt=0.0;
492       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
493       switch(fieldTyp)
494       {
495         case MED_FLOAT64:
496           {
497             _time_steps[i]=MEDFileField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
498             break;
499           }
500         case MED_INT32:
501           {
502             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
503             break;
504           }
505         case MED_FLOAT32:
506           {
507             _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
508             break;
509           }
510         case MED_INT:
511           {
512             if(sizeof(med_int)==sizeof(int))
513               {
514                 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos);
515                 break;
516               }
517           }
518         default:
519           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
520       }
521       if(loadAll)
522         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
523       else
524         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
525       synchronizeNameScope();
526     }
527 }
528
529 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
530 {
531   if(_time_steps.empty())
532     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
533   checkThatNbOfCompoOfTSMatchThis();
534   std::vector<std::string> infos(getInfo());
535   int nbComp=infos.size();
536   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
537   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
538   for(int i=0;i<nbComp;i++)
539     {
540       std::string info=infos[i];
541       std::string c,u;
542       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
543       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
544       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
545     }
546   if(_name.empty())
547     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
548   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
549   int nbOfTS=_time_steps.size();
550   for(int i=0;i<nbOfTS;i++)
551     _time_steps[i]->writeLL(fid,opts,*this);
552 }
553
554 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
555 {
556   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
557     {
558       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
559       if(elt)
560         elt->loadBigArraysRecursively(fid,nasc);
561     }
562 }
563
564 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
565 {
566   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
567     {
568       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
569       if(elt)
570         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
571     }
572 }
573
574 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
575 {
576   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
577     {
578       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
579       if(elt)
580         elt->unloadArrays();
581     }
582 }
583
584 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
585 {
586   return _time_steps.size();
587 }
588
589 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
590 {
591   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
592   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
593     {
594       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
595       if(tmp)
596         newTS.push_back(*it);
597     }
598   _time_steps=newTS;
599 }
600
601 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
602 {
603   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
604   int maxId=(int)_time_steps.size();
605   int ii=0;
606   std::set<int> idsToDel;
607   for(const int *id=startIds;id!=endIds;id++,ii++)
608     {
609       if(*id>=0 && *id<maxId)
610         {
611           idsToDel.insert(*id);
612         }
613       else
614         {
615           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
616           throw INTERP_KERNEL::Exception(oss.str());
617         }
618     }
619   for(int iii=0;iii<maxId;iii++)
620     if(idsToDel.find(iii)==idsToDel.end())
621       newTS.push_back(_time_steps[iii]);
622   _time_steps=newTS;
623 }
624
625 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
626 {
627   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
628   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
629   if(nbOfEntriesToKill==0)
630     return ;
631   std::size_t sz=_time_steps.size();
632   std::vector<bool> b(sz,true);
633   int j=bg;
634   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
635     b[j]=false;
636   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
637   for(std::size_t i=0;i<sz;i++)
638     if(b[i])
639       newTS.push_back(_time_steps[i]);
640   _time_steps=newTS;
641 }
642
643 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
644 {
645   int ret=0;
646   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
647   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
648     {
649       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
650       if(tmp)
651         {
652           int it2,ord;
653           tmp->getTime(it2,ord);
654           if(it2==iteration && order==ord)
655             return ret;
656           else
657             oss << "(" << it2 << ","  << ord << "), ";
658         }
659     }
660   throw INTERP_KERNEL::Exception(oss.str());
661 }
662
663 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
664 {
665   int ret=0;
666   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
667   oss.precision(15);
668   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
669     {
670       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
671       if(tmp)
672         {
673           int it2,ord;
674           double ti=tmp->getTime(it2,ord);
675           if(fabs(time-ti)<eps)
676             return ret;
677           else
678             oss << ti << ", ";
679         }
680     }
681   throw INTERP_KERNEL::Exception(oss.str());
682 }
683
684 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
685 {
686   int lgth=_time_steps.size();
687   std::vector< std::pair<int,int> > ret(lgth);
688   for(int i=0;i<lgth;i++)
689     _time_steps[i]->fillIteration(ret[i]);
690   return ret;
691 }
692
693 /*!
694  * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
695  * This method returns two things.
696  * - The absolute dimension of 'this' in first parameter. 
697  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
698  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
699  *
700  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
701  * Only these 3 discretizations will be taken into account here.
702  *
703  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
704  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
705  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
706  *
707  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
708  * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
709  * 
710  * Let's consider the typical following case :
711  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
712  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
713  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
714  *   TETRA4 and SEG2
715  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
716  *
717  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
718  * 
719  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
720  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
721  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
722  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
723  */
724 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
725 {
726   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
727 }
728
729 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
730 {
731   if(pos<0 || pos>=(int)_time_steps.size())
732     {
733       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
734       throw INTERP_KERNEL::Exception(oss.str());
735     }
736   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
737   if(item==0)
738     {
739       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
740       oss << "\nTry to use following method eraseEmptyTS !";
741       throw INTERP_KERNEL::Exception(oss.str());
742     }
743   return item;
744 }
745
746 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
747 {
748   if(pos<0 || pos>=(int)_time_steps.size())
749     {
750       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
751       throw INTERP_KERNEL::Exception(oss.str());
752     }
753   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
754   if(item==0)
755     {
756       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
757       oss << "\nTry to use following method eraseEmptyTS !";
758       throw INTERP_KERNEL::Exception(oss.str());
759     }
760   return item;
761 }
762
763 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
764 {
765   std::vector<std::string> ret;
766   std::set<std::string> ret2;
767   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
768     {
769       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
770       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
771         if(ret2.find(*it2)==ret2.end())
772           {
773             ret.push_back(*it2);
774             ret2.insert(*it2);
775           }
776     }
777   return ret;
778 }
779
780 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
781 {
782   std::vector<std::string> ret;
783   std::set<std::string> ret2;
784   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
785     {
786       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
787       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
788         if(ret2.find(*it2)==ret2.end())
789           {
790             ret.push_back(*it2);
791             ret2.insert(*it2);
792           }
793     }
794   return ret;
795 }
796
797 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
798 {
799   std::vector<std::string> ret;
800   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
801     {
802       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
803       ret.insert(ret.end(),tmp.begin(),tmp.end());
804     }
805   return ret;
806 }
807
808 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
809 {
810   std::vector<std::string> ret;
811   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
812     {
813       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
814       ret.insert(ret.end(),tmp.begin(),tmp.end());
815     }
816   return ret;
817 }
818
819 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
820 {
821   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
822     (*it)->changePflsRefsNamesGen2(mapOfModif);
823 }
824
825 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
826 {
827   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
828     (*it)->changeLocsRefsNamesGen2(mapOfModif);
829 }
830
831 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
832 {
833   int lgth=_time_steps.size();
834   std::vector< std::vector<TypeOfField> > ret(lgth);
835   for(int i=0;i<lgth;i++)
836     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
837   return ret;
838 }
839
840 /*!
841  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
842  */
843 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
844 {
845   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
846 }
847
848 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
849 {
850   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
851   std::size_t i=0;
852   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
853     {
854       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
855         ret->_time_steps[i]=(*it)->deepCopy();
856     }
857   return ret.retn();
858 }
859
860 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
861 {
862   std::size_t sz(_infos.size()),sz2(_time_steps.size());
863   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
864   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
865   for(std::size_t i=0;i<sz;i++)
866     {
867       ret[i]=shallowCpy();
868       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
869     }
870   for(std::size_t i=0;i<sz2;i++)
871     {
872       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
873       if(ret1.size()!=sz)
874         {
875           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
876           throw INTERP_KERNEL::Exception(oss.str());
877         }
878       ts[i]=ret1;
879     }
880   for(std::size_t i=0;i<sz;i++)
881     for(std::size_t j=0;j<sz2;j++)
882       ret[i]->_time_steps[j]=ts[j][i];
883   return ret;
884 }
885
886 /*!
887  * This method splits into discretization each time steps in \a this.
888  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
889  */
890 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
891 {
892   std::size_t sz(_time_steps.size());
893   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
894   for(std::size_t i=0;i<sz;i++)
895     {
896       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
897       if(!timeStep)
898         {
899           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
900           throw INTERP_KERNEL::Exception(oss.str());
901         }
902       items[i]=timeStep->splitDiscretizations();  
903     }
904   //
905   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
906   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
907   std::vector< TypeOfField > types;
908   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
909     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
910       {
911         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
912         if(ts.size()!=1)
913           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
914         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
915         if(it2==types.end())
916           types.push_back(ts[0]);
917       }
918   ret.resize(types.size()); ret2.resize(types.size());
919   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
920     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
921       {
922         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
923         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
924         ret2[pos].push_back(*it1);
925       }
926   for(std::size_t i=0;i<types.size();i++)
927     {
928       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
929       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
930         elt->pushBackTimeStep(*it1);//also updates infos in elt
931       ret[i]=elt;
932       elt->MEDFileFieldNameScope::operator=(*this);
933     }
934   return ret;
935 }
936
937 /*!
938  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
939  */
940 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
941 {
942   std::size_t sz(_time_steps.size());
943   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
944   std::size_t szOut(std::numeric_limits<std::size_t>::max());
945   for(std::size_t i=0;i<sz;i++)
946     {
947       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
948       if(!timeStep)
949         {
950           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
951           throw INTERP_KERNEL::Exception(oss.str());
952         }
953       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
954       if(szOut==std::numeric_limits<std::size_t>::max())
955         szOut=items[i].size();
956       else
957         if(items[i].size()!=szOut)
958           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
959     }
960   if(szOut==std::numeric_limits<std::size_t>::max())
961     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
962   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
963   for(std::size_t i=0;i<szOut;i++)
964     {
965       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
966       for(std::size_t j=0;j<sz;j++)
967         elt->pushBackTimeStep(items[j][i]);
968       ret[i]=elt;
969       elt->MEDFileFieldNameScope::operator=(*this);
970     }
971   return ret;
972 }
973
974 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
975 {
976   setName(field->getName());
977   if(field->getMesh())
978     setMeshName(field->getMesh()->getName());
979   if(_name.empty())
980     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
981   if(!arr)
982     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
983   _infos=arr->getInfoOnComponents();
984 }
985
986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
987 {
988   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
989   if(_name!=field->getName())
990     {
991       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
992       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
993       throw INTERP_KERNEL::Exception(oss.str());
994     }
995   if(!arr)
996     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
997   checkThatComponentsMatch(arr->getInfoOnComponents());
998 }
999
1000 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
1001 {
1002   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
1003   if(getInfo().size()!=compos.size())
1004     {
1005       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
1006       oss << " number of components of element to append (" << compos.size() << ") !";
1007       throw INTERP_KERNEL::Exception(oss.str());
1008     }
1009   if(_infos!=compos)
1010     {
1011       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
1012       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
1013       oss << " But compo in input fields are : ";
1014       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
1015       oss << " !";
1016       throw INTERP_KERNEL::Exception(oss.str());
1017     }
1018 }
1019
1020 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
1021 {
1022   std::size_t sz=_infos.size();
1023   int j=0;
1024   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
1025     {
1026       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
1027       if(elt)
1028         if(elt->getInfo().size()!=sz)
1029           {
1030             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
1031             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
1032             throw INTERP_KERNEL::Exception(oss.str());
1033           }
1034     }
1035 }
1036
1037 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1038 {
1039   if(!field)
1040     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1041   if(!_time_steps.empty())
1042     checkCoherencyOfTinyInfo(field,arr);
1043   MEDFileAnyTypeField1TSWithoutSDA *objC(createNew1TSWithoutSDAEmptyInstance());
1044   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
1045   {
1046     MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
1047     objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this);
1048   }
1049   copyTinyInfoFrom(field,arr);
1050   _time_steps.push_back(obj);
1051 }
1052
1053 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
1054 {
1055   if(!field)
1056     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
1057   if(!_time_steps.empty())
1058     checkCoherencyOfTinyInfo(field,arr);
1059   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
1060   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
1061   {
1062     MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
1063     objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this);
1064   }
1065   copyTinyInfoFrom(field,arr);
1066   setMeshName(objC->getMeshName());
1067   _time_steps.push_back(obj);
1068 }
1069
1070 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
1071 {
1072   int sz=(int)_time_steps.size();
1073   if(i<0 || i>=sz)
1074     {
1075       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
1076       throw INTERP_KERNEL::Exception(oss.str());
1077     }
1078   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
1079   if(tsPtr)
1080     {
1081       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
1082         {
1083           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
1084           throw INTERP_KERNEL::Exception(oss.str());
1085         }
1086     }
1087   _time_steps[i]=ts;
1088 }
1089
1090 //= MEDFileFieldMultiTSWithoutSDA
1091
1092 /*!
1093  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
1094  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
1095  */
1096 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
1097 {
1098   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
1099   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
1100   if(!myF1TSC)
1101     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
1102   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
1103 }
1104
1105 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
1106 {
1107   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
1108   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
1109   int i=0;
1110   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
1111     {
1112       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
1113       if(eltToConv)
1114         {
1115           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
1116           if(!eltToConvC)
1117             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
1118           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
1119           ret->setIteration(i,elt);
1120         }
1121     }
1122   return ret.retn();
1123 }
1124
1125 //= MEDFileAnyTypeFieldMultiTS
1126
1127 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
1128 {
1129 }
1130
1131 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1132 try:MEDFileFieldGlobsReal(fid)
1133 {
1134   _content=BuildContentFrom(fid,loadAll,ms);
1135   loadGlobals(fid);
1136 }
1137 catch(INTERP_KERNEL::Exception& e)
1138 {
1139     throw e;
1140 }
1141
1142 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1143 {
1144   med_field_type typcha;
1145   std::vector<std::string> infos;
1146   std::string dtunit;
1147   std::string meshName;
1148   int i(-1);
1149   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit,meshName);
1150   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1151   switch(typcha)
1152   {
1153     case MED_FLOAT64:
1154       {
1155         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1156         break;
1157       }
1158     case MED_INT32:
1159       {
1160         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1161         break;
1162       }
1163     case MED_FLOAT32:
1164       {
1165         ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1166         break;
1167       }
1168     case MED_INT:
1169       {
1170         if(sizeof(med_int)==sizeof(int))
1171           {
1172             ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
1173             break;
1174           }
1175       }
1176     default:
1177       {
1178         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !";
1179         throw INTERP_KERNEL::Exception(oss.str());
1180       }
1181   }
1182   ret->setMeshName(meshName);
1183   ret->setDtUnit(dtunit.c_str());
1184   return ret.retn();
1185 }
1186
1187 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
1188 {
1189   med_field_type typcha;
1190   //
1191   std::vector<std::string> infos;
1192   std::string dtunit,fieldName,meshName;
1193   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1194   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
1195   switch(typcha)
1196   {
1197     case MED_FLOAT64:
1198       {
1199         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1200         break;
1201       }
1202     case MED_INT32:
1203       {
1204         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1205         break;
1206       }
1207     case MED_FLOAT32:
1208       {
1209         ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1210         break;
1211       }
1212     case MED_INT:
1213       {
1214         if(sizeof(med_int)==sizeof(int))
1215           {
1216             ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
1217             break;
1218           }
1219       }
1220     default:
1221       {
1222         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !";
1223         throw INTERP_KERNEL::Exception(oss.str());
1224       }
1225   }
1226   ret->setMeshName(meshName);
1227   ret->setDtUnit(dtunit.c_str());
1228   return ret.retn();
1229 }
1230
1231 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
1232 {
1233   if(!c)
1234     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1235   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
1236     {
1237       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
1238       ret->_content=c;  c->incrRef();
1239       return ret.retn();
1240     }
1241   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
1242     {
1243       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
1244       ret->_content=c;  c->incrRef();
1245       return ret.retn();
1246     }
1247   if(dynamic_cast<const MEDFileFloatFieldMultiTSWithoutSDA *>(c))
1248     {
1249       MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
1250       ret->_content=c;  c->incrRef();
1251       return ret.retn();
1252     }
1253   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1254 }
1255
1256 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
1257 {
1258   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
1259   std::string fileName(FileNameFromFID(fid));
1260   ret->setFileName(fileName);
1261   return ret;
1262 }
1263
1264 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1265 try:MEDFileFieldGlobsReal(fid)
1266 {
1267   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1268   loadGlobals(fid);
1269 }
1270 catch(INTERP_KERNEL::Exception& e)
1271 {
1272     throw e;
1273 }
1274
1275 //= MEDFileAnyTypeFieldMultiTS
1276
1277 /*!
1278  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
1279  * that has been read from a specified MED file.
1280  *  \param [in] fileName - the name of the MED file to read.
1281  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1282  *          is to delete this field using decrRef() as it is no more needed.
1283  *  \throw If reading the file fails.
1284  */
1285 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
1286 {
1287   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1288   return New(fid,loadAll);
1289 }
1290
1291 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
1292 {
1293   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
1294   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1295   ret->loadGlobals(fid);
1296   return ret.retn();
1297 }
1298
1299 /*!
1300  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
1301  * that has been read from a specified MED file.
1302  *  \param [in] fileName - the name of the MED file to read.
1303  *  \param [in] fieldName - the name of the field to read.
1304  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
1305  *          is to delete this field using decrRef() as it is no more needed.
1306  *  \throw If reading the file fails.
1307  *  \throw If there is no field named \a fieldName in the file.
1308  */
1309 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1310 {
1311   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1312   return New(fid,fieldName,loadAll);
1313 }
1314
1315 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1316 {
1317   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1318   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
1319   ret->loadGlobals(fid);
1320   return ret.retn();
1321 }
1322
1323 /*!
1324  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1325  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1326  *
1327  * \warning this is a shallow copy constructor
1328  */
1329 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
1330 {
1331   if(!shallowCopyOfContent)
1332     {
1333       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
1334       otherPtr->incrRef();
1335       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
1336     }
1337   else
1338     {
1339       _content=other.shallowCpy();
1340     }
1341 }
1342
1343 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
1344 {
1345   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1346   if(!ret)
1347     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
1348   return ret;
1349 }
1350
1351 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
1352 {
1353   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
1354   if(!ret)
1355     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
1356   return ret;
1357 }
1358
1359 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
1360 {
1361   return contentNotNullBase()->getPflsReallyUsed2();
1362 }
1363
1364 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
1365 {
1366   return contentNotNullBase()->getLocsReallyUsed2();
1367 }
1368
1369 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
1370 {
1371   return contentNotNullBase()->getPflsReallyUsedMulti2();
1372 }
1373
1374 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
1375 {
1376   return contentNotNullBase()->getLocsReallyUsedMulti2();
1377 }
1378
1379 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1380 {
1381   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
1382 }
1383
1384 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1385 {
1386   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
1387 }
1388
1389 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
1390 {
1391   return contentNotNullBase()->getNumberOfTS();
1392 }
1393
1394 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
1395 {
1396   contentNotNullBase()->eraseEmptyTS();
1397 }
1398
1399 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
1400 {
1401   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
1402 }
1403
1404 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
1405 {
1406   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
1407 }
1408
1409 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
1410 {
1411   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
1412   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1413   ret->_content=c;
1414   return ret.retn();
1415 }
1416
1417 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
1418 {
1419   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
1420   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1421   ret->_content=c;
1422   return ret.retn();
1423 }
1424
1425 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
1426 {
1427   return contentNotNullBase()->getIterations();
1428 }
1429
1430 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
1431 {
1432   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
1433     pushBackTimeStep(*it);
1434 }
1435
1436 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
1437 {
1438   if(!fmts)
1439     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
1440   int nbOfTS(fmts->getNumberOfTS());
1441   for(int i=0;i<nbOfTS;i++)
1442     {
1443       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
1444       pushBackTimeStep(elt);
1445     }
1446 }
1447
1448 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
1449 {
1450   if(!f1ts)
1451     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
1452   checkCoherencyOfType(f1ts);
1453   f1ts->incrRef();
1454   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
1455   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
1456   c->incrRef();
1457   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
1458   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
1459     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
1460   _content->pushBackTimeStep(cSafe);
1461   appendGlobs(*f1ts,1e-12);
1462 }
1463
1464 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
1465 {
1466   contentNotNullBase()->synchronizeNameScope();
1467 }
1468
1469 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
1470 {
1471   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
1472 }
1473
1474 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
1475 {
1476   return contentNotNullBase()->getPosGivenTime(time,eps);
1477 }
1478
1479 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
1480 {
1481   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
1482 }
1483
1484 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
1485 {
1486   return contentNotNullBase()->getTypesOfFieldAvailable();
1487 }
1488
1489 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
1490 {
1491   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1492 }
1493
1494 std::string MEDFileAnyTypeFieldMultiTS::getName() const
1495 {
1496   return contentNotNullBase()->getName();
1497 }
1498
1499 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
1500 {
1501   contentNotNullBase()->setName(name);
1502 }
1503
1504 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
1505 {
1506   return contentNotNullBase()->getDtUnit();
1507 }
1508
1509 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
1510 {
1511   contentNotNullBase()->setDtUnit(dtUnit);
1512 }
1513
1514 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
1515 {
1516   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
1517 }
1518
1519 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
1520 {
1521   return contentNotNullBase()->getTimeSteps(ret1);
1522 }
1523
1524 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
1525 {
1526   return contentNotNullBase()->getMeshName();
1527 }
1528
1529 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
1530 {
1531   contentNotNullBase()->setMeshName(newMeshName);
1532 }
1533
1534 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1535 {
1536   return contentNotNullBase()->changeMeshNames(modifTab);
1537 }
1538
1539 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
1540 {
1541   return contentNotNullBase()->getInfo();
1542 }
1543
1544 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
1545 {
1546   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
1547 }
1548
1549 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
1550 {
1551   return contentNotNullBase()->setInfo(info);
1552 }
1553
1554 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
1555 {
1556   const std::vector<std::string> ret=getInfo();
1557   return (int)ret.size();
1558 }
1559
1560 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
1561 {
1562   writeGlobals(fid,*this);
1563   contentNotNullBase()->writeLL(fid,*this);
1564 }
1565
1566 /*!
1567  * This method alloc the arrays and load potentially huge arrays contained in this field.
1568  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
1569  * This method can be also called to refresh or reinit values from a file.
1570  * 
1571  * \throw If the fileName is not set or points to a non readable MED file.
1572  */
1573 void MEDFileAnyTypeFieldMultiTS::loadArrays()
1574 {
1575   if(getFileName().empty())
1576     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
1577   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1578   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
1579 }
1580
1581 /*!
1582  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
1583  * But once data loaded once, this method does nothing.
1584  * 
1585  * \throw If the fileName is not set or points to a non readable MED file.
1586  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
1587  */
1588 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
1589 {
1590   if(!getFileName().empty())
1591     {
1592       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
1593       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
1594     }
1595 }
1596
1597 /*!
1598  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
1599  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
1600  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
1601  * 
1602  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
1603  */
1604 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
1605 {
1606   contentNotNullBase()->unloadArrays();
1607 }
1608
1609 /*!
1610  * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
1611  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
1612  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
1613  * 
1614  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
1615  */
1616 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
1617 {
1618   if(!getFileName().empty())
1619     contentNotNullBase()->unloadArrays();
1620 }
1621
1622 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
1623 {
1624   std::ostringstream oss;
1625   contentNotNullBase()->simpleRepr(0,oss,-1);
1626   simpleReprGlobs(oss);
1627   return oss.str();
1628 }
1629
1630 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
1631 {
1632   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
1633 }
1634
1635 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
1636 {
1637   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
1638   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
1639   return ret;
1640 }
1641
1642 /*!
1643  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
1644  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
1645  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
1646  */
1647 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
1648 {
1649   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1650   if(!content)
1651     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
1652   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
1653   std::size_t sz(contentsSplit.size());
1654   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1655   for(std::size_t i=0;i<sz;i++)
1656     {
1657       ret[i]=shallowCpy();
1658       ret[i]->_content=contentsSplit[i];
1659     }
1660   return ret;
1661 }
1662
1663 /*!
1664  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
1665  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
1666  */
1667 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
1668 {
1669   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1670   if(!content)
1671     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
1672   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
1673   std::size_t sz(contentsSplit.size());
1674   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1675   for(std::size_t i=0;i<sz;i++)
1676     {
1677       ret[i]=shallowCpy();
1678       ret[i]->_content=contentsSplit[i];
1679     }
1680   return ret;
1681 }
1682
1683 /*!
1684  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
1685  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
1686  */
1687 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
1688 {
1689   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
1690   if(!content)
1691     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
1692   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
1693   std::size_t sz(contentsSplit.size());
1694   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
1695   for(std::size_t i=0;i<sz;i++)
1696     {
1697       ret[i]=shallowCpy();
1698       ret[i]->_content=contentsSplit[i];
1699     }
1700   return ret;
1701 }
1702
1703 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
1704 {
1705   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
1706   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
1707     ret->_content=_content->deepCopy();
1708   ret->deepCpyGlobs(*this);
1709   return ret.retn();
1710 }
1711
1712 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
1713 {
1714   return _content;
1715 }
1716
1717 /*!
1718  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1719  *  \param [in] iteration - the iteration number of a required time step.
1720  *  \param [in] order - the iteration order number of required time step.
1721  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
1722  *          delete this field using decrRef() as it is no more needed.
1723  *  \throw If there is no required time step in \a this field.
1724  */
1725 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
1726 {
1727   int pos=getPosOfTimeStep(iteration,order);
1728   return getTimeStepAtPos(pos);
1729 }
1730
1731 /*!
1732  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
1733  *  \param [in] time - the time of the time step of interest.
1734  *  \param [in] eps - a precision used to compare time values.
1735  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
1736  *          delete this field using decrRef() as it is no more needed.
1737  *  \throw If there is no required time step in \a this field.
1738  */
1739 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
1740 {
1741   int pos=getPosGivenTime(time,eps);
1742   return getTimeStepAtPos(pos);
1743 }
1744
1745 /*!
1746  * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
1747  * The float64 value of time attached to the pair of integers are not considered here.
1748  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
1749  *
1750  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
1751  * \throw If there is a null pointer in \a vectFMTS.
1752  */
1753 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
1754 {
1755   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
1756   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1757   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1758   while(!lstFMTS.empty())
1759     {
1760       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1761       MEDFileAnyTypeFieldMultiTS *curIt(*it);
1762       if(!curIt)
1763         throw INTERP_KERNEL::Exception(msg);
1764       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
1765       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1766       elt.push_back(curIt); it=lstFMTS.erase(it);
1767       while(it!=lstFMTS.end())
1768         {
1769           curIt=*it;
1770           if(!curIt)
1771             throw INTERP_KERNEL::Exception(msg);
1772           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
1773           if(refIts==curIts)
1774             { elt.push_back(curIt); it=lstFMTS.erase(it); }
1775           else
1776             it++;
1777         }
1778       ret.push_back(elt);
1779     }
1780   return ret;
1781 }
1782
1783 /*!
1784  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
1785  * All returned instances in a subvector can be safely loaded, rendered along time
1786  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
1787  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
1788  * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
1789  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
1790  * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
1791  *
1792  * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
1793  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
1794  * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
1795  * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
1796  *
1797  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
1798  * \throw If an element in \a vectFMTS change of spatial discretization along time.
1799  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
1800  * \thorw If some elements in \a vectFMTS do not have the same times steps.
1801  * \throw If mesh is null.
1802  * \throw If an element in \a vectFMTS is null.
1803  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
1804  */
1805 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
1806 {
1807   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
1808   if(!mesh)
1809     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
1810   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1811   if(vectFMTS.empty())
1812     return ret;
1813   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
1814   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
1815   if(!frstElt)
1816     throw INTERP_KERNEL::Exception(msg);
1817   std::size_t i=0;
1818   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
1819   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
1820   for(;it!=vectFMTS.end();it++,i++)
1821     {
1822       if(!(*it))
1823         throw INTERP_KERNEL::Exception(msg);
1824       TypeOfField tof0,tof1;
1825       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
1826         {
1827           if(tof1!=ON_NODES)
1828             vectFMTSNotNodes.push_back(*it);
1829           else
1830             vectFMTSNodes.push_back(*it);
1831         }
1832       else
1833         vectFMTSNotNodes.push_back(*it);
1834     }
1835   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
1836   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
1837   ret=retCell;
1838   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
1839     {
1840       i=0;
1841       bool isFetched(false);
1842       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
1843         {
1844           if((*it0).empty())
1845             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
1846           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
1847             { ret[i].push_back(*it2); isFetched=true; }
1848         }
1849       if(!isFetched)
1850         {
1851           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
1852           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
1853           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
1854         }
1855     }
1856   fsc=cmps;
1857   return ret;
1858 }
1859
1860 /*!
1861  * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
1862  * \param [out] cmps - same size than the returned vector.
1863  */
1864 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
1865 {
1866   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
1867   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
1868   while(!lstFMTS.empty())
1869     {
1870       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
1871       MEDFileAnyTypeFieldMultiTS *ref(*it);
1872       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
1873       elt.push_back(ref); it=lstFMTS.erase(it);
1874       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
1875       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
1876       while(it!=lstFMTS.end())
1877         {
1878           MEDFileAnyTypeFieldMultiTS *curIt(*it);
1879           if(cmp->isEqual(curIt))
1880             { elt.push_back(curIt); it=lstFMTS.erase(it); }
1881           else
1882             it++;
1883         }
1884       ret.push_back(elt); cmps.push_back(cmp);
1885     }
1886   return ret;
1887 }
1888
1889 /*!
1890  * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
1891  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
1892  *
1893  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
1894  * \throw If \a f0 or \a f1 change of spatial discretization along time.
1895  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
1896  * \thorw If \a f0 and \a f1 do not have the same times steps.
1897  * \throw If mesh is null.
1898  * \throw If \a f0 or \a f1 is null.
1899  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
1900  */
1901 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
1902 {
1903   if(!mesh)
1904     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
1905   if(!f0 || !f1)
1906     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
1907   if(f0->getMeshName()!=mesh->getName())
1908     {
1909       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1910       throw INTERP_KERNEL::Exception(oss.str());
1911     }
1912   if(f1->getMeshName()!=mesh->getName())
1913     {
1914       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
1915       throw INTERP_KERNEL::Exception(oss.str());
1916     }
1917   int nts=f0->getNumberOfTS();
1918   if(nts!=f1->getNumberOfTS())
1919     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
1920   if(nts==0)
1921     return nts;
1922   for(int i=0;i<nts;i++)
1923     {
1924       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
1925       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
1926       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
1927       if(tofs0.size()!=1 || tofs1.size()!=1)
1928         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
1929       if(i!=0)
1930         {
1931           if(tof0!=tofs0[0] || tof1!=tofs1[0])
1932             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
1933         }
1934       else
1935         { tof0=tofs0[0]; tof1=tofs1[0]; }
1936       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
1937         {
1938           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
1939           throw INTERP_KERNEL::Exception(oss.str());
1940         }
1941       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
1942         {
1943           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
1944           throw INTERP_KERNEL::Exception(oss.str());
1945         }
1946       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
1947         {
1948           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
1949           throw INTERP_KERNEL::Exception(oss.str());
1950         }
1951     }
1952   return nts;
1953 }
1954
1955 template<class T>
1956 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
1957 {
1958   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
1959   if(f1tss.empty())
1960     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
1961   std::size_t sz(f1tss.size()),i(0);
1962   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
1963   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
1964     {
1965       typename MLFieldTraits<T>::F1TSType const *elt(*it);
1966       if(!elt)
1967         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
1968       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
1969     }
1970   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
1971   if(!retc)
1972     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
1973   retc->aggregate(f1tsw,dts);
1974   ret->setDtUnit(f1tss[0]->getDtUnit());
1975   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
1976 }
1977
1978 template<class T>
1979 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
1980 {
1981   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
1982   if(fmtss.empty())
1983     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
1984   std::size_t sz(fmtss.size());
1985   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
1986     {
1987       typename MLFieldTraits<T>::FMTSType const *elt(*it);
1988       if(!elt)
1989         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
1990     }
1991   int nbTS(fmtss[0]->getNumberOfTS());
1992   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
1993     if((*it)->getNumberOfTS()!=nbTS)
1994       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
1995   for(int iterTS=0;iterTS<nbTS;iterTS++)
1996     {
1997       std::size_t i(0);
1998       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
1999       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
2000       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
2001         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
2002       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
2003       ret->pushBackTimeStep(f1ts);
2004       ret->setDtUnit(f1ts->getDtUnit());
2005     }
2006   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
2007 }
2008
2009 /*!
2010  * \a dts and \a ftmss are expected to have same size.
2011  */
2012 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
2013 {
2014   if(fmtss.empty())
2015     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
2016   std::size_t sz(fmtss.size());
2017   std::vector<const MEDFileFieldMultiTS *> fmtss1;
2018   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
2019   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
2020     {
2021       if(!(*it))
2022         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
2023       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
2024       if(elt1)
2025         {
2026           fmtss1.push_back(elt1);
2027           continue;
2028         }
2029       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
2030       if(elt2)
2031         {
2032           fmtss2.push_back(elt2);
2033           continue;
2034         }
2035       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
2036     }
2037   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
2038     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
2039   if(fmtss1.size()==sz)
2040     return AggregateHelperFMTS<double>(fmtss1,dts);
2041   if(fmtss2.size()!=sz)
2042     return AggregateHelperFMTS<int>(fmtss2,dts);
2043   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
2044 }
2045
2046 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
2047 {
2048   return new MEDFileAnyTypeFieldMultiTSIterator(this);
2049 }
2050
2051 //= MEDFileFieldMultiTS
2052
2053 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
2054 {
2055   return new MEDFileFieldMultiTS(*this);
2056 }
2057
2058 /*!
2059  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2060  * following the given input policy.
2061  *
2062  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2063  *                            By default (true) the globals are deeply copied.
2064  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
2065  */
2066 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
2067 {
2068   MCAuto<MEDFileIntFieldMultiTS> ret;
2069   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
2070   if(content)
2071     {
2072       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
2073       if(!contc)
2074         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2075       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
2076       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
2077     }
2078   else
2079     ret=MEDFileIntFieldMultiTS::New();
2080   if(isDeepCpyGlobs)
2081     ret->deepCpyGlobs(*this);
2082   else
2083     ret->shallowCpyGlobs(*this);
2084   return ret.retn();
2085 }
2086
2087 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2088 try:MEDFileTemplateFieldMultiTS<double>(fid,loadAll,ms)
2089 {
2090 }
2091 catch(INTERP_KERNEL::Exception& e)
2092 { throw e; }
2093
2094 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2095 try:MEDFileTemplateFieldMultiTS<double>(fid,fieldName,loadAll,ms,entities)
2096 {
2097 }
2098 catch(INTERP_KERNEL::Exception& e)
2099 { throw e; }
2100
2101 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS<double>(other,shallowCopyOfContent)
2102 {
2103 }
2104
2105 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2106 {
2107   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
2108 }
2109
2110 //= MEDFileAnyTypeFieldMultiTSIterator
2111
2112 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
2113 {
2114   if(fmts)
2115     {
2116       fmts->incrRef();
2117       _nb_iter=fmts->getNumberOfTS();
2118     }
2119 }
2120
2121 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
2122 {
2123 }
2124
2125 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
2126 {
2127   if(_iter_id<_nb_iter)
2128     {
2129       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
2130       if(fmts)
2131         return fmts->getTimeStepAtPos(_iter_id++);
2132       else
2133         return 0;
2134     }
2135   else
2136     return 0;
2137 }
2138
2139 //= MEDFileIntFieldMultiTS