]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
End of refacto. Now ready for MEDFilemem implementation and for selection of MED...
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2016  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 (CEA/DEN)
20
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileUtilities.hxx"
26 #include "MEDFileSafeCaller.txx"
27 #include "MEDFileFieldOverView.hxx"
28
29 #include "MEDCouplingFieldDouble.hxx"
30 #include "MEDCouplingFieldTemplate.hxx"
31 #include "MEDCouplingFieldDiscretization.hxx"
32
33 #include "InterpKernelAutoPtr.hxx"
34 #include "CellModel.hxx"
35
36 #include <algorithm>
37 #include <iterator>
38
39 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
40 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
41 extern med_geometry_type typmainoeud[1];
42 extern med_geometry_type typmai3[34];
43
44 using namespace MEDCoupling;
45
46 template class MEDFileField1TSTemplateWithoutSDA<int>;
47 template class MEDFileField1TSTemplateWithoutSDA<double>;
48
49 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
50 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51
52 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 {
54   return new MEDFileFieldLoc(fid,locName);
55 }
56
57 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 {
59   return new MEDFileFieldLoc(fid,id);
60 }
61
62 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
63 {
64   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
65 }
66
67 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 {
69   med_geometry_type geotype;
70   med_geometry_type sectiongeotype;
71   int nsectionmeshcell;
72   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
74   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
75   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
76   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
77   _nb_node_per_cell=cm.getNumberOfNodes();
78   _ref_coo.resize(_dim*_nb_node_per_cell);
79   _gs_coo.resize(_dim*_nb_gauss_pt);
80   _w.resize(_nb_gauss_pt);
81   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
82 }
83
84 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 {
86   med_geometry_type geotype;
87   med_geometry_type sectiongeotype;
88   int nsectionmeshcell;
89   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
92   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
93   _name=locName;
94   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
95   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
96   _nb_node_per_cell=cm.getNumberOfNodes();
97   _ref_coo.resize(_dim*_nb_node_per_cell);
98   _gs_coo.resize(_dim*_nb_gauss_pt);
99   _w.resize(_nb_gauss_pt);
100   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
101 }
102
103 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
104                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
105                                      _w(w)
106 {
107   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
108   _dim=cm.getDimension();
109   _nb_node_per_cell=cm.getNumberOfNodes();
110   _nb_gauss_pt=_w.size();
111 }
112
113 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 {
115   return new MEDFileFieldLoc(*this);
116 }
117
118 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 {
120   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
121 }
122
123 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 {
125   return std::vector<const BigMemoryObject *>();
126 }
127
128 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 {
130   static const char OFF7[]="\n    ";
131   oss << "\"" << _name << "\"" << OFF7;
132   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
133   oss << "Dimension=" << _dim << OFF7;
134   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
135   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
136   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
138   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
139 }
140
141 void MEDFileFieldLoc::setName(const std::string& name)
142 {
143   _name=name;
144 }
145
146 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 {
148   if(_name!=other._name)
149     return false;
150   if(_dim!=other._dim)
151     return false;
152   if(_nb_gauss_pt!=other._nb_gauss_pt)
153     return false;
154   if(_nb_node_per_cell!=other._nb_node_per_cell)
155     return false;
156   if(_geo_type!=other._geo_type)
157     return false;
158   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159     return false;
160   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161     return false;
162   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
163     return false;
164
165   return true;
166 }
167
168 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 {
170   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
171 }
172
173 std::string MEDFileFieldLoc::repr() const
174 {
175   std::ostringstream oss; oss.precision(15);
176   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
177   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
178   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
179   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
180   oss << "\n  - Ref coords are : ";
181   int sz=_ref_coo.size();
182   if(sz%_dim==0)
183     {
184       int nbOfTuples=sz/_dim;
185       for(int i=0;i<nbOfTuples;i++)
186         {
187           oss << "(";
188           for(int j=0;j<_dim;j++)
189             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
190           oss << ") ";
191         }
192     }
193   else
194     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
195   oss << "\n  - Gauss coords in reference element : ";
196   sz=_gs_coo.size();
197   if(sz%_dim==0)
198     {
199       int nbOfTuples=sz/_dim;
200       for(int i=0;i<nbOfTuples;i++)
201         {
202           oss << "(";
203           for(int j=0;j<_dim;j++)
204             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
205           oss << ") ";
206         }
207     }
208   else
209     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
210   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
211   return oss.str();
212 }
213
214 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 {
216   _type=field->getTypeOfField();
217   _start=start;
218   switch(_type)
219   {
220     case ON_CELLS:
221       {
222         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
223         _end=_start+nbOfCells;
224         _nval=nbOfCells;
225         break;
226       }
227     case ON_GAUSS_NE:
228       {
229         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
230         const int *arrPtr=arr->getConstPointer();
231         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
232         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
233         _nval=nbOfCells;
234         break;
235       }
236     case ON_GAUSS_PT:
237       {
238         const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
239         const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
240         const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241         if(!disc2)
242           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
243         const DataArrayInt *dai(disc2->getArrayOfDiscIds());
244         MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
245         const int *dai2Ptr(dai2->getConstPointer());
246         int nbi(gsLoc.getWeights().size());
247         MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
248         MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
249         const int *da3Ptr(da3->getConstPointer());
250         if(da3->getNumberOfTuples()!=nbOfCells)
251           {//profile : for gauss even in NoProfile !!!
252             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253             _profile=oss.str();
254             da3->setName(_profile.c_str());
255             glob.appendProfile(da3);
256           }
257         MCAuto<DataArrayInt> da4(DataArrayInt::New());
258         _nval=da3->getNbOfElems();
259         da4->alloc(_nval*nbi,1);
260         int *da4Ptr(da4->getPointer());
261         for(int i=0;i<_nval;i++)
262           {
263             int ref=dai2Ptr[offset+da3Ptr[i]];
264             for(int j=0;j<nbi;j++)
265               *da4Ptr++=ref+j;
266           }
267         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
268         _localization=oss2.str();
269         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
270         _end=_start+_nval*nbi;
271         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
272         break;
273       }
274     default:
275       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
276   }
277   start=_end;
278 }
279
280 /*!
281  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
282  * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
283  * \param [in] multiTypePfl is the end user profile specified in high level API
284  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
285  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
286  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
287  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
288  */
289 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
290 {
291   _profile.clear();
292   _type=field->getTypeOfField();
293   std::string pflName(multiTypePfl->getName());
294   std::ostringstream oss; oss << pflName;
295   if(_type!=ON_NODES)
296     {
297       if(!isPflAlone)
298         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
299     }
300   else
301     { oss << "_NODE"; }
302   if(locIds)
303     {
304       if(pflName.empty())
305         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
306       if(_type!=ON_GAUSS_PT)
307         {
308           locIds->setName(oss.str());
309           glob.appendProfile(locIds);
310           _profile=oss.str();
311         }
312     }
313   _start=start;
314   switch(_type)
315   {
316     case ON_NODES:
317       {
318         _nval=idsInPfl->getNumberOfTuples();
319         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
320         _end=_start+_nval;
321         break;
322       }
323     case ON_CELLS:
324       {
325         _nval=idsInPfl->getNumberOfTuples();
326         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
327         _end=_start+_nval;
328         break;
329       }
330     case ON_GAUSS_NE:
331       {
332         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
333         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
334         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
335         arr3->computeOffsetsFull();
336         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
337         int trueNval=tmp->getNumberOfTuples();
338         _nval=idsInPfl->getNumberOfTuples();
339         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
340         _end=_start+trueNval;
341         break;
342       }
343     case ON_GAUSS_PT:
344       {
345         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346         if(!disc2)
347           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
348         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
349         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
350         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
351         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
352         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353         //
354         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
355         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356         //
357         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358         int trueNval=0;
359         for(const int *pt=da4->begin();pt!=da4->end();pt++)
360           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
361         tmp->alloc(trueNval,1);
362         int *tmpPtr=tmp->getPointer();
363         for(const int *pt=da4->begin();pt!=da4->end();pt++)
364           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
365             *tmpPtr++=j;
366         //
367         _nval=da4->getNumberOfTuples();
368         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
369         _end=_start+trueNval;
370         oss << "_loc_" << _loc_id;
371         if(locIds)
372           {
373             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
374             da5->setName(oss.str());
375             glob.appendProfile(da5);
376             _profile=oss.str();
377           }
378         else
379           {
380             if(!da3->isIota(nbOfEltsInWholeMesh))
381               {
382                 da3->setName(oss.str());
383                 glob.appendProfile(da3);
384                 _profile=oss.str();
385               }
386           }
387         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
388         _localization=oss2.str();
389         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
390         break;
391       }
392     default:
393       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
394   }
395   start=_end;
396 }
397
398 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
399 {
400   _start=start;
401   _nval=arrr->getNumberOfTuples();
402   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
403   _end=_start+_nval;
404   start=_end;
405 }
406
407 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 {
409   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
410 }
411
412 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
413 {
414   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
415 }
416
417 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 {
419   return new MEDFileFieldPerMeshPerTypePerDisc(other);
420 }
421
422 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 {
424   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
425 }
426
427 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 {
429   std::vector<const BigMemoryObject *> ret(1);
430   ret[0]=(const PartDefinition*)_pd;
431   return ret;
432 }
433
434 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
435 {
436   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
437   ret->_father=father;
438   return ret.retn();
439 }
440
441 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
442 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
443 {
444   if(pd)
445     pd->incrRef();
446 }
447 catch(INTERP_KERNEL::Exception& e)
448 {
449     throw e;
450 }
451
452 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
453 {
454 }
455
456 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
457 {
458 }
459
460 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
461     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
462 {
463 }
464
465 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
466 {
467   const PartDefinition *pd(_pd);
468   if(!pd)
469     {
470       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471       int nbi,tmp1;
472       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
473       if(_end-_start!=nbValsInFile*nbi)
474         {
475           std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi <<  " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
476           throw INTERP_KERNEL::Exception(oss.str());
477         }
478       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
479     }
480   else
481     {
482       if(!_profile.empty())
483         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
484       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485       int profilesize,nbi;
486       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
487       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
488       if(spd)
489         {
490           int start,stop,step;
491           spd->getSlice(start,stop,step);
492           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
493           med_filter filter=MED_FILTER_INIT;
494           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
495                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
496                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
497                                    /*lastblocksize=useless because count=1*/0,&filter);
498           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
499           MEDfilterClose(&filter);
500           return ;
501         }
502       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
503       if(dpd)
504         {
505           dpd->checkConsistencyLight();
506           MCAuto<DataArrayInt> myIds(dpd->toDAI());
507           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
508           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
509           myIds->applyLin(1,-a);
510           int nbOfEltsToLoad(b-a+1);
511           med_filter filter=MED_FILTER_INIT;
512           {//TODO : manage int32 !
513             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
514             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
515             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
516                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
517                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
518                                      /*lastblocksize=useless because count=1*/0,&filter);
519             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
520             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
521             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
522             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523           }
524           MEDfilterClose(&filter);
525         }
526       else
527         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
528     }
529 }
530
531 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
532 {
533   return _father;
534 }
535
536 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 {
538   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
540   std::string fieldName(nasc.getName()),meshName(getMeshName());
541   int iteration(getIteration()),order(getOrder());
542   TypeOfField type(getType());
543   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
544   int profilesize,nbi;
545   med_geometry_type mgeoti;
546   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
547   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
548   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
549   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
550   const PartDefinition *pd(_pd);
551   if(!pd)
552     {
553       _nval=zeNVal;
554     }
555   else
556     {
557       if(!_profile.empty())
558         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
559       _nval=pd->getNumberOfElems();
560     }
561   _start=start;
562   _end=start+_nval*nbi;
563   start=_end;
564   if(type==ON_CELLS && !_localization.empty())
565     {
566       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
567         setType(ON_GAUSS_PT);
568       else
569         {
570           setType(ON_GAUSS_NE);
571           _localization.clear();
572         }
573     }
574 }
575
576 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
577 {
578   std::string fieldName(nasc.getName()),meshName(getMeshName());
579   int iteration(getIteration()),order(getOrder());
580   TypeOfField type(getType());
581   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
582   med_geometry_type mgeoti;
583   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
584   if(_start>_end)
585     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
586   if(_start==_end)
587     return ;
588   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
589   if(_start<0 || _start>=arr->getNumberOfTuples())
590     {
591       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
592       throw INTERP_KERNEL::Exception(oss.str());
593     }
594   if(_end<0 || _end>arr->getNumberOfTuples())
595     {
596       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
597       throw INTERP_KERNEL::Exception(oss.str());
598     }
599   int nbOfCompo(arr->getNumberOfComponents());
600   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
601   if(arrD)
602     {
603       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
604       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
605       return ;
606     }
607   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
608   if(arrI)
609     {
610       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
611       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
612       return ;
613     }
614   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
615 }
616
617 /*!
618  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
619  */
620 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
621 {
622   int delta=_end-_start;
623   _start=newValueOfStart;
624   _end=_start+delta;
625 }
626
627 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
628 {
629   return _father->getIteration();
630 }
631
632 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
633 {
634   return _father->getOrder();
635 }
636
637 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
638 {
639   return _father->getTime();
640 }
641
642 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
643 {
644   return _father->getMeshName();
645 }
646
647 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
648 {
649   const char startLine[]="    ## ";
650   std::string startLine2(bkOffset,' ');
651   startLine2+=startLine;
652   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
653   oss << startLine2 << "Localization #" << id << "." << std::endl;
654   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
655   delete tmp;
656   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
657   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
658   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
659 }
660
661 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
662 {
663   return _type;
664 }
665
666 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
667 {
668   types.insert(_type);
669 }
670
671 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
672 {
673   _type=newType;
674 }
675
676 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
677 {
678   return _father->getGeoType();
679 }
680
681 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
682 {
683   return _father->getNumberOfComponents();
684 }
685
686 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
687 {
688   return _end-_start;
689 }
690
691 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
692 {
693   return _father->getOrCreateAndGetArray();
694 }
695
696 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
697 {
698   const MEDFileFieldPerMeshPerType *fath=_father;
699   return fath->getOrCreateAndGetArray();
700 }
701
702 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
703 {
704   return _father->getInfo();
705 }
706
707 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
708 {
709   return _profile;
710 }
711
712 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
713 {
714   _profile=newPflName;
715 }
716
717 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
718 {
719   return _localization;
720 }
721
722 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
723 {
724   _localization=newLocName;
725 }
726
727 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
728 {
729   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
730     {
731       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
732         {
733           _profile=(*it2).second;
734           return;
735         }
736     }
737 }
738
739 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
740 {
741   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
742     {
743       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
744         {
745           _localization=(*it2).second;
746           return;
747         }
748     }
749 }
750
751 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
752 {
753   if(type!=_type)
754     return ;
755   dads.push_back(std::pair<int,int>(_start,_end));
756   geoTypes.push_back(getGeoType());
757   if(_profile.empty())
758     pfls.push_back(0);
759   else
760     {
761       pfls.push_back(glob->getProfile(_profile.c_str()));
762     }
763   if(_localization.empty())
764     locs.push_back(-1);
765   else
766     {
767       locs.push_back(glob->getLocalizationId(_localization.c_str()));
768     }
769 }
770
771 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
772 {
773   entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
774   startEntryId++;
775 }
776
777 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
778 {
779   TypeOfField type=getType();
780   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
781   med_geometry_type mgeoti;
782   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
783   const DataArray *arr=getOrCreateAndGetArray();
784   if(!arr)
785     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
786   if(!arr->isAllocated())
787     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
788   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
789   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
790   const unsigned char *locToWrite=0;
791   if(arrD)
792     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
793   else if(arrI)
794     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
795   else
796     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
797   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
798                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
799                                                    locToWrite));
800 }
801
802 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
803 {
804   type=_type;
805   pfl=_profile;
806   loc=_localization;
807   dad.first=_start; dad.second=_end;
808 }
809
810 /*!
811  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
812  *             This code corresponds to the distribution of types in the corresponding mesh.
813  * \param [out] ptToFill memory zone where the output will be stored.
814  * \return the size of data pushed into output param \a ptToFill
815  */
816 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
817 {
818   _loc_id=offset;
819   std::ostringstream oss;
820   std::size_t nbOfType=codeOfMesh.size()/3;
821   int found=-1;
822   for(std::size_t i=0;i<nbOfType && found==-1;i++)
823     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
824       found=(int)i;
825   if(found==-1)
826     {
827       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
828       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
829       throw INTERP_KERNEL::Exception(oss.str());
830     }
831   int *work=ptToFill;
832   if(_profile.empty())
833     {
834       if(_nval!=codeOfMesh[3*found+1])
835         {
836           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
837           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
838           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
839           throw INTERP_KERNEL::Exception(oss.str());
840         }
841       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
842         *work++=ii;
843     }
844   else
845     {
846       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
847       if(pfl->getNumberOfTuples()!=_nval)
848         {
849           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
850           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
851           oss << _nval;
852           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
853           throw INTERP_KERNEL::Exception(oss.str());
854         }
855       int offset2=codeOfMesh[3*found+2];
856       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
857         {
858           if(*pflId<codeOfMesh[3*found+1])
859             *work++=offset2+*pflId;
860         }
861     }
862   return _nval;
863 }
864
865 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
866 {
867   for(int i=_start;i<_end;i++)
868     *ptToFill++=i;
869   return _end-_start;
870 }
871
872 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
873 {
874   switch(type)
875   {
876     case ON_CELLS:
877       return -2;
878     case ON_GAUSS_NE:
879       return -1;
880     case ON_GAUSS_PT:
881       return locId;
882     default:
883       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
884   }
885 }
886
887 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
888 {
889   int id=0;
890   std::map<std::pair<std::string,TypeOfField>,int> m;
891   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
892   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
893     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
894       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
895   ret.resize(id);
896   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
897     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
898   return ret;
899 }
900
901 /*!
902  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
903  * 
904  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
905  * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
906  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
907  * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
908  * \param [in,out] glob if necessary by the method, new profiles can be added to it
909  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
910  * \param [out] result All new entries will be appended on it.
911  * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
912  */
913 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
914                                                        const DataArrayInt *explicitIdsInMesh,
915                                                        const std::vector<int>& newCode,
916                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
917                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
918 {
919   if(entriesOnSameDisc.empty())
920     return false;
921   TypeOfField type=entriesOnSameDisc[0]->getType();
922   int szEntities=0,szTuples=0;
923   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
924     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
925   int nbi=szTuples/szEntities;
926   if(szTuples%szEntities!=0)
927     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
928   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
929   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
930   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
931   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
932   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
933   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
934   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
935   int id=0;
936   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
937     {
938       int startOfEltIdOfChunk=(*it)->_start;
939       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
940       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
941       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
942       //
943       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
944       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
945       //
946       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
947       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
948     }
949   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
950   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
951   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
952   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
953   //
954   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
955   //
956   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
957   arrPart->renumberInPlace(renumTupleIds->begin());
958   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
959   bool ret=false;
960   const int *idIt=diffVals->begin();
961   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
962   int offset2=0;
963   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
964     {
965       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
966       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
967       int nbEntityElts=subIds->getNumberOfTuples();
968       bool ret2;
969       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
970           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
971                                       offset+offset2,
972                                       li,glob,ret2);
973       ret=ret || ret2;
974       result.push_back(eltToAdd);
975       offset2+=nbEntityElts*nbi;
976     }
977   ret=ret || li.empty();
978   return ret;
979 }
980
981 /*!
982  * \param [in] typeF type of field of new chunk
983  * \param [in] geoType the geometric type of the chunk
984  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
985  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
986  * \param [in] nbi number of integration points
987  * \param [in] offset The offset in the **global array of data**.
988  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
989  *                 to the new chunk to create.
990  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
991  * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
992  *              and corresponding entry erased from \a entriesOnSameDisc.
993  * \return a newly allocated chunk
994  */
995 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
996                                                                                                   bool isPfl, int nbi, int offset,
997                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
998                                                                                                   MEDFileFieldGlobsReal& glob,
999                                                                                                   bool &notInExisting)
1000 {
1001   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1002   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1003   for(;it!=entriesOnSameDisc.end();it++)
1004     {
1005       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1006         {
1007           if(!isPfl)
1008             {
1009               if((*it)->_profile.empty())
1010                 break;
1011               else
1012                 if(!(*it)->_profile.empty())
1013                   {
1014                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1015                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1016                       break;
1017                   }
1018             }
1019         }
1020     }
1021   if(it==entriesOnSameDisc.end())
1022     {
1023       notInExisting=true;
1024       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1025       ret->_type=typeF;
1026       ret->_loc_id=(int)geoType;
1027       ret->_nval=nbMeshEntities;
1028       ret->_start=offset;
1029       ret->_end=ret->_start+ret->_nval*nbi;
1030       if(isPfl)
1031         {
1032           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1033           glob.appendProfile(idsOfMeshElt);
1034           ret->_profile=idsOfMeshElt->getName();
1035         }
1036       //tony treatment of localization
1037       return ret;
1038     }
1039   else
1040     {
1041       notInExisting=false;
1042       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1043       ret->_loc_id=(int)geoType;
1044       ret->setNewStart(offset);
1045       entriesOnSameDisc.erase(it);
1046       return ret;
1047     }
1048
1049 }
1050
1051 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1052 {
1053   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1054 }
1055
1056 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1057 {
1058   return new MEDFileFieldPerMeshPerType(fath,geoType);
1059 }
1060
1061 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1062 {
1063   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1064 }
1065
1066 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1067 {
1068   std::vector<const BigMemoryObject *> ret;
1069   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1070     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1071   return ret;
1072 }
1073
1074 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1075 {
1076   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1077   ret->_father=father;
1078   std::size_t i=0;
1079   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1080     {
1081       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1082         ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1083     }
1084   return ret.retn();
1085 }
1086
1087 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1088 {
1089   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1090   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1091     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1092 }
1093
1094 /*!
1095  * This method is the most general one. No optimization is done here.
1096  * \param [in] multiTypePfl is the end user profile specified in high level API
1097  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1098  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1099  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1100  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1101  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1102  */
1103 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1104 {
1105   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1106   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1107     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1108 }
1109
1110 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1111 {
1112   _field_pm_pt_pd.resize(1);
1113   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1114   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1115 }
1116
1117 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1118 {
1119   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1120   if(!arr || !arr->isAllocated())
1121     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1122   _field_pm_pt_pd.resize(1);
1123   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1124   _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1125 }
1126
1127 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1128 {
1129   TypeOfField type=field->getTypeOfField();
1130   if(type!=ON_GAUSS_PT)
1131     {
1132       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1133       int sz=_field_pm_pt_pd.size();
1134       bool found=false;
1135       for(int j=0;j<sz && !found;j++)
1136         {
1137           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1138             {
1139               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1140               found=true;
1141             }
1142         }
1143       if(!found)
1144         {
1145           _field_pm_pt_pd.resize(sz+1);
1146           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1147         }
1148       std::vector<int> ret(1,(int)sz);
1149       return ret;
1150     }
1151   else
1152     {
1153       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1154       int sz2=ret2.size();
1155       std::vector<int> ret3(sz2);
1156       int k=0;
1157       for(int i=0;i<sz2;i++)
1158         {
1159           int sz=_field_pm_pt_pd.size();
1160           int locIdToFind=ret2[i];
1161           bool found=false;
1162           for(int j=0;j<sz && !found;j++)
1163             {
1164               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1165                 {
1166                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1167                   ret3[k++]=j;
1168                   found=true;
1169                 }
1170             }
1171           if(!found)
1172             {
1173               _field_pm_pt_pd.resize(sz+1);
1174               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1175               ret3[k++]=sz;
1176             }
1177         }
1178       return ret3;
1179     }
1180 }
1181
1182 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1183 {
1184   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1185   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1186   if(!disc2)
1187     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1188   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1189   if(!da)
1190     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1191   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1192   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1193   if(retTmp->presenceOfValue(-1))
1194     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1195   std::vector<int> ret(retTmp->begin(),retTmp->end());
1196   return ret;
1197 }
1198
1199 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1200 {
1201   TypeOfField type=field->getTypeOfField();
1202   if(type!=ON_GAUSS_PT)
1203     {
1204       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1205       int sz=_field_pm_pt_pd.size();
1206       bool found=false;
1207       for(int j=0;j<sz && !found;j++)
1208         {
1209           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1210             {
1211               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1212               found=true;
1213             }
1214         }
1215       if(!found)
1216         {
1217           _field_pm_pt_pd.resize(sz+1);
1218           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1219         }
1220       std::vector<int> ret(1,0);
1221       return ret;
1222     }
1223   else
1224     {
1225       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1226       int sz2=ret2.size();
1227       std::vector<int> ret3(sz2);
1228       int k=0;
1229       for(int i=0;i<sz2;i++)
1230         {
1231           int sz=_field_pm_pt_pd.size();
1232           int locIdToFind=ret2[i];
1233           bool found=false;
1234           for(int j=0;j<sz && !found;j++)
1235             {
1236               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1237                 {
1238                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1239                   ret3[k++]=j;
1240                   found=true;
1241                 }
1242             }
1243           if(!found)
1244             {
1245               _field_pm_pt_pd.resize(sz+1);
1246               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1247               ret3[k++]=sz;
1248             }
1249         }
1250       return ret3;
1251     }
1252 }
1253
1254 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1255 {
1256   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1257   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1258   if(!disc2)
1259     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1260   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1261   if(!da)
1262     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1263   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1264   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1265   if(retTmp->presenceOfValue(-1))
1266     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1267   std::vector<int> ret(retTmp->begin(),retTmp->end());
1268   return ret;
1269 }
1270
1271 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1272 {
1273   return _father;
1274 }
1275
1276 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1277 {
1278   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1279   int curDim((int)cm.getDimension());
1280   dim=std::max(dim,curDim);
1281 }
1282
1283 bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
1284 {
1285   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1286   int curDim((int)cm.getDimension());
1287   if(dim!=std::numeric_limits<int>::max())
1288     {
1289       if(dim!=curDim)
1290         return false;
1291     }
1292   else
1293     dim=curDim;
1294   return true;
1295 }
1296
1297 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1298 {
1299   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1300     {
1301       (*it)->fillTypesOfFieldAvailable(types);
1302     }
1303 }
1304
1305 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1306 {
1307   int sz=_field_pm_pt_pd.size();
1308   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1309   for(int i=0;i<sz;i++)
1310     {
1311       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1312     }
1313 }
1314
1315 int MEDFileFieldPerMeshPerType::getIteration() const
1316 {
1317   return _father->getIteration();
1318 }
1319
1320 int MEDFileFieldPerMeshPerType::getOrder() const
1321 {
1322   return _father->getOrder();
1323 }
1324
1325 double MEDFileFieldPerMeshPerType::getTime() const
1326 {
1327   return _father->getTime();
1328 }
1329
1330 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1331 {
1332   return _father->getMeshName();
1333 }
1334
1335 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1336 {
1337   const char startLine[]="  ## ";
1338   std::string startLine2(bkOffset,' ');
1339   std::string startLine3(startLine2);
1340   startLine3+=startLine;
1341   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1342     {
1343       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1344       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1345     }
1346   else
1347     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1348   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1349   int i=0;
1350   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1351     {
1352       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1353       if(cur)
1354         cur->simpleRepr(bkOffset,oss,i);
1355       else
1356         {
1357           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1358         }
1359     }
1360 }
1361
1362 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1363 {
1364   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1365     {
1366       globalSz+=(*it)->getNumberOfTuples();
1367     }
1368   nbOfEntries+=(int)_field_pm_pt_pd.size();
1369 }
1370
1371 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1372 {
1373   return _geo_type;
1374 }
1375
1376
1377 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1378 {
1379   return _father->getNumberOfComponents();
1380 }
1381
1382 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1383 {
1384   std::size_t nb(0);
1385   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1386     {
1387       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1388       if(fmtd)
1389         nb++;
1390     }
1391   return nb>1;
1392 }
1393
1394 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1395 {
1396   return _father->getOrCreateAndGetArray();
1397 }
1398
1399 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1400 {
1401   const MEDFileFieldPerMesh *fath=_father;
1402   return fath->getOrCreateAndGetArray();
1403 }
1404
1405 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1406 {
1407   return _father->getInfo();
1408 }
1409
1410 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1411 {
1412   std::vector<std::string> ret;
1413   std::set<std::string> ret2;
1414   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1415     {
1416       std::string tmp=(*it1)->getProfile();
1417       if(!tmp.empty())
1418         if(ret2.find(tmp)==ret2.end())
1419           {
1420             ret.push_back(tmp);
1421             ret2.insert(tmp);
1422           }
1423     }
1424   return ret;
1425 }
1426
1427 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1428 {
1429   std::vector<std::string> ret;
1430   std::set<std::string> ret2;
1431   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1432     {
1433       std::string tmp=(*it1)->getLocalization();
1434       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1435         if(ret2.find(tmp)==ret2.end())
1436           {
1437             ret.push_back(tmp);
1438             ret2.insert(tmp);
1439           }
1440     }
1441   return ret;
1442 }
1443
1444 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1445 {
1446   std::vector<std::string> ret;
1447   std::set<std::string> ret2;
1448   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1449     {
1450       std::string tmp=(*it1)->getProfile();
1451       if(!tmp.empty())
1452         ret.push_back(tmp);
1453     }
1454   return ret;
1455 }
1456
1457 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1458 {
1459   std::vector<std::string> ret;
1460   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1461     {
1462       std::string tmp=(*it1)->getLocalization();
1463       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1464         ret.push_back(tmp);
1465     }
1466   return ret;
1467 }
1468
1469 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1470 {
1471   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1472     (*it1)->changePflsRefsNamesGen(mapOfModif);
1473 }
1474
1475 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1476 {
1477   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1478     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1479 }
1480
1481 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1482 {
1483   if(_field_pm_pt_pd.empty())
1484     {
1485       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1486       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1487       throw INTERP_KERNEL::Exception(oss.str());
1488     }
1489   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1490     return _field_pm_pt_pd[locId];
1491   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1492   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1493   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1494   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1495   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1496 }
1497
1498 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1499 {
1500   if(_field_pm_pt_pd.empty())
1501     {
1502       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1503       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1504       throw INTERP_KERNEL::Exception(oss.str());
1505     }
1506   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1507     return _field_pm_pt_pd[locId];
1508   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1509   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1510   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1511   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1512   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1513 }
1514
1515 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1516 {
1517   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1518     {
1519       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1520       if(meshDim!=(int)cm.getDimension())
1521         return ;
1522     }
1523   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1524     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1525 }
1526
1527 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1528 {
1529   int i=0;
1530   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1531     {
1532       (*it)->fillValues(i,startEntryId,entries);
1533     }
1534 }
1535
1536 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1537 {
1538   _field_pm_pt_pd=leaves;
1539   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1540     (*it)->setFather(this);
1541 }
1542
1543 /*!
1544  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1545  *  \param [out] its - list of pair (start,stop) kept
1546  *  \return bool - false if the type of field \a tof is not contained in \a this.
1547  */
1548 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1549 {
1550   bool ret(false);
1551   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1552   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1553     if((*it)->getType()==tof)
1554       {
1555         newPmPtPd.push_back(*it);
1556         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1557         (*it)->setNewStart(globalNum);
1558         globalNum=(*it)->getEnd();
1559         its.push_back(bgEnd);
1560         ret=true;
1561       }
1562   if(ret)
1563     _field_pm_pt_pd=newPmPtPd;
1564   return ret;
1565 }
1566
1567 /*!
1568  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1569  *  \param [out] its - list of pair (start,stop) kept
1570  *  \return bool - false if the type of field \a tof is not contained in \a this.
1571  */
1572 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1573 {
1574   if(_field_pm_pt_pd.size()<=idOfDisc)
1575     return false;
1576   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1577   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1578   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1579   elt->setNewStart(globalNum);
1580   globalNum=elt->getEnd();
1581   its.push_back(bgEnd);
1582   _field_pm_pt_pd=newPmPtPd;
1583   return true;
1584 }
1585
1586 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1587 {
1588   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1589   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1590   med_geometry_type mgeoti;
1591   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1592   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1593   _field_pm_pt_pd.resize(nbProfiles);
1594   for(int i=0;i<nbProfiles;i++)
1595     {
1596       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1597     }
1598   if(type==ON_CELLS)
1599     {
1600       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1601       for(int i=0;i<nbProfiles2;i++)
1602         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1603     }
1604 }
1605
1606 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1607 {
1608   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1610 }
1611
1612 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1613 {
1614   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1615     (*it)->loadBigArray(fid,nasc);
1616 }
1617
1618 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1619 {
1620   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1621     {
1622       (*it)->copyOptionsFrom(*this);
1623       (*it)->writeLL(fid,nasc);
1624     }
1625 }
1626
1627 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1628 {
1629   switch(ikType)
1630   {
1631     case ON_CELLS:
1632       medfGeoType=typmai3[(int)ikGeoType];
1633       return MED_CELL;
1634     case ON_NODES:
1635       medfGeoType=MED_NONE;
1636       return MED_NODE;
1637     case ON_GAUSS_NE:
1638       medfGeoType=typmai3[(int)ikGeoType];
1639       return MED_NODE_ELEMENT;
1640     case ON_GAUSS_PT:
1641       medfGeoType=typmai3[(int)ikGeoType];
1642       return MED_CELL;
1643     default:
1644       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1645   }
1646   return MED_UNDEF_ENTITY_TYPE;
1647 }
1648
1649 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1650 {
1651   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1652 }
1653
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1655 {
1656   return new MEDFileFieldPerMesh(fath,mesh);
1657 }
1658
1659 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1660 {
1661   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1662 }
1663
1664 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1665 {
1666   std::vector<const BigMemoryObject *> ret;
1667   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1668     ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1669   return ret;
1670 }
1671
1672 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1673 {
1674   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1675   ret->_father=father;
1676   std::size_t i=0;
1677   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1678     {
1679       if((const MEDFileFieldPerMeshPerType *)*it)
1680         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1681     }
1682   return ret.retn();
1683 }
1684
1685 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1686 {
1687   std::string startLine(bkOffset,' ');
1688   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1689   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1690   int i=0;
1691   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1692     {
1693       const MEDFileFieldPerMeshPerType *cur=*it;
1694       if(cur)
1695         cur->simpleRepr(bkOffset,oss,i);
1696       else
1697         {
1698           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1699         }
1700     }
1701 }
1702
1703 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1704 {
1705   _mesh_name=mesh->getName();
1706   mesh->getTime(_mesh_iteration,_mesh_order);
1707 }
1708
1709 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1710 {
1711   int nbOfTypes=code.size()/3;
1712   int offset=0;
1713   for(int i=0;i<nbOfTypes;i++)
1714     {
1715       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1716       int nbOfCells=code[3*i+1];
1717       int pos=addNewEntryIfNecessary(type);
1718       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1719       offset+=nbOfCells;
1720     }
1721 }
1722
1723 /*!
1724  * This method is the most general one. No optimization is done here.
1725  * \param [in] multiTypePfl is the end user profile specified in high level API
1726  * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1727  * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1728  * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1729  * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1730  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1731  */
1732 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1733 {
1734   int nbOfTypes(code.size()/3);
1735   for(int i=0;i<nbOfTypes;i++)
1736     {
1737       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1738       int pos=addNewEntryIfNecessary(type);
1739       DataArrayInt *pfl=0;
1740       if(code[3*i+2]!=-1)
1741         pfl=idsPerType[code[3*i+2]];
1742       int nbOfTupes2=code2.size()/3;
1743       int found=0;
1744       for(;found<nbOfTupes2;found++)
1745         if(code[3*i]==code2[3*found])
1746           break;
1747       if(found==nbOfTupes2)
1748         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1749       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1750     }
1751 }
1752
1753 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1754 {
1755   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1756   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1757 }
1758
1759 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1760 {
1761   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1762   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1763 }
1764
1765 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1766 {
1767   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1768     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1769 }
1770
1771 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1772 {
1773   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1774     (*it)->loadBigArraysRecursively(fid,nasc);
1775 }
1776
1777 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1778 {
1779   int nbOfTypes=_field_pm_pt.size();
1780   for(int i=0;i<nbOfTypes;i++)
1781     {
1782       _field_pm_pt[i]->copyOptionsFrom(*this);
1783       _field_pm_pt[i]->writeLL(fid,nasc);
1784     }
1785 }
1786
1787 void MEDFileFieldPerMesh::getDimension(int& dim) const
1788 {
1789   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1790     (*it)->getDimension(dim);
1791 }
1792
1793 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1794 {
1795   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1796     if(!(*it)->isUniqueLevel(dim))
1797       return false;
1798   return true;
1799 }
1800
1801 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1802 {
1803   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1804     (*it)->fillTypesOfFieldAvailable(types);
1805 }
1806
1807 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(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
1808 {
1809   int sz=_field_pm_pt.size();
1810   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1811   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1812   for(int i=0;i<sz;i++)
1813     {
1814       types[i]=_field_pm_pt[i]->getGeoType();
1815       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1816     }
1817   return ret;
1818 }
1819
1820 double MEDFileFieldPerMesh::getTime() const
1821 {
1822   int tmp1,tmp2;
1823   return _father->getTime(tmp1,tmp2);
1824 }
1825
1826 int MEDFileFieldPerMesh::getIteration() const
1827 {
1828   return _father->getIteration();
1829 }
1830
1831 int MEDFileFieldPerMesh::getOrder() const
1832 {
1833   return _father->getOrder();
1834 }
1835
1836 int MEDFileFieldPerMesh::getNumberOfComponents() const
1837 {
1838   return _father->getNumberOfComponents();
1839 }
1840
1841 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1842 {
1843   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844     {
1845       const MEDFileFieldPerMeshPerType *fpmt(*it);
1846       if(!fpmt)
1847         continue;
1848       if(fpmt->presenceOfMultiDiscPerGeoType())
1849         return true;
1850     }
1851   return false;
1852 }
1853
1854 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1855 {
1856   if(!_father)
1857     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1858   return _father->getOrCreateAndGetArray();
1859 }
1860
1861 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1862 {
1863   if(!_father)
1864     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1865   return _father->getOrCreateAndGetArray();
1866 }
1867
1868 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1869 {
1870   return _father->getInfo();
1871 }
1872
1873 /*!
1874  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1875  * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1876  * It returns 2 output vectors :
1877  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1878  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1879  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1880  */
1881 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1882 {
1883   int notNullPflsSz=0;
1884   int nbOfArrs=geoTypes.size();
1885   for(int i=0;i<nbOfArrs;i++)
1886     if(pfls[i])
1887       notNullPflsSz++;
1888   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1889   int nbOfDiffGeoTypes=geoTypes3.size();
1890   code.resize(3*nbOfDiffGeoTypes);
1891   notNullPfls.resize(notNullPflsSz);
1892   notNullPflsSz=0;
1893   int j=0;
1894   for(int i=0;i<nbOfDiffGeoTypes;i++)
1895     {
1896       int startZone=j;
1897       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1898       std::vector<const DataArrayInt *> notNullTmp;
1899       if(pfls[j])
1900         notNullTmp.push_back(pfls[j]);
1901       j++;
1902       for(;j<nbOfArrs;j++)
1903         if(geoTypes[j]==refType)
1904           {
1905             if(pfls[j])
1906               notNullTmp.push_back(pfls[j]);
1907           }
1908         else
1909           break;
1910       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1911       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1912       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1913       code[3*i]=(int)refType;
1914       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1915       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1916       if(notNullTmp.empty())
1917         code[3*i+2]=-1;
1918       else
1919         {
1920           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1921           code[3*i+2]=notNullPflsSz++;
1922         }
1923     }
1924 }
1925
1926 /*!
1927  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1928  */
1929 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs)
1930 {
1931   int sz=dads.size();
1932   int ret=0;
1933   for(int i=0;i<sz;i++)
1934     {
1935       if(locs[i]==-1)
1936         {
1937           if(type!=ON_GAUSS_NE)
1938             ret+=dads[i].second-dads[i].first;
1939           else
1940             {
1941               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1942               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1943             }
1944         }
1945       else
1946         {
1947           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1948           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1949         }
1950     }
1951   return ret;
1952 }
1953
1954 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1955 {
1956   std::vector<std::string> ret;
1957   std::set<std::string> ret2;
1958   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1959     {
1960       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1961       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1962         if(ret2.find(*it2)==ret2.end())
1963           {
1964             ret.push_back(*it2);
1965             ret2.insert(*it2);
1966           }
1967     }
1968   return ret;
1969 }
1970
1971 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1972 {
1973   std::vector<std::string> ret;
1974   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1975     {
1976       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1977       ret.insert(ret.end(),tmp.begin(),tmp.end());
1978     }
1979   return ret;
1980 }
1981
1982 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1983 {
1984   std::vector<std::string> ret;
1985   std::set<std::string> ret2;
1986   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1987     {
1988       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1989       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1990         if(ret2.find(*it2)==ret2.end())
1991           {
1992             ret.push_back(*it2);
1993             ret2.insert(*it2);
1994           }
1995     }
1996   return ret;
1997 }
1998
1999 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2000 {
2001   std::vector<std::string> ret;
2002   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2003     {
2004       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2005       ret.insert(ret.end(),tmp.begin(),tmp.end());
2006     }
2007   return ret;
2008 }
2009
2010 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2011 {
2012   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2013     {
2014       if((*it).first==_mesh_name)
2015         {
2016           _mesh_name=(*it).second;
2017           return true;
2018         }
2019     }
2020   return false;
2021 }
2022
2023 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2024                                                       MEDFileFieldGlobsReal& glob)
2025 {
2026   if(_mesh_name!=meshName)
2027     return false;
2028   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2029   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2030   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2031   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2032   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2033   getUndergroundDataArrayExt(entries);
2034   DataArray *arr0(getOrCreateAndGetArray());//tony
2035   if(!arr0)
2036     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2037   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2038   if(!arr0)
2039     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2040   int sz=0;
2041   if(!arr)
2042     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2043   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2044     {
2045       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2046         {
2047           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2048           sz+=(*it).second.second-(*it).second.first;
2049         }
2050       else
2051         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2052     }
2053   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2054   ////////////////////
2055   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2056   int *workI2=explicitIdsOldInMesh->getPointer();
2057   int sz1=0,sz2=0,sid=1;
2058   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2059   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2060   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2061     {
2062       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2063       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2064       int *workI=explicitIdsOldInArr->getPointer();
2065       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2066         {
2067           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2068           (*itL2)->setLocId(sz2);
2069           (*itL2)->_tmp_work1=(*itL2)->getStart();
2070           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2071         }
2072       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2073     }
2074   explicitIdsOldInMesh->reAlloc(sz2);
2075   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2076   ////////////////////
2077   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2078   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2079   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2080   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2081     {
2082       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2083       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2084       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2085     }
2086   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2087   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2088   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2089     {
2090       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2091       int newStart=elt->getLocId();
2092       elt->setLocId((*it)->getGeoType());
2093       elt->setNewStart(newStart);
2094       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2095       entriesKeptNew.push_back(elt);
2096       entriesKeptNew2.push_back(elt);
2097     }
2098   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2099   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2100   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2101   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2102   bool ret=false;
2103   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2104     {
2105       sid=0;
2106       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2107         {
2108           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2109           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2110           }*/
2111       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2112                                                             glob,arr2,otherEntriesNew) || ret;
2113     }
2114   if(!ret)
2115     return false;
2116   // Assign new dispatching
2117   assignNewLeaves(otherEntriesNew);
2118   arr->deepCopyFrom(*arr2);
2119   return true;
2120 }
2121
2122 /*!
2123  * \param [in,out] globalNum a global numbering counter for the renumbering.
2124  * \param [out] its - list of pair (start,stop) kept
2125  */
2126 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2127 {
2128   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2129   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2130     {
2131       std::vector< std::pair<int,int> > its2;
2132       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2133         {
2134           ret.push_back(*it);
2135           its.insert(its.end(),its2.begin(),its2.end());
2136         }
2137     }
2138   _field_pm_pt=ret;
2139 }
2140
2141 /*!
2142  * \param [in,out] globalNum a global numbering counter for the renumbering.
2143  * \param [out] its - list of pair (start,stop) kept
2144  */
2145 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2146 {
2147   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2148   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2149     {
2150       std::vector< std::pair<int,int> > its2;
2151       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2152         {
2153           ret.push_back(*it);
2154           its.insert(its.end(),its2.begin(),its2.end());
2155         }
2156     }
2157   _field_pm_pt=ret;
2158 }
2159
2160 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2161 {
2162   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2163   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2164     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2165   //
2166   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2167   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2168   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2169   for(;it1!=types.end();it1++,it2++)
2170     {
2171       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2172       elt->setLeaves((*it1).second);
2173       *it2=elt;
2174     }
2175   _field_pm_pt=fieldPmPt;
2176 }
2177
2178 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2179 {
2180   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2181     (*it)->changePflsRefsNamesGen(mapOfModif);
2182 }
2183
2184 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2185 {
2186   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2187     (*it)->changeLocsRefsNamesGen(mapOfModif);
2188 }
2189
2190 /*!
2191  * \param [in] mesh is the whole mesh
2192  */
2193 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2194 {
2195   if(_field_pm_pt.empty())
2196     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2197   //
2198   std::vector< std::pair<int,int> > dads;
2199   std::vector<const DataArrayInt *> pfls;
2200   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2201   std::vector<int> locs,code;
2202   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2203   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2205   // Sort by types
2206   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2207   if(code.empty())
2208     {
2209       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2210       throw INTERP_KERNEL::Exception(oss.str());
2211     }
2212   //
2213   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2214   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2215   if(type!=ON_NODES)
2216     {
2217       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2218       if(!arr)
2219         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2220       else
2221         {
2222           MCAuto<DataArrayInt> arr2(arr);
2223           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2224         }
2225     }
2226   else
2227     {
2228       if(code.size()!=3)
2229         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2230       int nb=code[1];
2231       if(code[2]==-1)
2232         {
2233           if(nb!=mesh->getNumberOfNodes())
2234             {
2235               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2236               oss << " nodes in mesh !";
2237               throw INTERP_KERNEL::Exception(oss.str());
2238             }
2239           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2240         }
2241       else
2242         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2243     }
2244 }
2245
2246 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2247 {
2248   if(_field_pm_pt.empty())
2249     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2250   //
2251   std::vector<std::pair<int,int> > dads;
2252   std::vector<const DataArrayInt *> pfls;
2253   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2254   std::vector<int> locs,code;
2255   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2256   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2257     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2258   // Sort by types
2259   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2260   if(code.empty())
2261     {
2262       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2263       throw INTERP_KERNEL::Exception(oss.str());
2264     }
2265   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2266   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2267   if(type!=ON_NODES)
2268     {
2269       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2270       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2271     }
2272   else
2273     {
2274       if(code.size()!=3)
2275         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2276       int nb=code[1];
2277       if(code[2]==-1)
2278         {
2279           if(nb!=mesh->getNumberOfNodes())
2280             {
2281               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2282               oss << " nodes in mesh !";
2283               throw INTERP_KERNEL::Exception(oss.str());
2284             }
2285         }
2286       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2287     }
2288   //
2289   return 0;
2290 }
2291
2292 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2293 {
2294   int globalSz=0;
2295   int nbOfEntries=0;
2296   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2297     {
2298       (*it)->getSizes(globalSz,nbOfEntries);
2299     }
2300   entries.resize(nbOfEntries);
2301   nbOfEntries=0;
2302   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303     {
2304       (*it)->fillValues(nbOfEntries,entries);
2305     }
2306 }
2307
2308 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2309 {
2310   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311     {
2312       if((*it)->getGeoType()==typ)
2313         return (*it)->getLeafGivenLocId(locId);
2314     }
2315   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2316   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2317   oss << "Possiblities are : ";
2318   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2319     {
2320       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2321       oss << "\"" << cm2.getRepr() << "\", ";
2322     }
2323   throw INTERP_KERNEL::Exception(oss.str());
2324 }
2325
2326 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2327 {
2328   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2329     {
2330       if((*it)->getGeoType()==typ)
2331         return (*it)->getLeafGivenLocId(locId);
2332     }
2333   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2334   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2335   oss << "Possiblities are : ";
2336   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2337     {
2338       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2339       oss << "\"" << cm2.getRepr() << "\", ";
2340     }
2341   throw INTERP_KERNEL::Exception(oss.str());
2342 }
2343
2344 /*!
2345  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2346  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2347  * \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
2348  * \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
2349  */
2350 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2351 {
2352   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2353   if(pms.empty())
2354     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2355   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2356     {
2357       if(!(*it).second)
2358         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2359       if(!(*it).second->getProfile().empty())
2360         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2361       if(!(*it).second->getLocalization().empty())
2362         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2363     }
2364   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2365   std::size_t i(0);
2366   std::vector< std::pair<int,int> > filteredDTS;
2367   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2368     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2369       if((*it2).first==gt)
2370         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2371   if(pms.size()!=filteredDTS.size())
2372     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2373   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2374   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2375   int zeStart(start),nval(0);
2376   for(;it1!=pms.end();it1++,it2++)
2377     {
2378       if((*it1).first!=(*it2).first)
2379         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2380       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2381       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2382       start+=e1-s1;
2383       nval+=((*it1).second)->getNumberOfVals();
2384     }
2385   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2386   return ret;
2387 }
2388
2389 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2390 {
2391   MCAuto<MEDFileFieldPerMeshPerType> ret(new MEDFileFieldPerMeshPerType(father,gt));
2392   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
2393   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2394     {
2395       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
2396         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
2397     }
2398   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
2399     {
2400       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2401       ret->_field_pm_pt_pd.push_back(agg);
2402     }
2403   return ret;
2404 }
2405
2406 MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2407 {
2408   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2409   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2410   std::size_t i(0);
2411   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2412     {
2413       const std::vector< MCAuto< MEDFileFieldPerMeshPerType > >& v((*it)->_field_pm_pt);
2414       for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2415         {
2416           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2417           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
2418         }
2419     }
2420   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2421     {
2422       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2423       ret->_field_pm_pt.push_back(agg);
2424     }
2425   return ret;
2426 }
2427
2428 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2429 {
2430   int i=0;
2431   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2432   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2433   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2434     {
2435       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2436       if(type==curType)
2437         return i;
2438       else
2439         {
2440           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2441           if(pos>pos2)
2442             it2=it+1;
2443         }
2444     }
2445   int ret=std::distance(_field_pm_pt.begin(),it2);
2446   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2447   return ret;
2448 }
2449
2450 /*!
2451  * 'dads' and 'locs' input parameters have the same number of elements
2452  * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2453  */
2454 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2455                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2456                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2457 {
2458   isPfl=false;
2459   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2460   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2461   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2462   const std::vector<std::string>& infos=getInfo();
2463   da->setInfoOnComponents(infos);
2464   da->setName("");
2465   if(type==ON_GAUSS_PT)
2466     {
2467       int offset=0;
2468       int nbOfArrs=dads.size();
2469       for(int i=0;i<nbOfArrs;i++)
2470         {
2471           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2472           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2473           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2474           MCAuto<DataArrayInt> di=DataArrayInt::New();
2475           di->alloc(nbOfElems,1);
2476           di->iota(offset);
2477           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2478           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2479           offset+=nbOfElems;
2480         }
2481     }
2482   arrOut=da;
2483   return ret.retn();
2484 }
2485
2486 /*!
2487  * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2488  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2489  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2490  * The order of cells in the returned field is those imposed by the profile.
2491  * \param [in] mesh is the global mesh.
2492  */
2493 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2494                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2495                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2496                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2497 {
2498   if(da->isIota(mesh->getNumberOfCells()))
2499     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2500   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2501   m2->setName(mesh->getName().c_str());
2502   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2503   isPfl=true;
2504   return ret.retn();
2505 }
2506
2507 /*!
2508  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2509  */
2510 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2511                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2512                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2513 {
2514   if(da->isIota(mesh->getNumberOfNodes()))
2515     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2516   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2517   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2518   if(meshu)
2519     {
2520       if(meshu->getNodalConnectivity()==0)
2521         {
2522           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2523           int nb=da->getNbOfElems();
2524           const int *ptr=da->getConstPointer();
2525           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2526           meshuc->allocateCells(nb);
2527           for(int i=0;i<nb;i++)
2528             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2529           meshuc->finishInsertingCells();
2530           ret->setMesh(meshuc);
2531           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2532           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2533           disc->checkCoherencyBetween(meshuc,arrOut);
2534           return ret.retn();
2535         }
2536     }
2537   //
2538   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2539   isPfl=true;
2540   DataArrayInt *arr2=0;
2541   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2542   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2543   MCAuto<DataArrayInt> arr3(arr2);
2544   int nnodes=mesh2->getNumberOfNodes();
2545   if(nnodes==(int)da->getNbOfElems())
2546     {
2547       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2548       arrOut->renumberInPlace(da3->getConstPointer());
2549       mesh2->setName(mesh->getName().c_str());
2550       ret->setMesh(mesh2);
2551       return ret.retn();
2552     }
2553   else
2554     {
2555       std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2556       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2557       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2558       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2559       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2560       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2561       throw INTERP_KERNEL::Exception(oss.str());
2562     }
2563   return 0;
2564 }
2565
2566 /*!
2567  * This method is the most light method of field retrieving.
2568  */
2569 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2570 {
2571   if(!pflIn)
2572     {
2573       pflOut=DataArrayInt::New();
2574       pflOut->alloc(nbOfElems,1);
2575       pflOut->iota(0);
2576     }
2577   else
2578     {
2579       pflOut=const_cast<DataArrayInt*>(pflIn);
2580       pflOut->incrRef();
2581     }
2582   MCAuto<DataArrayInt> safePfl(pflOut);
2583   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2584   const std::vector<std::string>& infos=getInfo();
2585   int nbOfComp=infos.size();
2586   for(int i=0;i<nbOfComp;i++)
2587     da->setInfoOnComponent(i,infos[i].c_str());
2588   safePfl->incrRef();
2589   return da.retn();
2590 }
2591
2592
2593 /// @cond INTERNAL
2594
2595 class MFFPMIter
2596 {
2597 public:
2598   static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2599   static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2600   virtual ~MFFPMIter() { }
2601   virtual void begin() = 0;
2602   virtual bool finished() const = 0;
2603   virtual void next() = 0;
2604   virtual int current() const = 0;
2605 };
2606
2607 class MFFPMIterSimple : public MFFPMIter
2608 {
2609 public:
2610   MFFPMIterSimple():_pos(0) { }
2611   void begin() { _pos=0; }
2612   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2613   void next() { _pos++; }
2614   int current() const { return _pos; }
2615 private:
2616   int _pos;
2617 };
2618
2619 class MFFPMIter2 : public MFFPMIter
2620 {
2621 public:
2622   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2623   void begin() { _it=_ids.begin(); }
2624   bool finished() const { return _it==_ids.end(); }
2625   void next() { _it++; }
2626   int current() const { return *_it; }
2627 private:
2628   std::vector<int> _ids;
2629   std::vector<int>::const_iterator _it;
2630 };
2631
2632 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2633 {
2634   if(!entities)
2635     return new MFFPMIterSimple;
2636   else
2637     {
2638       std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2639       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2640         {
2641           if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2642             tmp.push_back((*it).second);
2643         }
2644       return new MFFPMIter2(tmp);
2645     }
2646 }
2647
2648 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2649 {
2650   if(!entities)
2651     return true;
2652   else
2653     {
2654       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2655         if((*it).first==ON_NODES)
2656           return true;
2657       return false;
2658     }
2659 }
2660
2661 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2662 {
2663   std::size_t sz(cts.size());
2664   _ids.resize(sz);
2665   for(std::size_t i=0;i<sz;i++)
2666     {
2667       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2668       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2669         _ids[i]=(int)std::distance(typmai2,loc);
2670       else
2671         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2672     }
2673 }
2674
2675 /// @endcond
2676
2677 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2678     _father(fath)
2679 {
2680   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2681   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2682   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2683   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2684   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2685   for(iter0->begin();!iter0->finished();iter0->next())
2686     {
2687       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2688       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2689       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2690       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2691       if(nbProfile>0 || nbProfile2>0)
2692         {
2693           const PartDefinition *pd(0);
2694           if(mmu)
2695             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2696           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2697           if(nbProfile>0)
2698             _mesh_name=name0;
2699           else
2700             _mesh_name=name1;
2701         }
2702     }
2703   if(MFFPMIter::IsPresenceOfNode(entities))
2704     {
2705       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2706       if(nbProfile>0)
2707         {
2708           const PartDefinition *pd(0);
2709           if(mmu)
2710             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2711           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2712           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2713         }
2714     }
2715 }
2716
2717 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2718 {
2719   copyTinyInfoFrom(mesh);
2720 }
2721
2722 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2723 {
2724   if(id>=(int)_pfls.size())
2725     _pfls.resize(id+1);
2726   _pfls[id]=DataArrayInt::New();
2727   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2728   _pfls[id]->setName(pflName);
2729   _pfls[id]->alloc(lgth,1);
2730   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2731   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2732 }
2733
2734 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2735 {
2736   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2737   int sz;
2738   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2739   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2740   if(i>=(int)_pfls.size())
2741     _pfls.resize(i+1);
2742   _pfls[i]=DataArrayInt::New();
2743   _pfls[i]->alloc(sz,1);
2744   _pfls[i]->setName(pflCpp.c_str());
2745   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2746   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2747 }
2748
2749 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2750 {
2751   int nbOfPfls=_pfls.size();
2752   for(int i=0;i<nbOfPfls;i++)
2753     {
2754       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2755       cpy->applyLin(1,1,0);
2756       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2757       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2758       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2759     }
2760   //
2761   int nbOfLocs=_locs.size();
2762   for(int i=0;i<nbOfLocs;i++)
2763     _locs[i]->writeLL(fid);
2764 }
2765
2766 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2767 {
2768   std::vector<std::string> pfls=getPfls();
2769   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2770     {
2771       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2772       if(it2==pfls.end())
2773         {
2774           _pfls.push_back(*it);
2775         }
2776       else
2777         {
2778           int id=std::distance(pfls.begin(),it2);
2779           if(!(*it)->isEqual(*_pfls[id]))
2780             {
2781               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2782               throw INTERP_KERNEL::Exception(oss.str());
2783             }
2784         }
2785     }
2786   std::vector<std::string> locs=getLocs();
2787   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2788     {
2789       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2790       if(it2==locs.end())
2791         {
2792           _locs.push_back(*it);
2793         }
2794       else
2795         {
2796           int id=std::distance(locs.begin(),it2);
2797           if(!(*it)->isEqual(*_locs[id],eps))
2798             {
2799               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2800               throw INTERP_KERNEL::Exception(oss.str());
2801             }
2802         }
2803     }
2804 }
2805
2806 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2807 {
2808   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2809     getProfile((*it).c_str());
2810 }
2811
2812 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2813 {
2814   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2815     getLocalization((*it).c_str());
2816 }
2817
2818 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2819 {
2820   std::vector<std::string> profiles=real.getPflsReallyUsed();
2821   int sz=profiles.size();
2822   _pfls.resize(sz);
2823   for(int i=0;i<sz;i++)
2824     loadProfileInFile(fid,i,profiles[i].c_str());
2825   //
2826   std::vector<std::string> locs=real.getLocsReallyUsed();
2827   sz=locs.size();
2828   _locs.resize(sz);
2829   for(int i=0;i<sz;i++)
2830     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2831 }
2832
2833 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2834 {
2835   int nProfil=MEDnProfile(fid);
2836   for(int i=0;i<nProfil;i++)
2837     loadProfileInFile(fid,i);
2838   int sz=MEDnLocalization(fid);
2839   _locs.resize(sz);
2840   for(int i=0;i<sz;i++)
2841     {
2842       _locs[i]=MEDFileFieldLoc::New(fid,i);
2843     }
2844 }
2845
2846 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2847 {
2848   return new MEDFileFieldGlobs(fid);
2849 }
2850
2851 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2852 {
2853   return new MEDFileFieldGlobs;
2854 }
2855
2856 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2857 {
2858   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2859 }
2860
2861 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2862 {
2863   std::vector<const BigMemoryObject *> ret;
2864   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2865     ret.push_back((const DataArrayInt *)*it);
2866   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2867     ret.push_back((const MEDFileFieldLoc *)*it);
2868   return ret;
2869 }
2870
2871 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2872 {
2873   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2874   std::size_t i=0;
2875   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2876     {
2877       if((const DataArrayInt *)*it)
2878         ret->_pfls[i]=(*it)->deepCopy();
2879     }
2880   i=0;
2881   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2882     {
2883       if((const MEDFileFieldLoc*)*it)
2884         ret->_locs[i]=(*it)->deepCopy();
2885     }
2886   return ret.retn();
2887 }
2888
2889 /*!
2890  * \throw if a profile in \a pfls in not in \a this.
2891  * \throw if a localization in \a locs in not in \a this.
2892  * \sa MEDFileFieldGlobs::deepCpyPart
2893  */
2894 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2895 {
2896   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2897   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2898     {
2899       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2900       if(!pfl)
2901         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2902       pfl->incrRef();
2903       MCAuto<DataArrayInt> pfl2(pfl);
2904       ret->_pfls.push_back(pfl2);
2905     }
2906   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2907     {
2908       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2909       if(!loc)
2910         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2911       loc->incrRef();
2912       MCAuto<MEDFileFieldLoc> loc2(loc);
2913       ret->_locs.push_back(loc2);
2914     }
2915   ret->setFileName(getFileName());
2916   return ret.retn();
2917 }
2918
2919 /*!
2920  * \throw if a profile in \a pfls in not in \a this.
2921  * \throw if a localization in \a locs in not in \a this.
2922  * \sa MEDFileFieldGlobs::shallowCpyPart
2923  */
2924 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2925 {
2926   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2927   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2928     {
2929       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2930       if(!pfl)
2931         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2932       ret->_pfls.push_back(pfl->deepCopy());
2933     }
2934   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2935     {
2936       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2937       if(!loc)
2938         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2939       ret->_locs.push_back(loc->deepCopy());
2940     }
2941   ret->setFileName(getFileName());
2942   return ret.retn();
2943 }
2944
2945 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
2946 {
2947 }
2948
2949 MEDFileFieldGlobs::MEDFileFieldGlobs()
2950 {
2951 }
2952
2953 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2954 {
2955 }
2956
2957 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2958 {
2959   oss << "Profiles :\n";
2960   std::size_t n=_pfls.size();
2961   for(std::size_t i=0;i<n;i++)
2962     {
2963       oss << "  - #" << i << " ";
2964       const DataArrayInt *pfl=_pfls[i];
2965       if(pfl)
2966         oss << "\"" << pfl->getName() << "\"\n";
2967       else
2968         oss << "EMPTY !\n";
2969     }
2970   n=_locs.size();
2971   oss << "Localizations :\n";
2972   for(std::size_t i=0;i<n;i++)
2973     {
2974       oss << "  - #" << i << " ";
2975       const MEDFileFieldLoc *loc=_locs[i];
2976       if(loc)
2977         loc->simpleRepr(oss);
2978       else
2979         oss<< "EMPTY !\n";
2980     }
2981 }
2982
2983 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2984 {
2985   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2986     {
2987       DataArrayInt *elt(*it);
2988       if(elt)
2989         {
2990           std::string name(elt->getName());
2991           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2992             {
2993               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2994                 {
2995                   elt->setName((*it2).second.c_str());
2996                   return;
2997                 }
2998             }
2999         }
3000     }
3001 }
3002
3003 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3004 {
3005   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3006     {
3007       MEDFileFieldLoc *elt(*it);
3008       if(elt)
3009         {
3010           std::string name(elt->getName());
3011           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3012             {
3013               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3014                 {
3015                   elt->setName((*it2).second.c_str());
3016                   return;
3017                 }
3018             }
3019         }
3020     }
3021 }
3022
3023 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3024 {
3025   if(locId<0 || locId>=(int)_locs.size())
3026     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3027   return _locs[locId]->getNbOfGaussPtPerCell();
3028 }
3029
3030 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3031 {
3032   return getLocalizationFromId(getLocalizationId(locName));
3033 }
3034
3035 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3036 {
3037   if(locId<0 || locId>=(int)_locs.size())
3038     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3039   return *_locs[locId];
3040 }
3041
3042 /// @cond INTERNAL
3043 namespace MEDCouplingImpl
3044 {
3045   class LocFinder
3046   {
3047   public:
3048     LocFinder(const std::string& loc):_loc(loc) { }
3049     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3050   private:
3051     const std::string &_loc;
3052   };
3053
3054   class PflFinder
3055   {
3056   public:
3057     PflFinder(const std::string& pfl):_pfl(pfl) { }
3058     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3059   private:
3060     const std::string& _pfl;
3061   };
3062 }
3063 /// @endcond
3064
3065 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3066 {
3067   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3068   if(it==_locs.end())
3069     {
3070       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3071       for(it=_locs.begin();it!=_locs.end();it++)
3072         oss << "\"" << (*it)->getName() << "\", ";
3073       throw INTERP_KERNEL::Exception(oss.str());
3074     }
3075   return std::distance(_locs.begin(),it);
3076 }
3077
3078 /*!
3079  * The returned value is never null.
3080  */
3081 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3082 {
3083   std::string pflNameCpp(pflName);
3084   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3085   if(it==_pfls.end())
3086     {
3087       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3088       for(it=_pfls.begin();it!=_pfls.end();it++)
3089         oss << "\"" << (*it)->getName() << "\", ";
3090       throw INTERP_KERNEL::Exception(oss.str());
3091     }
3092   return *it;
3093 }
3094
3095 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3096 {
3097   if(pflId<0 || pflId>=(int)_pfls.size())
3098     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3099   return _pfls[pflId];
3100 }
3101
3102 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3103 {
3104   if(locId<0 || locId>=(int)_locs.size())
3105     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3106   return *_locs[locId];
3107 }
3108
3109 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3110 {
3111   return getLocalizationFromId(getLocalizationId(locName));
3112 }
3113
3114 /*!
3115  * The returned value is never null.
3116  */
3117 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3118 {
3119   std::string pflNameCpp(pflName);
3120   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3121   if(it==_pfls.end())
3122     {
3123       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3124       for(it=_pfls.begin();it!=_pfls.end();it++)
3125         oss << "\"" << (*it)->getName() << "\", ";
3126       throw INTERP_KERNEL::Exception(oss.str());
3127     }
3128   return *it;
3129 }
3130
3131 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3132 {
3133   if(pflId<0 || pflId>=(int)_pfls.size())
3134     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3135   return _pfls[pflId];
3136 }
3137
3138 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3139 {
3140   std::vector< MCAuto<DataArrayInt> > newPfls;
3141   int i=0;
3142   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3143     {
3144       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3145         newPfls.push_back(*it);
3146     }
3147   _pfls=newPfls;
3148 }
3149
3150 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3151 {
3152   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3153   int i=0;
3154   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3155     {
3156       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3157         newLocs.push_back(*it);
3158     }
3159   _locs=newLocs;
3160 }
3161
3162 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3163 {
3164   int sz=_pfls.size();
3165   std::vector<std::string> ret(sz);
3166   for(int i=0;i<sz;i++)
3167     ret[i]=_pfls[i]->getName();
3168   return ret;
3169 }
3170
3171 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3172 {
3173   int sz=_locs.size();
3174   std::vector<std::string> ret(sz);
3175   for(int i=0;i<sz;i++)
3176     ret[i]=_locs[i]->getName();
3177   return ret;
3178 }
3179
3180 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3181 {
3182   std::vector<std::string> v=getPfls();
3183   std::string s(pflName);
3184   return std::find(v.begin(),v.end(),s)!=v.end();
3185 }
3186
3187 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3188 {
3189   std::vector<std::string> v=getLocs();
3190   std::string s(locName);
3191   return std::find(v.begin(),v.end(),s)!=v.end();
3192 }
3193
3194 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3195 {
3196   std::map<int,std::vector<int> > m;
3197   int i=0;
3198   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3199     {
3200       const DataArrayInt *tmp=(*it);
3201       if(tmp)
3202         {
3203           m[tmp->getHashCode()].push_back(i);
3204         }
3205     }
3206   std::vector< std::vector<int> > ret;
3207   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3208     {
3209       if((*it2).second.size()>1)
3210         {
3211           std::vector<int> ret0;
3212           bool equalityOrNot=false;
3213           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3214             {
3215               std::vector<int>::const_iterator it4=it3; it4++;
3216               for(;it4!=(*it2).second.end();it4++)
3217                 {
3218                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3219                     {
3220                       if(!equalityOrNot)
3221                         ret0.push_back(*it3);
3222                       ret0.push_back(*it4);
3223                       equalityOrNot=true;
3224                     }
3225                 }
3226             }
3227           if(!ret0.empty())
3228             ret.push_back(ret0);
3229         }
3230     }
3231   return ret;
3232 }
3233
3234 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3235 {
3236   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3237 }
3238
3239 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3240 {
3241   std::string name(pfl->getName());
3242   if(name.empty())
3243     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3244   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3245     if(name==(*it)->getName())
3246       {
3247         if(!pfl->isEqual(*(*it)))
3248           {
3249             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3250             throw INTERP_KERNEL::Exception(oss.str());
3251           }
3252       }
3253   pfl->incrRef();
3254   _pfls.push_back(pfl);
3255 }
3256
3257 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3258 {
3259   std::string name(locName);
3260   if(name.empty())
3261     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3262   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3263   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3264     if((*it)->isName(locName))
3265       {
3266         if(!(*it)->isEqual(*obj,1e-12))
3267           {
3268             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3269             throw INTERP_KERNEL::Exception(oss.str());
3270           }
3271       }
3272   _locs.push_back(obj);
3273 }
3274
3275 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3276 {
3277   std::vector<std::string> names=getPfls();
3278   return CreateNewNameNotIn("NewPfl_",names);
3279 }
3280
3281 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3282 {
3283   std::vector<std::string> names=getLocs();
3284   return CreateNewNameNotIn("NewLoc_",names);
3285 }
3286
3287 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3288 {
3289   for(std::size_t sz=0;sz<100000;sz++)
3290     {
3291       std::ostringstream tryName;
3292       tryName << prefix << sz;
3293       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3294         return tryName.str();
3295     }
3296   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3297 }
3298
3299 /*!
3300  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3301  *  \param [in] fname - the file name.
3302  */
3303 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3304 {
3305 }
3306
3307 /*!
3308  * Creates an empty MEDFileFieldGlobsReal.
3309  */
3310 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3311 {
3312 }
3313
3314 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3315 {
3316   return 0;
3317 }
3318
3319 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3320 {
3321   std::vector<const BigMemoryObject *> ret;
3322   ret.push_back((const MEDFileFieldGlobs *)_globals);
3323   return ret;
3324 }
3325
3326 /*!
3327  * Returns a string describing profiles and Gauss points held in \a this.
3328  *  \return std::string - the description string.
3329  */
3330 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3331 {
3332   const MEDFileFieldGlobs *glob=_globals;
3333   std::ostringstream oss2; oss2 << glob;
3334   std::string stars(oss2.str().length(),'*');
3335   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3336   if(glob)
3337     glob->simpleRepr(oss);
3338   else
3339     oss << "NO GLOBAL INFORMATION !\n";
3340 }
3341
3342 void MEDFileFieldGlobsReal::resetContent()
3343 {
3344   _globals=MEDFileFieldGlobs::New();
3345 }
3346
3347 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3348 {
3349 }
3350
3351 /*!
3352  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3353  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3354  */
3355 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3356 {
3357   _globals=other._globals;
3358 }
3359
3360 /*!
3361  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3362  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3363  */
3364 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3365 {
3366   const MEDFileFieldGlobs *otherg(other._globals);
3367   if(!otherg)
3368     return ;
3369   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3370 }
3371
3372 /*!
3373  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3374  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3375  */
3376 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3377 {
3378   const MEDFileFieldGlobs *otherg(other._globals);
3379   if(!otherg)
3380     return ;
3381   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3382 }
3383
3384 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3385 {
3386   _globals=other._globals;
3387   if((const MEDFileFieldGlobs *)_globals)
3388     _globals=other._globals->deepCopy();
3389 }
3390
3391 /*!
3392  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3393  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3394  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3395  *         \a this and \a other MEDFileFieldGlobsReal.
3396  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3397  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3398  */
3399 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3400 {
3401   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3402   if(thisGlobals==otherGlobals)
3403     return ;
3404   if(!thisGlobals)
3405     {
3406       _globals=other._globals;
3407       return ;
3408     }
3409   _globals->appendGlobs(*other._globals,eps);
3410 }
3411
3412 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3413 {
3414   checkGlobsPflsPartCoherency();
3415   checkGlobsLocsPartCoherency();
3416 }
3417
3418 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3419 {
3420   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3421 }
3422
3423 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3424 {
3425   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3426 }
3427
3428 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3429 {
3430   contentNotNull()->loadProfileInFile(fid,id,pflName);
3431 }
3432
3433 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3434 {
3435   contentNotNull()->loadProfileInFile(fid,id);
3436 }
3437
3438 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3439 {
3440   contentNotNull()->loadGlobals(fid,*this);
3441 }
3442
3443 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3444 {
3445   contentNotNull()->loadAllGlobals(fid);
3446 }
3447
3448 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3449 {
3450   contentNotNull()->writeGlobals(fid,opt);
3451 }
3452
3453 /*!
3454  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3455  * or getPflsReallyUsedMulti().
3456  *  \return std::vector<std::string> - a sequence of names of all profiles.
3457  */
3458 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3459 {
3460   return contentNotNull()->getPfls();
3461 }
3462
3463 /*!
3464  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3465  * or getLocsReallyUsedMulti().
3466  *  \return std::vector<std::string> - a sequence of names of all localizations.
3467  */
3468 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3469 {
3470   return contentNotNull()->getLocs();
3471 }
3472
3473 /*!
3474  * Checks if the profile with a given name exists.
3475  *  \param [in] pflName - the profile name of interest.
3476  *  \return bool - \c true if the profile named \a pflName exists.
3477  */
3478 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3479 {
3480   return contentNotNull()->existsPfl(pflName);
3481 }
3482
3483 /*!
3484  * Checks if the localization with a given name exists.
3485  *  \param [in] locName - the localization name of interest.
3486  *  \return bool - \c true if the localization named \a locName exists.
3487  */
3488 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3489 {
3490   return contentNotNull()->existsLoc(locName);
3491 }
3492
3493 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3494 {
3495   return contentNotNull()->createNewNameOfPfl();
3496 }
3497
3498 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3499 {
3500   return contentNotNull()->createNewNameOfLoc();
3501 }
3502
3503 /*!
3504  * Sets the name of a MED file.
3505  *  \param [inout] fileName - the file name.
3506  */
3507 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3508 {
3509   contentNotNull()->setFileName(fileName);
3510 }
3511
3512 /*!
3513  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3514  * in the same order.
3515  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3516  *          Each item of this sequence is a vector containing ids of equal profiles.
3517  */
3518 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3519 {
3520   return contentNotNull()->whichAreEqualProfiles();
3521 }
3522
3523 /*!
3524  * Finds equal localizations.
3525  *  \param [in] eps - a precision used to compare real values of the localizations.
3526  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3527  *          Each item of this sequence is a vector containing ids of equal localizations.
3528  */
3529 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3530 {
3531   return contentNotNull()->whichAreEqualLocs(eps);
3532 }
3533
3534 /*!
3535  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3536  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3537  *        this sequence is a pair whose 
3538  *        - the first item is a vector of profile names to replace by the second item,
3539  *        - the second item is a profile name to replace every profile name of the first item.
3540  */
3541 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3542 {
3543   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3544 }
3545
3546 /*!
3547  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3548  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3549  *        this sequence is a pair whose 
3550  *        - the first item is a vector of localization names to replace by the second item,
3551  *        - the second item is a localization name to replace every localization name of the first item.
3552  */
3553 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3554 {
3555   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3556 }
3557
3558 /*!
3559  * Replaces references to some profiles (a reference is a profile name) by references
3560  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3561  * them-selves accordingly. <br>
3562  * This method is a generalization of changePflName().
3563  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3564  *        this sequence is a pair whose 
3565  *        - the first item is a vector of profile names to replace by the second item,
3566  *        - the second item is a profile name to replace every profile of the first item.
3567  * \sa changePflsRefsNamesGen()
3568  * \sa changePflName()
3569  */
3570 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3571 {
3572   changePflsRefsNamesGen(mapOfModif);
3573   changePflsNamesInStruct(mapOfModif);
3574 }
3575
3576 /*!
3577  * Replaces references to some localizations (a reference is a localization name) by references
3578  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3579  * them-selves accordingly. <br>
3580  * This method is a generalization of changeLocName().
3581  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3582  *        this sequence is a pair whose 
3583  *        - the first item is a vector of localization names to replace by the second item,
3584  *        - the second item is a localization name to replace every localization of the first item.
3585  * \sa changeLocsRefsNamesGen()
3586  * \sa changeLocName()
3587  */
3588 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3589 {
3590   changeLocsRefsNamesGen(mapOfModif);
3591   changeLocsNamesInStruct(mapOfModif);
3592 }
3593
3594 /*!
3595  * Renames the profile having a given name and updates references to this profile.
3596  *  \param [in] oldName - the name of the profile to rename.
3597  *  \param [in] newName - a new name of the profile.
3598  * \sa changePflsNames().
3599  */
3600 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3601 {
3602   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3603   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3604   mapOfModif[0]=p;
3605   changePflsNames(mapOfModif);
3606 }
3607
3608 /*!
3609  * Renames the localization having a given name and updates references to this localization.
3610  *  \param [in] oldName - the name of the localization to rename.
3611  *  \param [in] newName - a new name of the localization.
3612  * \sa changeLocsNames().
3613  */
3614 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3615 {
3616   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3617   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3618   mapOfModif[0]=p;
3619   changeLocsNames(mapOfModif);
3620 }
3621
3622 /*!
3623  * Removes duplicated profiles. Returns a map used to update references to removed 
3624  * profiles via changePflsRefsNamesGen().
3625  * Equal profiles are found using whichAreEqualProfiles().
3626  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3627  *          a sequence describing the performed replacements of profiles. Each element of
3628  *          this sequence is a pair whose
3629  *          - the first item is a vector of profile names replaced by the second item,
3630  *          - the second item is a profile name replacing every profile of the first item.
3631  */
3632 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3633 {
3634   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3635   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3636   int i=0;
3637   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3638     {
3639       std::vector< std::string > tmp((*it).size());
3640       int j=0;
3641       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3642         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3643       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3644       ret[i]=p;
3645       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3646       killProfileIds(tmp2);
3647     }
3648   changePflsRefsNamesGen(ret);
3649   return ret;
3650 }
3651
3652 /*!
3653  * Removes duplicated localizations. Returns a map used to update references to removed 
3654  * localizations via changeLocsRefsNamesGen().
3655  * Equal localizations are found using whichAreEqualLocs().
3656  *  \param [in] eps - a precision used to compare real values of the localizations.
3657  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3658  *          a sequence describing the performed replacements of localizations. Each element of
3659  *          this sequence is a pair whose
3660  *          - the first item is a vector of localization names replaced by the second item,
3661  *          - the second item is a localization name replacing every localization of the first item.
3662  */
3663 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3664 {
3665   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3666   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3667   int i=0;
3668   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3669     {
3670       std::vector< std::string > tmp((*it).size());
3671       int j=0;
3672       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3673         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3674       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3675       ret[i]=p;
3676       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3677       killLocalizationIds(tmp2);
3678     }
3679   changeLocsRefsNamesGen(ret);
3680   return ret;
3681 }
3682
3683 /*!
3684  * Returns number of Gauss points per cell in a given localization.
3685  *  \param [in] locId - an id of the localization of interest.
3686  *  \return int - the number of the Gauss points per cell.
3687  */
3688 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3689 {
3690   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3691 }
3692
3693 /*!
3694  * Returns an id of a localization by its name.
3695  *  \param [in] loc - the localization name of interest.
3696  *  \return int - the id of the localization.
3697  *  \throw If there is no a localization named \a loc.
3698  */
3699 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3700 {
3701   return contentNotNull()->getLocalizationId(loc);
3702 }
3703
3704 /*!
3705  * Returns the name of the MED file.
3706  *  \return const std::string&  - the MED file name.
3707  */
3708 std::string MEDFileFieldGlobsReal::getFileName() const
3709 {
3710   return contentNotNull()->getFileName();
3711 }
3712
3713 /*!
3714  * Returns a localization object by its name.
3715  *  \param [in] locName - the name of the localization of interest.
3716  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3717  *  \throw If there is no a localization named \a locName.
3718  */
3719 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3720 {
3721   return contentNotNull()->getLocalization(locName);
3722 }
3723
3724 /*!
3725  * Returns a localization object by its id.
3726  *  \param [in] locId - the id of the localization of interest.
3727  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3728  *  \throw If there is no a localization with id \a locId.
3729  */
3730 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3731 {
3732   return contentNotNull()->getLocalizationFromId(locId);
3733 }
3734
3735 /*!
3736  * Returns a profile array by its name.
3737  *  \param [in] pflName - the name of the profile of interest.
3738  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3739  *  \throw If there is no a profile named \a pflName.
3740  */
3741 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3742 {
3743   return contentNotNull()->getProfile(pflName);
3744 }
3745
3746 /*!
3747  * Returns a profile array by its id.
3748  *  \param [in] pflId - the id of the profile of interest.
3749  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3750  *  \throw If there is no a profile with id \a pflId.
3751  */
3752 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3753 {
3754   return contentNotNull()->getProfileFromId(pflId);
3755 }
3756
3757 /*!
3758  * Returns a localization object, apt for modification, by its id.
3759  *  \param [in] locId - the id of the localization of interest.
3760  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3761  *          having the id \a locId.
3762  *  \throw If there is no a localization with id \a locId.
3763  */
3764 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3765 {
3766   return contentNotNull()->getLocalizationFromId(locId);
3767 }
3768
3769 /*!
3770  * Returns a localization object, apt for modification, by its name.
3771  *  \param [in] locName - the name of the localization of interest.
3772  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3773  *          having the name \a locName.
3774  *  \throw If there is no a localization named \a locName.
3775  */
3776 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3777 {
3778   return contentNotNull()->getLocalization(locName);
3779 }
3780
3781 /*!
3782  * Returns a profile array, apt for modification, by its name.
3783  *  \param [in] pflName - the name of the profile of interest.
3784  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3785  *  \throw If there is no a profile named \a pflName.
3786  */
3787 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3788 {
3789   return contentNotNull()->getProfile(pflName);
3790 }
3791
3792 /*!
3793  * Returns a profile array, apt for modification, by its id.
3794  *  \param [in] pflId - the id of the profile of interest.
3795  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3796  *  \throw If there is no a profile with id \a pflId.
3797  */
3798 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3799 {
3800   return contentNotNull()->getProfileFromId(pflId);
3801 }
3802
3803 /*!
3804  * Removes profiles given by their ids. No data is updated to track this removal.
3805  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3806  */
3807 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3808 {
3809   contentNotNull()->killProfileIds(pflIds);
3810 }
3811
3812 /*!
3813  * Removes localizations given by their ids. No data is updated to track this removal.
3814  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3815  */
3816 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3817 {
3818   contentNotNull()->killLocalizationIds(locIds);
3819 }
3820
3821 /*!
3822  * Stores a profile array.
3823  *  \param [in] pfl - the profile array to store.
3824  *  \throw If the name of \a pfl is empty.
3825  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3826  *         different ids.
3827  */
3828 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3829 {
3830   contentNotNull()->appendProfile(pfl);
3831 }
3832
3833 /*!
3834  * Adds a new localization of Gauss points.
3835  *  \param [in] locName - the name of the new localization.
3836  *  \param [in] geoType - a geometrical type of the reference cell.
3837  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3838  *         must be \c nbOfNodesPerCell * \c dimOfType.
3839  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3840  *         must be  _wg_.size() * \c dimOfType.
3841  *  \param [in] w - the weights of Gauss points.
3842  *  \throw If \a locName is empty.
3843  *  \throw If a localization with the name \a locName already exists but is
3844  *         different form the new one.
3845  */
3846 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3847 {
3848   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3849 }
3850
3851 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3852 {
3853   MEDFileFieldGlobs *g(_globals);
3854   if(!g)
3855     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3856   return g;
3857 }
3858
3859 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3860 {
3861   const MEDFileFieldGlobs *g(_globals);
3862   if(!g)
3863     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3864   return g;
3865 }
3866
3867 //= MEDFileFieldNameScope
3868
3869 MEDFileFieldNameScope::MEDFileFieldNameScope()
3870 {
3871 }
3872
3873 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3874 {
3875 }
3876
3877 /*!
3878  * Returns the name of \a this field.
3879  *  \return std::string - a string containing the field name.
3880  */
3881 std::string MEDFileFieldNameScope::getName() const
3882 {
3883   return _name;
3884 }
3885
3886 /*!
3887  * Sets name of \a this field
3888  *  \param [in] name - the new field name.
3889  */
3890 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3891 {
3892   _name=fieldName;
3893 }
3894
3895 std::string MEDFileFieldNameScope::getDtUnit() const
3896 {
3897   return _dt_unit;
3898 }
3899
3900 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3901 {
3902   _dt_unit=dtUnit;
3903 }
3904
3905 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3906 {
3907   _name=other._name;
3908   _dt_unit=other._dt_unit;
3909 }
3910
3911 //= MEDFileAnyTypeField1TSWithoutSDA
3912
3913 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3914 {
3915   _field_per_mesh.resize(other._field_per_mesh.size());
3916   std::size_t i=0;
3917   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3918     {
3919       if((const MEDFileFieldPerMesh *)*it)
3920         _field_per_mesh[i]=(*it)->deepCopy(this);
3921     }
3922 }
3923
3924 /*!
3925  * Prints a string describing \a this field into a stream. This string is outputted 
3926  * by \c print Python command.
3927  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3928  *  \param [in,out] oss - the out stream.
3929  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3930  *          info id printed, else, not.
3931  */
3932 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3933 {
3934   std::string startOfLine(bkOffset,' ');
3935   oss << startOfLine << "Field ";
3936   if(bkOffset==0)
3937     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3938   oss << "on one time Step ";
3939   if(f1tsId>=0)
3940     oss << "(" << f1tsId << ") ";
3941   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3942   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3943   const DataArray *arr=getUndergroundDataArray();
3944   if(arr)
3945     {
3946       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3947       if(f1tsId<0)
3948         {
3949           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3950           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3951             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3952         }
3953       if(arr->isAllocated())
3954         {
3955           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3956         }
3957       else
3958         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3959     }
3960   else
3961     {
3962       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3963     }
3964   oss << startOfLine << "----------------------" << std::endl;
3965   if(!_field_per_mesh.empty())
3966     {
3967       int i=0;
3968       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3969         {
3970           const MEDFileFieldPerMesh *cur=(*it2);
3971           if(cur)
3972             cur->simpleRepr(bkOffset,oss,i);
3973           else
3974             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3975         }
3976     }
3977   else
3978     {
3979       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3980     }
3981   oss << startOfLine << "----------------------" << std::endl;
3982 }
3983
3984 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3985 {
3986   const DataArray *arr(getUndergroundDataArray());
3987   if(!arr)
3988     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3989   int nbOfCompo=arr->getNumberOfComponents();
3990   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3991   for(int i=0;i<nbOfCompo;i++)
3992     {
3993       ret[i]=deepCopy();
3994       std::vector<int> v(1,i);
3995       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3996       ret[i]->setArray(arr2);
3997     }
3998   return ret;
3999 }
4000
4001 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
4002 {
4003 }
4004
4005 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4006 {
4007 }
4008
4009 /*!
4010  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4011  * empty. Returns -1 if this in on nodes.
4012  *  \return int - the dimension of \a this.
4013  */
4014 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4015 {
4016   int ret=-2;
4017   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4018     (*it)->getDimension(ret);
4019   return ret;
4020 }
4021
4022 /*!
4023  * Returns the mesh name.
4024  *  \return std::string - a string holding the mesh name.
4025  *  \throw If \c _field_per_mesh.empty()
4026  */
4027 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4028 {
4029   if(_field_per_mesh.empty())
4030     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4031   return _field_per_mesh[0]->getMeshName();
4032 }
4033
4034 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4035 {
4036   std::string oldName(getMeshName());
4037   std::vector< std::pair<std::string,std::string> > v(1);
4038   v[0].first=oldName; v[0].second=newMeshName;
4039   changeMeshNames(v);
4040 }
4041
4042 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4043 {
4044   bool ret=false;
4045   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4046     {
4047       MEDFileFieldPerMesh *cur(*it);
4048       if(cur)
4049         ret=cur->changeMeshNames(modifTab) || ret;
4050     }
4051   return ret;
4052 }
4053
4054 /*!
4055  * Returns the number of iteration of the state of underlying mesh.
4056  *  \return int - the iteration number.
4057  *  \throw If \c _field_per_mesh.empty()
4058  */
4059 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4060 {
4061   if(_field_per_mesh.empty())
4062     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4063   return _field_per_mesh[0]->getMeshIteration();
4064 }
4065
4066 /*!
4067  * Returns the order number of iteration of the state of underlying mesh.
4068  *  \return int - the order number.
4069  *  \throw If \c _field_per_mesh.empty()
4070  */
4071 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4072 {
4073   if(_field_per_mesh.empty())
4074     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4075   return _field_per_mesh[0]->getMeshOrder();
4076 }
4077
4078 /*!
4079  * Checks if \a this field is tagged by a given iteration number and a given
4080  * iteration order number.
4081  *  \param [in] iteration - the iteration number of interest.
4082  *  \param [in] order - the iteration order number of interest.
4083  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4084  *          \a this->getOrder() == \a order.
4085  */
4086 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4087 {
4088   return iteration==_iteration && order==_order;
4089 }
4090
4091 /*!
4092  * Returns number of iteration and order number of iteration when
4093  * \a this field has been calculated.
4094  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4095  *          order number.
4096  */
4097 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4098 {
4099   std::pair<int,int> p;
4100   fillIteration(p);
4101   return p;
4102 }
4103
4104 /*!
4105  * Returns number of iteration and order number of iteration when
4106  * \a this field has been calculated.
4107  *  \param [in,out] p - a pair returning the iteration number and the iteration
4108  *          order number.
4109  */
4110 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4111 {
4112   p.first=_iteration;
4113   p.second=_order;
4114 }
4115
4116 /*!
4117  * Returns all types of spatial discretization of \a this field.
4118  *  \param [in,out] types - a sequence of types of \a this field.
4119  */
4120 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4121 {
4122   std::set<TypeOfField> types2;
4123   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4124     {
4125       (*it)->fillTypesOfFieldAvailable(types2);
4126     }
4127   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4128   std::copy(types2.begin(),types2.end(),bi);
4129 }
4130
4131 /*!
4132  * Returns all types of spatial discretization of \a this field.
4133  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4134  *          of \a this field.
4135  */
4136 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4137 {
4138   std::vector<TypeOfField> ret;
4139   fillTypesOfFieldAvailable(ret);
4140   return ret;
4141 }
4142
4143 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4144 {
4145   std::vector<std::string> ret;
4146   std::set<std::string> ret2;
4147   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4148     {
4149       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4150       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4151         if(ret2.find(*it2)==ret2.end())
4152           {
4153             ret.push_back(*it2);
4154             ret2.insert(*it2);
4155           }
4156     }
4157   return ret;
4158 }
4159
4160 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4161 {
4162   std::vector<std::string> ret;
4163   std::set<std::string> ret2;
4164   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4165     {
4166       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4167       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4168         if(ret2.find(*it2)==ret2.end())
4169           {
4170             ret.push_back(*it2);
4171             ret2.insert(*it2);
4172           }
4173     }
4174   return ret;
4175 }
4176
4177 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4178 {
4179   std::vector<std::string> ret;
4180   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4181     {
4182       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4183       ret.insert(ret.end(),tmp.begin(),tmp.end());
4184     }
4185   return ret;
4186 }
4187
4188 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4189 {
4190   std::vector<std::string> ret;
4191   std::set<std::string> ret2;
4192   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4193     {
4194       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4195       ret.insert(ret.end(),tmp.begin(),tmp.end());
4196     }
4197   return ret;
4198 }
4199
4200 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4201 {
4202   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4203     (*it)->changePflsRefsNamesGen(mapOfModif);
4204 }
4205
4206 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4207 {
4208   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4209     (*it)->changeLocsRefsNamesGen(mapOfModif);
4210 }
4211
4212 /*!
4213  * Returns all attributes of parts of \a this field lying on a given mesh.
4214  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4215  * item of every of returned sequences refers to the _i_-th part of \a this field.
4216  * Thus all sequences returned by this method are of the same length equal to number
4217  * of different types of supporting entities.<br>
4218  * A field part can include sub-parts with several different spatial discretizations,
4219  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4220  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4221  * of a nested sequence corresponds to a type of spatial discretization.<br>
4222  * This method allows for iteration over MEDFile DataStructure without any overhead.
4223  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4224  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4225  *          not checked if \a mname == \c NULL).
4226  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4227  *          a field part is returned. 
4228  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4229  *          This sequence is of the same length as \a types. 
4230  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4231  *          discretization. A profile name can be empty.
4232  *          Length of this and of nested sequences is the same as that of \a typesF.
4233  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4234  *          discretization. A localization name can be empty.
4235  *          Length of this and of nested sequences is the same as that of \a typesF.
4236  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4237  *          of ids of tuples within the data array, per each type of spatial
4238  *          discretization within one mesh entity type. 
4239  *          Length of this and of nested sequences is the same as that of \a typesF.
4240  *  \throw If no field is lying on \a mname.
4241  */
4242 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(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
4243 {
4244   int meshId=0;
4245   if(!mname.empty())
4246     meshId=getMeshIdFromMeshName(mname);
4247   else
4248     if(_field_per_mesh.empty())
4249       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4250   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4251 }
4252
4253 /*!
4254  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4255  * maximal absolute dimension and values returned via the out parameter \a levs are 
4256  * dimensions relative to the maximal absolute dimension. <br>
4257  * This method is designed for MEDFileField1TS instances that have a discretization
4258  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4259  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4260  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4261  * Only these 3 discretizations will be taken into account here. If \a this is
4262  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4263  * This method is useful to make the link between the dimension of the underlying mesh
4264  * and the levels of \a this, because it is possible that the highest dimension of \a this
4265  * field is not equal to the dimension of the underlying mesh.
4266  * 
4267  * Let's consider the following case:
4268  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4269  * TETRA4, HEXA8, TRI3 and SEG2.
4270  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4271  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4272  *
4273  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4274  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4275  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4276  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4277  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4278  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4279  * For example<br>
4280  * to retrieve the highest level of
4281  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4282  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4283  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4284  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4285  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4286  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4287  *          not checked if \a mname == \c NULL).
4288  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4289  *          absolute one. They are in decreasing order. This sequence is cleared before
4290  *          filling it in.
4291  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4292  *  \throw If no field is lying on \a mname.
4293  */
4294 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4295 {
4296   levs.clear();
4297   int meshId=getMeshIdFromMeshName(mname);
4298   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4299   std::vector< std::vector<TypeOfField> > typesF;
4300   std::vector< std::vector<std::string> > pfls, locs;
4301   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4302   if(types.empty())
4303     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4304   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4305   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4306     return -1;
4307   st.erase(INTERP_KERNEL::NORM_ERROR);
4308   std::set<int> ret1;
4309   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4310     {
4311       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4312       ret1.insert((int)cm.getDimension());
4313     }
4314   int ret=*std::max_element(ret1.begin(),ret1.end());
4315   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4316   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4317   return ret;
4318 }
4319
4320 /*!
4321  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4322  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
4323  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4324  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4325  */
4326 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4327 {
4328   int mid=getMeshIdFromMeshName(mName);
4329   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4330 }
4331
4332 /*!
4333  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4334  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
4335  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4336  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4337  */
4338 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4339 {
4340   int mid=getMeshIdFromMeshName(mName);
4341   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4342 }
4343
4344 /*!
4345  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4346  */
4347 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4348 {
4349   if(_field_per_mesh.empty())
4350     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4351   if(mName.empty())
4352     return 0;
4353   std::string mName2(mName);
4354   int ret=0;
4355   std::vector<std::string> msg;
4356   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4357     if(mName2==(*it)->getMeshName())
4358       return ret;
4359     else
4360       msg.push_back((*it)->getMeshName());
4361   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4362   oss << "Possible meshes are : ";
4363   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4364     oss << "\"" << (*it2) << "\" ";
4365   throw INTERP_KERNEL::Exception(oss.str());
4366 }
4367
4368 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4369 {
4370   if(!mesh)
4371     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4372   std::string tmp(mesh->getName());
4373   if(tmp.empty())
4374     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4375   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4376   int i=0;
4377   for(;it!=_field_per_mesh.end();it++,i++)
4378     {
4379       if((*it)->getMeshName()==tmp)
4380         return i;
4381     }
4382   int sz=_field_per_mesh.size();
4383   _field_per_mesh.resize(sz+1);
4384   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4385   return sz;
4386 }
4387
4388 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4389                                                                    MEDFileFieldGlobsReal& glob)
4390 {
4391   bool ret=false;
4392   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4393     {
4394       MEDFileFieldPerMesh *fpm(*it);
4395       if(fpm)
4396         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4397     }
4398   return ret;
4399 }
4400
4401 /*!
4402  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4403  * splitting that leads to single spatial discretization of this.
4404  *
4405  * \sa splitMultiDiscrPerGeoTypes
4406  */
4407 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4408 {
4409   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4410   std::vector< std::vector<TypeOfField> > typesF;
4411   std::vector< std::vector<std::string> > pfls,locs;
4412   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4413   std::set<TypeOfField> allEnt;
4414   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4415     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4416       allEnt.insert(*it2);
4417   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4418   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4419   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4420     {
4421       std::vector< std::pair<int,int> > its;
4422       ret[i]=shallowCpy();
4423       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4424       ret[i]->updateData(newLgth,its);
4425     }
4426   return ret;
4427 }
4428
4429 /*!
4430  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4431  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4432  *
4433  * \sa splitDiscretizations
4434  */
4435 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4436 {
4437   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4438   std::vector< std::vector<TypeOfField> > typesF;
4439   std::vector< std::vector<std::string> > pfls,locs;
4440   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4441   std::set<TypeOfField> allEnt;
4442   std::size_t nbOfMDPGT(0),ii(0);
4443   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4444     {
4445       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4446       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4447         allEnt.insert(*it2);
4448     }
4449   if(allEnt.size()!=1)
4450     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4451   if(nbOfMDPGT==0)
4452     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4453   if(nbOfMDPGT==1)
4454     {
4455       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4456       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4457       return ret0;
4458     }
4459   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4460   for(std::size_t i=0;i<nbOfMDPGT;i++)
4461     {
4462       std::vector< std::pair<int,int> > its;
4463       ret[i]=shallowCpy();
4464       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4465       ret[i]->updateData(newLgth,its);
4466     }
4467   return ret;
4468 }
4469
4470 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4471 {
4472   int globalCounter(0);
4473   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4474     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4475   return globalCounter;
4476 }
4477
4478 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4479 {
4480   int globalCounter(0);
4481   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4482     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4483   return globalCounter;
4484 }
4485
4486 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4487 {
4488   if(_nb_of_tuples_to_be_allocated>=0)
4489     {
4490       _nb_of_tuples_to_be_allocated=newLgth;
4491       const DataArray *oldArr(getUndergroundDataArray());
4492       if(oldArr)
4493         {
4494           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4495           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4496           setArray(newArr);
4497           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4498         }
4499       return ;
4500     }
4501   if(_nb_of_tuples_to_be_allocated==-1)
4502     return ;
4503   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4504     {
4505       const DataArray *oldArr(getUndergroundDataArray());
4506       if(!oldArr || !oldArr->isAllocated())
4507         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4508       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4509       newArr->alloc(newLgth,getNumberOfComponents());
4510       if(oldArr)
4511         newArr->copyStringInfoFrom(*oldArr);
4512       int pos=0;
4513       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4514         {
4515           if((*it).second<(*it).first)
4516             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4517           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4518           pos+=(*it).second-(*it).first;
4519         }
4520       setArray(newArr);
4521       return ;
4522     }
4523   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4524 }
4525
4526 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4527 {
4528   if(_field_per_mesh.empty())
4529     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4530   if(_field_per_mesh.size()>1)
4531     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4532   _field_per_mesh[0]->copyOptionsFrom(opts);
4533   _field_per_mesh[0]->writeLL(fid,nasc);
4534 }
4535
4536 /*!
4537  * This methods returns true is the allocation has been needed leading to a modification of state in \a this->_nb_of_tuples_to_be_allocated.
4538  * If false is returned the memory allocation is not required.
4539  */
4540 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4541 {
4542   if(_nb_of_tuples_to_be_allocated>=0)
4543     {
4544       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4545       _nb_of_tuples_to_be_allocated=-2;
4546       return true;
4547     }
4548   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4549     return false;
4550   if(_nb_of_tuples_to_be_allocated==-1)
4551     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4552   if(_nb_of_tuples_to_be_allocated<-3)
4553     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4554   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4555 }
4556
4557 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4558 {
4559   med_int numdt,numit;
4560   med_float dt;
4561   med_int nmesh;
4562   med_bool localMesh;
4563   med_int meshnumdt,meshnumit;
4564   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4565   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4566   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4567   if(_iteration!=numdt || _order!=numit)
4568     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4569   _field_per_mesh.resize(nmesh);
4570   //
4571   MEDFileMesh *mm(0);
4572   if(ms)
4573     {
4574       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4575       mm=ms->getMeshWithName(meshNameCpp);
4576     }
4577   //
4578   for(int i=0;i<nmesh;i++)
4579     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4580   _nb_of_tuples_to_be_allocated=0;
4581   for(int i=0;i<nmesh;i++)
4582     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4583 }
4584
4585 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4586 {
4587   allocIfNecessaryTheArrayToReceiveDataFromFile();
4588   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4589     (*it)->loadBigArraysRecursively(fid,nasc);
4590 }
4591
4592 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4593 {
4594   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4595     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4596       (*it)->loadBigArraysRecursively(fid,nasc);
4597 }
4598
4599 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4600 {
4601   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4602   loadBigArraysRecursively(fid,nasc);
4603 }
4604
4605 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4606 {
4607   DataArray *thisArr(getUndergroundDataArray());
4608   if(thisArr && thisArr->isAllocated())
4609     {
4610       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4611       thisArr->desallocate();
4612     }
4613 }
4614
4615 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4616 {
4617   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4618 }
4619
4620 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4621 {
4622   std::vector<const BigMemoryObject *> ret;
4623   if(getUndergroundDataArray())
4624     ret.push_back(getUndergroundDataArray());
4625   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4626     ret.push_back((const MEDFileFieldPerMesh *)*it);
4627   return ret;
4628 }
4629
4630 /*!
4631  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4632  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4633  * "Sort By Type"), if not, an exception is thrown. 
4634  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4635  *  \param [in] arr - the array of values.
4636  *  \param [in,out] glob - the global data where profiles and localization present in
4637  *          \a field, if any, are added.
4638  *  \throw If the name of \a field is empty.
4639  *  \throw If the data array of \a field is not set.
4640  *  \throw If \a this->_arr is already allocated but has different number of components
4641  *         than \a field.
4642  *  \throw If the underlying mesh of \a field has no name.
4643  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4644  */
4645 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4646 {
4647   const MEDCouplingMesh *mesh=field->getMesh();
4648   //
4649   TypeOfField type=field->getTypeOfField();
4650   std::vector<DataArrayInt *> dummy;
4651   int start=copyTinyInfoFrom(field,arr);
4652   int pos=addNewEntryIfNecessary(mesh);
4653   if(type!=ON_NODES)
4654     {
4655       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4656       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4657     }
4658   else
4659     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4660 }
4661
4662 /*!
4663  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4664  * of a given mesh are used as the support of the given field (a real support is not used). 
4665  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4666  * Order of underlying mesh entities of the given field specified by \a profile parameter
4667  * is not prescribed; this method permutes field values to have them sorted by element
4668  * type as required for writing to MED file. A new profile is added only if no equal
4669  * profile is missing. 
4670  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4671  *  \param [in] arrOfVals - the values of the field \a field used.
4672  *  \param [in] mesh - the supporting mesh of \a field.
4673  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4674  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4675  *  \param [in,out] glob - the global data where profiles and localization present in
4676  *          \a field, if any, are added.
4677  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4678  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4679  *  \throw If the data array of \a field is not set.
4680  *  \throw If \a this->_arr is already allocated but has different number of components
4681  *         than \a field.
4682  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4683  *  \sa setFieldNoProfileSBT()
4684  */
4685 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4686 {
4687   if(!field)
4688     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4689   if(!arrOfVals || !arrOfVals->isAllocated())
4690     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4691   TypeOfField type=field->getTypeOfField();
4692   std::vector<DataArrayInt *> idsInPflPerType;
4693   std::vector<DataArrayInt *> idsPerType;
4694   std::vector<int> code,code2;
4695   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4696   if(type!=ON_NODES)
4697     {
4698       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4699       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4700       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4701       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4702       // start of check
4703       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4704       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4705       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4706         {
4707           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4708           throw INTERP_KERNEL::Exception(oss.str());
4709         }
4710       // end of check
4711       int start=copyTinyInfoFrom(field,arrOfVals);
4712       code2=m->getDistributionOfTypes();
4713       //
4714       int pos=addNewEntryIfNecessary(m);
4715       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4716     }
4717   else
4718     {
4719       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4720         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4721       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4722       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4723       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4724       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4725         {
4726           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4727           throw INTERP_KERNEL::Exception(oss.str());
4728         }
4729       int start=copyTinyInfoFrom(field,arrOfVals);
4730       int pos=addNewEntryIfNecessary(m);
4731       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4732     }
4733 }
4734
4735 /*!
4736  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4737  */
4738 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4739 {
4740   if(_nb_of_tuples_to_be_allocated>=0)
4741     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile : the object is expected to be appended to a data coming from a file but not loaded ! Load before appending data !");
4742   DataArray *arr(getOrCreateAndGetArray());
4743   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4744   _nb_of_tuples_to_be_allocated=-3;
4745 }
4746
4747 /*!
4748  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4749  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4750  * larger by the size of \a field. Returns an id of the first not filled
4751  * tuple of \a this->_arr.
4752  *  \param [in] field - the field to copy the info on components and the name from.
4753  *  \return int - the id of first not initialized tuple of \a this->_arr.
4754  *  \throw If the name of \a field is empty.
4755  *  \throw If the data array of \a field is not set.
4756  *  \throw If \a this->_arr is already allocated but has different number of components
4757  *         than \a field.
4758  */
4759 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4760 {
4761   if(!field)
4762     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4763   std::string name(field->getName());
4764   setName(name.c_str());
4765   setDtUnit(field->getTimeUnit());
4766   if(name.empty())
4767     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4768   if(!arr)
4769     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4770   if(!arr->isAllocated())
4771     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4772   _dt=field->getTime(_iteration,_order);
4773   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4774   if(!getOrCreateAndGetArray()->isAllocated())
4775     {
4776       allocNotFromFile(arr->getNumberOfTuples());
4777       return 0;
4778     }
4779   else
4780     {
4781       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4782       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4783       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4784       _nb_of_tuples_to_be_allocated=-3;
4785       return oldNbOfTuples;
4786     }
4787 }
4788
4789 /*!
4790  * Returns number of components in \a this field
4791  *  \return int - the number of components.
4792  */
4793 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4794 {
4795   return getOrCreateAndGetArray()->getNumberOfComponents();
4796 }
4797
4798 /*!
4799  * Change info on components in \a this.
4800  * \throw If size of \a infos is not equal to the number of components already in \a this.
4801  */
4802 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4803 {
4804   DataArray *arr=getOrCreateAndGetArray();
4805   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4806 }
4807
4808 /*!
4809  * Returns info on components of \a this field.
4810  *  \return const std::vector<std::string>& - a sequence of strings each being an
4811  *          information on _i_-th component.
4812  */
4813 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4814 {
4815   const DataArray *arr=getOrCreateAndGetArray();
4816   return arr->getInfoOnComponents();
4817 }
4818
4819 /*!
4820  * Returns a mutable info on components of \a this field.
4821  *  \return std::vector<std::string>& - a sequence of strings each being an
4822  *          information on _i_-th component.
4823  */
4824 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4825 {
4826   DataArray *arr=getOrCreateAndGetArray();
4827   return arr->getInfoOnComponents();
4828 }
4829
4830 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4831 {
4832   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4833     {
4834       const MEDFileFieldPerMesh *fpm(*it);
4835       if(!fpm)
4836         continue;
4837       if(fpm->presenceOfMultiDiscPerGeoType())
4838         return true;
4839     }
4840   return false;
4841 }
4842
4843 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4844 {
4845   static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with  \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
4846   if(_field_per_mesh.empty())
4847     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4848   if(_field_per_mesh.size()>1)
4849     throw INTERP_KERNEL::Exception(MSG0);
4850   if(_field_per_mesh[0].isNull())
4851     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4852   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4853   std::set<TypeOfField> types;
4854   pm->fillTypesOfFieldAvailable(types);
4855   if(types.size()!=1)
4856     throw INTERP_KERNEL::Exception(MSG0);
4857   TypeOfField type(*types.begin());
4858   int meshDimRelToMax(0);
4859   if(type==ON_NODES)
4860     meshDimRelToMax=0;
4861   else
4862     {
4863       int myDim(std::numeric_limits<int>::max());
4864       bool isUnique(pm->isUniqueLevel(myDim));
4865       if(!isUnique)
4866         throw INTERP_KERNEL::Exception(MSG0);
4867       meshDimRelToMax=myDim-mesh->getMeshDimension();
4868       if(meshDimRelToMax>0)
4869         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4870     }
4871   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4872 }
4873
4874 /*!
4875  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4876  *  \param [in] type - a spatial discretization of the new field.
4877  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4878  *  \param [in] mName - a name of the supporting mesh.
4879  *  \param [in] renumPol - specifies how to permute values of the result field according to
4880  *          the optional numbers of cells and nodes, if any. The valid values are
4881  *          - 0 - do not permute.
4882  *          - 1 - permute cells.
4883  *          - 2 - permute nodes.
4884  *          - 3 - permute cells and nodes.
4885  *
4886  *  \param [in] glob - the global data storing profiles and localization.
4887  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4888  *          caller is to delete this field using decrRef() as it is no more needed. 
4889  *  \throw If the MED file is not readable.
4890  *  \throw If there is no mesh named \a mName in the MED file.
4891  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4892  *  \throw If no field of \a this is lying on the mesh \a mName.
4893  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4894  */
4895 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4896 {
4897   MCAuto<MEDFileMesh> mm;
4898   if(mName.empty())
4899     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4900   else
4901     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4902   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4903 }
4904
4905 /*!
4906  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4907  *  \param [in] type - a spatial discretization of the new field.
4908  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4909  *  \param [in] renumPol - specifies how to permute values of the result field according to
4910  *          the optional numbers of cells and nodes, if any. The valid values are
4911  *          - 0 - do not permute.
4912  *          - 1 - permute cells.
4913  *          - 2 - permute nodes.
4914  *          - 3 - permute cells and nodes.
4915  *
4916  *  \param [in] glob - the global data storing profiles and localization.
4917  *  \param [in] mesh - the supporting mesh.
4918  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4919  *          caller is to delete this field using decrRef() as it is no more needed. 
4920  *  \throw If the MED file is not readable.
4921  *  \throw If no field of \a this is lying on \a mesh.
4922  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4923  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4924  */
4925 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4926 {
4927   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4928   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4929   if(meshDimRelToMax==1)
4930     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4931   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4932 }
4933
4934 /*!
4935  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4936  * given mesh. 
4937  *  \param [in] type - a spatial discretization of the new field.
4938  *  \param [in] mName - a name of the supporting mesh.
4939  *  \param [in] renumPol - specifies how to permute values of the result field according to
4940  *          the optional numbers of cells and nodes, if any. The valid values are
4941  *          - 0 - do not permute.
4942  *          - 1 - permute cells.
4943  *          - 2 - permute nodes.
4944  *          - 3 - permute cells and nodes.
4945  *
4946  *  \param [in] glob - the global data storing profiles and localization.
4947  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4948  *          caller is to delete this field using decrRef() as it is no more needed. 
4949  *  \throw If the MED file is not readable.
4950  *  \throw If there is no mesh named \a mName in the MED file.
4951  *  \throw If there are no mesh entities in the mesh.
4952  *  \throw If no field values of the given \a type are available.
4953  */
4954 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4955 {
4956   MCAuto<MEDFileMesh> mm;
4957   if(mName.empty())
4958     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4959   else
4960     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4961   int absDim=getDimension();
4962   int meshDimRelToMax=absDim-mm->getMeshDimension();
4963   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4964 }
4965
4966 /*!
4967  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4968  *  \param [in] type - a spatial discretization of the new field.
4969  *  \param [in] renumPol - specifies how to permute values of the result field according to
4970  *          the optional numbers of cells and nodes, if any. The valid values are
4971  *          - 0 - do not permute.
4972  *          - 1 - permute cells.
4973  *          - 2 - permute nodes.
4974  *          - 3 - permute cells and nodes.
4975  *
4976  *  \param [in] glob - the global data storing profiles and localization.
4977  *  \param [in] mesh - the supporting mesh.
4978  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4979  *         field according to \a renumPol.
4980  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4981  *         field according to \a renumPol.
4982  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4983  *          caller is to delete this field using decrRef() as it is no more needed. 
4984  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4985  *  \throw If no field of \a this is lying on \a mesh.
4986  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4987  */
4988 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4989 {
4990   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4991   int meshId=getMeshIdFromMeshName(mesh->getName());
4992   bool isPfl=false;
4993   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4994   switch(renumPol)
4995   {
4996     case 0:
4997       {
4998         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4999         return ret.retn();
5000       }
5001     case 3:
5002     case 1:
5003       {
5004         if(isPfl)
5005           throw INTERP_KERNEL::Exception(msg1);
5006         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5007         if(cellRenum)
5008           {
5009             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5010               {
5011                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5012                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5013                 throw INTERP_KERNEL::Exception(oss.str());
5014               }
5015             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5016             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5017             std::vector<DataArray *> arrOut2(1,arrOut);
5018             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5019             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5020             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5021           }
5022         if(renumPol==1)
5023           return ret.retn();
5024       }
5025     case 2:
5026       {
5027         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5028         if(isPfl)
5029           throw INTERP_KERNEL::Exception(msg1);
5030         if(nodeRenum)
5031           {
5032             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5033               {
5034                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5035                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5036                 throw INTERP_KERNEL::Exception(oss.str());
5037               }
5038             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5039             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5040               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5041             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5042           }
5043         return ret.retn();
5044       }
5045     default:
5046       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5047   }
5048 }
5049
5050 /*!
5051  * Returns values and a profile of the field of a given type lying on a given support.
5052  *  \param [in] type - a spatial discretization of the field.
5053  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5054  *  \param [in] mesh - the supporting mesh.
5055  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5056  *          field of interest lies on. If the field lies on all entities of the given
5057  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5058  *          using decrRef() as it is no more needed.  
5059  *  \param [in] glob - the global data storing profiles and localization.
5060  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5061  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5062  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5063  *  \throw If no field of \a this is lying on \a mesh.
5064  *  \throw If no field values of the given \a type are available.
5065  */
5066 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5067 {
5068   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5069   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5070   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5071   ret->setName(nasc.getName().c_str());
5072   return ret.retn();
5073 }
5074
5075 //= MEDFileField1TSWithoutSDA
5076
5077 /*!
5078  * Throws if a given value is not a valid (non-extended) relative dimension.
5079  *  \param [in] meshDimRelToMax - the relative dimension value.
5080  *  \throw If \a meshDimRelToMax > 0.
5081  */
5082 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5083 {
5084   if(meshDimRelToMax>0)
5085     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5086 }
5087
5088 /*!
5089  * Checks if elements of a given mesh are in the order suitable for writing 
5090  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5091  * vector describing types of elements and their number.
5092  *  \param [in] mesh - the mesh to check.
5093  *  \return std::vector<int> - a vector holding for each element type (1) item of
5094  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5095  *          These values are in full-interlace mode.
5096  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5097  */
5098 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5099 {
5100   if(!mesh)
5101     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5102   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5103   int nbOfTypes=geoTypes.size();
5104   std::vector<int> code(3*nbOfTypes);
5105   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5106   arr1->alloc(nbOfTypes,1);
5107   int *arrPtr=arr1->getPointer();
5108   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5109   for(int i=0;i<nbOfTypes;i++,it++)
5110     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5111   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5112   const int *arrPtr2=arr2->getConstPointer();
5113   int i=0;
5114   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5115     {
5116       int pos=arrPtr2[i];
5117       int nbCells=mesh->getNumberOfCellsWithType(*it);
5118       code[3*pos]=(int)(*it);
5119       code[3*pos+1]=nbCells;
5120       code[3*pos+2]=-1;//no profiles
5121     }
5122   std::vector<const DataArrayInt *> idsPerType;//no profiles
5123   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5124   if(da)
5125     {
5126       da->decrRef();
5127       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5128     }
5129   return code;
5130 }
5131
5132 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5133 {
5134   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5135 }
5136
5137 /*!
5138  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5139  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5140  * item of every of returned sequences refers to the _i_-th part of \a this field.
5141  * Thus all sequences returned by this method are of the same length equal to number
5142  * of different types of supporting entities.<br>
5143  * A field part can include sub-parts with several different spatial discretizations,
5144  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5145  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5146  * of a nested sequence corresponds to a type of spatial discretization.<br>
5147  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5148  * The overhead is due to selecting values into new instances of DataArrayDouble.
5149  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5150  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5151  *          not checked if \a mname == \c NULL).
5152  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5153  *          a field part is returned. 
5154  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5155  *          A field part can include sub-parts with several different spatial discretizations,
5156  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5157  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5158  *          This sequence is of the same length as \a types. 
5159  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5160  *          discretization. A profile name can be empty.
5161  *          Length of this and of nested sequences is the same as that of \a typesF.
5162  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5163  *          discretization. A localization name can be empty.
5164  *          Length of this and of nested sequences is the same as that of \a typesF.
5165  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5166  *          per each type of spatial discretization within one mesh entity type.
5167  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5168  *          Length of this and of nested sequences is the same as that of \a typesF.
5169  *  \throw If no field is lying on \a mname.
5170  */
5171 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(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
5172 {
5173   int meshId=0;
5174   if(!mname.empty())
5175     meshId=getMeshIdFromMeshName(mname);
5176   else
5177     if(_field_per_mesh.empty())
5178       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5179   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5180   int nbOfRet=ret0.size();
5181   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5182   for(int i=0;i<nbOfRet;i++)
5183     {
5184       const std::vector< std::pair<int,int> >& p=ret0[i];
5185       int nbOfRet1=p.size();
5186       ret[i].resize(nbOfRet1);
5187       for(int j=0;j<nbOfRet1;j++)
5188         {
5189           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5190           ret[i][j]=tmp;
5191         }
5192     }
5193   return ret;
5194 }
5195
5196 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5197 {
5198   return TYPE_STR;
5199 }
5200
5201 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5202 {
5203   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5204   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5205   ret->deepCpyLeavesFrom(*this);
5206   const DataArrayDouble *arr(_arr);
5207   if(arr)
5208     {
5209       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5210       ret->setArray(arr2);
5211     }
5212   return ret.retn();
5213 }
5214
5215 /*!
5216  * Returns a pointer to the underground DataArrayDouble instance and a
5217  * sequence describing parameters of a support of each part of \a this field. The
5218  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5219  * direct access to the field values. This method is intended for the field lying on one
5220  * mesh only.
5221  *  \param [in,out] entries - the sequence describing parameters of a support of each
5222  *         part of \a this field. Each item of this sequence consists of two parts. The
5223  *         first part describes a type of mesh entity and an id of discretization of a
5224  *         current field part. The second part describes a range of values [begin,end)
5225  *         within the returned array relating to the current field part.
5226  *  \return DataArrayDouble * - the pointer to the field values array.
5227  *  \throw If the number of underlying meshes is not equal to 1.
5228  *  \throw If no field values are available.
5229  *  \sa getUndergroundDataArray()
5230  */
5231 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5232 {
5233   if(_field_per_mesh.size()!=1)
5234     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5235   if(_field_per_mesh[0]==0)
5236     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5237   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5238   return getUndergroundDataArrayTemplate();
5239 }
5240
5241 /*!
5242  * Returns a pointer to the underground DataArrayDouble instance and a
5243  * sequence describing parameters of a support of each part of \a this field. The
5244  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5245  * direct access to the field values. This method is intended for the field lying on one
5246  * mesh only.
5247  *  \param [in,out] entries - the sequence describing parameters of a support of each
5248  *         part of \a this field. Each item of this sequence consists of two parts. The
5249  *         first part describes a type of mesh entity and an id of discretization of a
5250  *         current field part. The second part describes a range of values [begin,end)
5251  *         within the returned array relating to the current field part.
5252  *  \return DataArrayDouble * - the pointer to the field values array.
5253  *  \throw If the number of underlying meshes is not equal to 1.
5254  *  \throw If no field values are available.
5255  *  \sa getUndergroundDataArray()
5256  */
5257 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5258 {
5259   return getUndergroundDataArrayDoubleExt(entries);
5260 }
5261
5262 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5263 {
5264   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5265   arr->setInfoAndChangeNbOfCompo(infos);
5266 }
5267
5268 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5269 {
5270 }
5271
5272 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5273 {
5274   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5275   ret->deepCpyLeavesFrom(*this);
5276   return ret.retn();
5277 }
5278
5279 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5280 {
5281   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5282   if((const DataArrayDouble *)_arr)
5283     ret->_arr=_arr->deepCopy();
5284   return ret.retn();
5285 }
5286
5287 //= MEDFileIntField1TSWithoutSDA
5288
5289 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5290 {
5291   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5292 }
5293
5294 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5295 {
5296 }
5297
5298 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5299                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5300 {
5301   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5302   arr->setInfoAndChangeNbOfCompo(infos);
5303 }
5304
5305 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5306 {
5307   return TYPE_STR;
5308 }
5309
5310 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5311 {
5312   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5313   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5314   ret->deepCpyLeavesFrom(*this);
5315   const DataArrayInt *arr(_arr);
5316   if(arr)
5317     {
5318       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5319       ret->setArray(arr2);
5320     }
5321   return ret.retn();
5322 }
5323
5324 /*!
5325  * Returns a pointer to the underground DataArrayInt instance and a
5326  * sequence describing parameters of a support of each part of \a this field. The
5327  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5328  * direct access to the field values. This method is intended for the field lying on one
5329  * mesh only.
5330  *  \param [in,out] entries - the sequence describing parameters of a support of each
5331  *         part of \a this field. Each item of this sequence consists of two parts. The
5332  *         first part describes a type of mesh entity and an id of discretization of a
5333  *         current field part. The second part describes a range of values [begin,end)
5334  *         within the returned array relating to the current field part.
5335  *  \return DataArrayInt * - the pointer to the field values array.
5336  *  \throw If the number of underlying meshes is not equal to 1.
5337  *  \throw If no field values are available.
5338  *  \sa getUndergroundDataArray()
5339  */
5340 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5341 {
5342   return getUndergroundDataArrayIntExt(entries);
5343 }
5344
5345 /*!
5346  * Returns a pointer to the underground DataArrayInt instance and a
5347  * sequence describing parameters of a support of each part of \a this field. The
5348  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5349  * direct access to the field values. This method is intended for the field lying on one
5350  * mesh only.
5351  *  \param [in,out] entries - the sequence describing parameters of a support of each
5352  *         part of \a this field. Each item of this sequence consists of two parts. The
5353  *         first part describes a type of mesh entity and an id of discretization of a
5354  *         current field part. The second part describes a range of values [begin,end)
5355  *         within the returned array relating to the current field part.
5356  *  \return DataArrayInt * - the pointer to the field values array.
5357  *  \throw If the number of underlying meshes is not equal to 1.
5358  *  \throw If no field values are available.
5359  *  \sa getUndergroundDataArray()
5360  */
5361 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5362 {
5363   if(_field_per_mesh.size()!=1)
5364     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5365   if(_field_per_mesh[0]==0)
5366     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5367   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5368   return getUndergroundDataArrayTemplate();
5369 }
5370
5371 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5372 {
5373   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5374   ret->deepCpyLeavesFrom(*this);
5375   return ret.retn();
5376 }
5377
5378 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5379 {
5380   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5381   if((const DataArrayInt *)_arr)
5382     ret->_arr=_arr->deepCopy();
5383   return ret.retn();
5384 }
5385
5386 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5387 {
5388 }
5389
5390 //= MEDFileAnyTypeField1TS
5391
5392 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5393 {
5394   med_field_type typcha;
5395   //
5396   std::vector<std::string> infos;
5397   std::string dtunit,fieldName;
5398   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5399   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5400   switch(typcha)
5401   {
5402     case MED_FLOAT64:
5403       {
5404         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5405         break;
5406       }
5407     case MED_INT32:
5408       {
5409         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5410         break;
5411       }
5412     default:
5413       {
5414         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5415         throw INTERP_KERNEL::Exception(oss.str());
5416       }
5417   }
5418   ret->setDtUnit(dtunit.c_str());
5419   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5420   //
5421   med_int numdt,numit;
5422   med_float dt;
5423   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5424   ret->setTime(numdt,numit,dt);
5425   ret->_csit=1;
5426   if(loadAll)
5427     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5428   else
5429     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5430   return ret.retn();
5431 }
5432
5433 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5434 try:MEDFileFieldGlobsReal(fid)
5435 {
5436   _content=BuildContentFrom(fid,loadAll,ms);
5437   loadGlobals(fid);
5438 }
5439 catch(INTERP_KERNEL::Exception& e)
5440 {
5441     throw e;
5442 }
5443
5444 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5445 {
5446   med_field_type typcha;
5447   std::vector<std::string> infos;
5448   std::string dtunit;
5449   int iii=-1;
5450   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5451   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5452   switch(typcha)
5453   {
5454     case MED_FLOAT64:
5455       {
5456         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5457         break;
5458       }
5459     case MED_INT32:
5460       {
5461         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5462         break;
5463       }
5464     default:
5465       {
5466         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5467         throw INTERP_KERNEL::Exception(oss.str());
5468       }
5469   }
5470   ret->setDtUnit(dtunit.c_str());
5471   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5472   //
5473   if(nbSteps<1)
5474     {
5475       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5476       throw INTERP_KERNEL::Exception(oss.str());
5477     }
5478   //
5479   med_int numdt,numit;
5480   med_float dt;
5481   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5482   ret->setTime(numdt,numit,dt);
5483   ret->_csit=1;
5484   if(loadAll)
5485     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5486   else
5487     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5488   return ret.retn();
5489 }
5490
5491 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5492 try:MEDFileFieldGlobsReal(fid)
5493 {
5494   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5495   loadGlobals(fid);
5496 }
5497 catch(INTERP_KERNEL::Exception& e)
5498 {
5499     throw e;
5500 }
5501
5502 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5503 {
5504   if(!c)
5505     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5506   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5507     {
5508       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5509       ret->_content=c; c->incrRef();
5510       return ret.retn();
5511     }
5512   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5513     {
5514       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5515       ret->_content=c; c->incrRef();
5516       return ret.retn();
5517     }
5518   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5519 }
5520
5521 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5522 {
5523   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5524   ret->setFileName(FileNameFromFID(fid));
5525   return ret;
5526 }
5527
5528 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5529 {
5530   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5531   return New(fid,loadAll);
5532 }
5533
5534 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5535 {
5536   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5537   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5538   ret->loadGlobals(fid);
5539   return ret.retn();
5540 }
5541
5542 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5543 {
5544   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5545   return New(fid,fieldName,loadAll);
5546 }
5547
5548 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5549 {
5550   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5551   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5552   ret->loadGlobals(fid);
5553   return ret.retn();
5554 }
5555
5556 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5557 {
5558   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5559   return New(fid,fieldName,iteration,order,loadAll);
5560 }
5561
5562 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5563 {
5564   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5565   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5566   ret->loadGlobals(fid);
5567   return ret.retn();
5568 }
5569
5570 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5571 {
5572   med_field_type typcha;
5573   std::vector<std::string> infos;
5574   std::string dtunit;
5575   int iii(-1);
5576   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5577   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5578   switch(typcha)
5579   {
5580     case MED_FLOAT64:
5581       {
5582         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5583         break;
5584       }
5585     case MED_INT32:
5586       {
5587         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5588         break;
5589       }
5590     default:
5591       {
5592         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5593         throw INTERP_KERNEL::Exception(oss.str());
5594       }
5595   }
5596   ret->setDtUnit(dtunit.c_str());
5597   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5598   //
5599   bool found=false;
5600   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5601   for(int i=0;i<nbOfStep2 && !found;i++)
5602     {
5603       med_int numdt,numit;
5604       med_float dt;
5605       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5606       if(numdt==iteration && numit==order)
5607         {
5608           found=true;
5609           ret->_csit=i+1;
5610         }
5611       else
5612         dtits[i]=std::pair<int,int>(numdt,numit);
5613     }
5614   if(!found)
5615     {
5616       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5617       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5618         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5619       throw INTERP_KERNEL::Exception(oss.str());
5620     }
5621   if(loadAll)
5622     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5623   else
5624     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5625   return ret.retn();
5626 }
5627
5628 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5629 try:MEDFileFieldGlobsReal(fid)
5630 {
5631   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5632   loadGlobals(fid);
5633 }
5634 catch(INTERP_KERNEL::Exception& e)
5635 {
5636     throw e;
5637 }
5638
5639 /*!
5640  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5641  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5642  *
5643  * \warning this is a shallow copy constructor
5644  */
5645 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5646 {
5647   if(!shallowCopyOfContent)
5648     {
5649       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5650       otherPtr->incrRef();
5651       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5652     }
5653   else
5654     {
5655       _content=other.shallowCpy();
5656     }
5657 }
5658
5659 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5660 {
5661   if(checkFieldId)
5662     {
5663       int nbFields=MEDnField(fid);
5664       if(fieldIdCFormat>=nbFields)
5665         {
5666           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5667           throw INTERP_KERNEL::Exception(oss.str());
5668         }
5669     }
5670   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5671   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5672   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5673   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5674   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5675   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5676   med_bool localMesh;
5677   int nbOfStep;
5678   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5679   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5680   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5681   infos.clear(); infos.resize(ncomp);
5682   for(int j=0;j<ncomp;j++)
5683     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5684   return nbOfStep;
5685 }
5686
5687 /*!
5688  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5689  * 
5690  * \param [out]
5691  * \return in case of success the number of time steps available for the field with name \a fieldName.
5692  */
5693 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5694 {
5695   int nbFields=MEDnField(fid);
5696   bool found=false;
5697   std::vector<std::string> fns(nbFields);
5698   int nbOfStep2(-1);
5699   for(int i=0;i<nbFields && !found;i++)
5700     {
5701       std::string tmp;
5702       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5703       fns[i]=tmp;
5704       found=(tmp==fieldName);
5705       if(found)
5706         posCFormat=i;
5707     }
5708   if(!found)
5709     {
5710       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5711       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5712         oss << "\"" << *it << "\" ";
5713       throw INTERP_KERNEL::Exception(oss.str());
5714     }
5715   return nbOfStep2;
5716 }
5717
5718 /*!
5719  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5720  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5721  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5722  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5723  * to keep a valid instance.
5724  * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5725  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5726  * If \b newPflName already exists and that \b forceRenameOnGlob is false (the default) an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newPflName.
5727  *
5728  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5729  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5730  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5731  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5732  * \param [in] newLocName is the new localization name.
5733  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
5734  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5735  */
5736 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5737 {
5738   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5739   std::string oldPflName=disc->getProfile();
5740   std::vector<std::string> vv=getPflsReallyUsedMulti();
5741   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5742   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5743     {
5744       disc->setProfile(newPflName);
5745       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5746       pfl->setName(newPflName);
5747     }
5748   else
5749     {
5750       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5751       throw INTERP_KERNEL::Exception(oss.str());
5752     }
5753 }
5754
5755 /*!
5756  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5757  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5758  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5759  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5760  * to keep a valid instance.
5761  * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5762  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5763  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5764  * If \b newLocName already exists an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newLocName.
5765  *
5766  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5767  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5768  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5769  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5770  * \param [in] newLocName is the new localization name.
5771  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
5772  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5773  */
5774 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5775 {
5776   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5777   std::string oldLocName=disc->getLocalization();
5778   std::vector<std::string> vv=getLocsReallyUsedMulti();
5779   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5780   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5781     {
5782       disc->setLocalization(newLocName);
5783       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5784       loc.setName(newLocName);
5785     }
5786   else
5787     {
5788       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5789       throw INTERP_KERNEL::Exception(oss.str());
5790     }
5791 }
5792
5793 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5794 {
5795   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5796   if(!ret)
5797     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5798   return ret;
5799 }
5800
5801 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5802 {
5803   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5804   if(!ret)
5805     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5806   return ret;
5807 }
5808
5809 /*!
5810  * This method alloc the arrays and load potentially huge arrays contained in this field.
5811  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5812  * This method can be also called to refresh or reinit values from a file.
5813  * 
5814  * \throw If the fileName is not set or points to a non readable MED file.
5815  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5816  */
5817 void MEDFileAnyTypeField1TS::loadArrays()
5818 {
5819   if(getFileName().empty())
5820     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5821   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5822   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5823 }
5824
5825 /*!
5826  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5827  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5828  * this method does not throw if \a this does not come from file read.
5829  * 
5830  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5831  */
5832 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5833 {
5834   if(!getFileName().empty())
5835     {
5836       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5837       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5838     }
5839 }
5840
5841 /*!
5842  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5843  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5844  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5845  * 
5846  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5847  */
5848 void MEDFileAnyTypeField1TS::unloadArrays()
5849 {
5850   contentNotNullBase()->unloadArrays();
5851 }
5852
5853 /*!
5854  * 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.
5855  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5856  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5857  * 
5858  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5859  */
5860 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5861 {
5862   if(!getFileName().empty())
5863     contentNotNullBase()->unloadArrays();
5864 }
5865
5866 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5867 {
5868   int nbComp(getNumberOfComponents());
5869   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5870   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5871   for(int i=0;i<nbComp;i++)
5872     {
5873       std::string info=getInfo()[i];
5874       std::string c,u;
5875       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5876       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5877       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5878     }
5879   if(getName().empty())
5880     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5881   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5882   writeGlobals(fid,*this);
5883   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5884 }
5885
5886 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5887 {
5888   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5889 }
5890
5891 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5892 {
5893   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5894   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5895   return ret;
5896 }
5897
5898 /*!
5899  * Returns a string describing \a this field. This string is outputted 
5900  * by \c print Python command.
5901  */
5902 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5903 {
5904   std::ostringstream oss;
5905   contentNotNullBase()->simpleRepr(0,oss,-1);
5906   simpleReprGlobs(oss);
5907   return oss.str();
5908 }
5909
5910 /*!
5911  * This method returns all profiles whose name is non empty used.
5912  * \b WARNING If profile is used several times it will be reported \b only \b once.
5913  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5914  */
5915 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5916 {
5917   return contentNotNullBase()->getPflsReallyUsed2();
5918 }
5919
5920 /*!
5921  * This method returns all localizations whose name is non empty used.
5922  * \b WARNING If localization is used several times it will be reported \b only \b once.
5923  */
5924 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5925 {
5926   return contentNotNullBase()->getLocsReallyUsed2();
5927 }
5928
5929 /*!
5930  * This method returns all profiles whose name is non empty used.
5931  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5932  */
5933 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5934 {
5935   return contentNotNullBase()->getPflsReallyUsedMulti2();
5936 }
5937
5938 /*!
5939  * This method returns all localizations whose name is non empty used.
5940  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5941  */
5942 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5943 {
5944   return contentNotNullBase()->getLocsReallyUsedMulti2();
5945 }
5946
5947 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5948 {
5949   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5950 }
5951
5952 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5953 {
5954   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5955 }
5956
5957 int MEDFileAnyTypeField1TS::getDimension() const
5958 {
5959   return contentNotNullBase()->getDimension();
5960 }
5961
5962 int MEDFileAnyTypeField1TS::getIteration() const
5963 {
5964   return contentNotNullBase()->getIteration();
5965 }
5966
5967 int MEDFileAnyTypeField1TS::getOrder() const
5968 {
5969   return contentNotNullBase()->getOrder();
5970 }
5971
5972 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5973 {
5974   return contentNotNullBase()->getTime(iteration,order);
5975 }
5976
5977 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5978 {
5979   contentNotNullBase()->setTime(iteration,order,val);
5980 }
5981
5982 std::string MEDFileAnyTypeField1TS::getName() const
5983 {
5984   return contentNotNullBase()->getName();
5985 }
5986
5987 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5988 {
5989   contentNotNullBase()->setName(name);
5990 }
5991
5992 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5993 {
5994   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5995 }
5996
5997 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5998 {
5999   return contentNotNullBase()->getDtUnit();
6000 }
6001
6002 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6003 {
6004   contentNotNullBase()->setDtUnit(dtUnit);
6005 }
6006
6007 std::string MEDFileAnyTypeField1TS::getMeshName() const
6008 {
6009   return contentNotNullBase()->getMeshName();
6010 }
6011
6012 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6013 {
6014   contentNotNullBase()->setMeshName(newMeshName);
6015 }
6016
6017 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6018 {
6019   return contentNotNullBase()->changeMeshNames(modifTab);
6020 }
6021
6022 int MEDFileAnyTypeField1TS::getMeshIteration() const
6023 {
6024   return contentNotNullBase()->getMeshIteration();
6025 }
6026
6027 int MEDFileAnyTypeField1TS::getMeshOrder() const
6028 {
6029   return contentNotNullBase()->getMeshOrder();
6030 }
6031
6032 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6033 {
6034   return contentNotNullBase()->getNumberOfComponents();
6035 }
6036
6037 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6038 {
6039   return contentNotNullBase()->isDealingTS(iteration,order);
6040 }
6041
6042 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6043 {
6044   return contentNotNullBase()->getDtIt();
6045 }
6046
6047 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6048 {
6049   contentNotNullBase()->fillIteration(p);
6050 }
6051
6052 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6053 {
6054   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6055 }
6056
6057 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6058 {
6059   contentNotNullBase()->setInfo(infos);
6060 }
6061
6062 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6063 {
6064   return contentNotNullBase()->getInfo();
6065 }
6066 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6067 {
6068   return contentNotNullBase()->getInfo();
6069 }
6070
6071 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6072 {
6073   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6074 }
6075
6076 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6077 {
6078   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6079 }
6080
6081 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6082 {
6083   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6084 }
6085
6086 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6087 {
6088   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6089 }
6090
6091 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6092 {
6093   return contentNotNullBase()->getTypesOfFieldAvailable();
6094 }
6095
6096 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6097                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6098 {
6099   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6100 }
6101
6102 /*!
6103  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6104  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6105  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6106  */
6107 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6108 {
6109   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6110   if(!content)
6111     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6112   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6113   std::size_t sz(contentsSplit.size());
6114   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6115   for(std::size_t i=0;i<sz;i++)
6116     {
6117       ret[i]=shallowCpy();
6118       ret[i]->_content=contentsSplit[i];
6119     }
6120   return ret;
6121 }
6122
6123 /*!
6124  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6125  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6126  */
6127 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6128 {
6129   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6130   if(!content)
6131     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6132   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6133   std::size_t sz(contentsSplit.size());
6134   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6135   for(std::size_t i=0;i<sz;i++)
6136     {
6137       ret[i]=shallowCpy();
6138       ret[i]->_content=contentsSplit[i];
6139     }
6140   return ret;
6141 }
6142
6143 /*!
6144  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6145  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6146  */
6147 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6148 {
6149   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6150   if(!content)
6151     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6152   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6153   std::size_t sz(contentsSplit.size());
6154   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6155   for(std::size_t i=0;i<sz;i++)
6156     {
6157       ret[i]=shallowCpy();
6158       ret[i]->_content=contentsSplit[i];
6159     }
6160   return ret;
6161 }
6162
6163 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6164 {
6165   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6166   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6167     ret->_content=_content->deepCopy();
6168   ret->deepCpyGlobs(*this);
6169   return ret.retn();
6170 }
6171
6172 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6173 {
6174   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6175 }
6176
6177 //= MEDFileField1TS
6178
6179 /*!
6180  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6181  * the first field that has been read from a specified MED file.
6182  *  \param [in] fileName - the name of the MED file to read.
6183  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6184  *          is to delete this field using decrRef() as it is no more needed.
6185  *  \throw If reading the file fails.
6186  */
6187 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6188 {
6189   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6190   return New(fid,loadAll);
6191 }
6192
6193 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6194 {
6195   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6196   ret->contentNotNull();
6197   return ret.retn();
6198 }
6199
6200 /*!
6201  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6202  * a given field that has been read from a specified MED file.
6203  *  \param [in] fileName - the name of the MED file to read.
6204  *  \param [in] fieldName - the name of the field to read.
6205  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6206  *          is to delete this field using decrRef() as it is no more needed.
6207  *  \throw If reading the file fails.
6208  *  \throw If there is no field named \a fieldName in the file.
6209  */
6210 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6211 {
6212   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6213   return New(fid,fieldName,loadAll);
6214 }
6215
6216 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6217 {
6218   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6219   ret->contentNotNull();
6220   return ret.retn();
6221 }
6222
6223 /*!
6224  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6225  * a given field that has been read from a specified MED file.
6226  *  \param [in] fileName - the name of the MED file to read.
6227  *  \param [in] fieldName - the name of the field to read.
6228  *  \param [in] iteration - the iteration number of a required time step.
6229  *  \param [in] order - the iteration order number of required time step.
6230  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6231  *          is to delete this field using decrRef() as it is no more needed.
6232  *  \throw If reading the file fails.
6233  *  \throw If there is no field named \a fieldName in the file.
6234  *  \throw If the required time step is missing from the file.
6235  */
6236 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6237 {
6238   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6239   return New(fid,fieldName,iteration,order,loadAll);
6240 }
6241
6242 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6243 {
6244   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6245   ret->contentNotNull();
6246   return ret.retn();
6247 }
6248
6249 /*!
6250  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6251  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6252  *
6253  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6254  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6255  * \warning this is a shallow copy constructor
6256  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6257  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6258  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6259  *          is to delete this field using decrRef() as it is no more needed.
6260  */
6261 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6262 {
6263   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6264   ret->contentNotNull();
6265   return ret.retn();
6266 }
6267
6268 /*!
6269  * Returns a new empty instance of MEDFileField1TS.
6270  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6271  *          is to delete this field using decrRef() as it is no more needed.
6272  */
6273 MEDFileField1TS *MEDFileField1TS::New()
6274 {
6275   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6276   ret->contentNotNull();
6277   return ret.retn();
6278 }
6279
6280 /*!
6281  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6282  * following the given input policy.
6283  *
6284  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6285  *                            By default (true) the globals are deeply copied.
6286  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6287  */
6288 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6289 {
6290   MCAuto<MEDFileIntField1TS> ret;
6291   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6292   if(content)
6293     {
6294       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6295       if(!contc)
6296         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6297       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6298       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6299     }
6300   else
6301     ret=MEDFileIntField1TS::New();
6302   if(isDeepCpyGlobs)
6303     ret->deepCpyGlobs(*this);
6304   else
6305     ret->shallowCpyGlobs(*this);
6306   return ret.retn();
6307 }
6308
6309 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6310 {
6311   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6312   if(!pt)
6313     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6314   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6315   if(!ret)
6316     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6317   return ret;
6318 }
6319
6320 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6321 {
6322   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6323   if(!pt)
6324     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6325   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6326   if(!ret)
6327     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6328   return ret;
6329 }
6330
6331 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6332 {
6333   if(!f)
6334     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6335   if(arr.isNull())
6336     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6337   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6338   if(!arrOutC)
6339     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6340   f->setArray(arrOutC);
6341 }
6342
6343 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6344 {
6345   if(arr.isNull())
6346     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6347   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6348   if(!arrOutC)
6349     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6350   arrOutC->incrRef();
6351   return arrOutC;
6352 }
6353
6354 /*!
6355  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6356  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6357  *
6358  * \return A new object that the caller is responsible to deallocate.
6359  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6360  */
6361 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6362 {
6363   if(!mm)
6364     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6365   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6366   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6367   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6368     {
6369       if((*it0)!=ON_NODES)
6370         {
6371           std::vector<int> levs;
6372           getNonEmptyLevels(mm->getName(),levs);
6373           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6374             {
6375               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6376               if(it2!=extractDef.end())
6377                 {
6378                   MCAuto<DataArrayInt> t((*it2).second);
6379                   if(t.isNull())
6380                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6381                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6382                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6383                   ret->setFieldNoProfileSBT(fOut);
6384                 }
6385             }
6386         }
6387       else
6388         {
6389           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6390           if(it2==extractDef.end())
6391             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6392           MCAuto<DataArrayInt> t((*it2).second);
6393           if(t.isNull())
6394             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6395           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6396           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6397           DataArrayDouble *arr(f->getArray());
6398           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6399           fOut->setArray(newArr);
6400           ret->setFieldNoProfileSBT(fOut);
6401         }
6402     }
6403   return ret.retn();
6404 }
6405
6406 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6407 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6408 {
6409 }
6410 catch(INTERP_KERNEL::Exception& e)
6411 { throw e; }
6412
6413 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6414 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6415 {
6416 }
6417 catch(INTERP_KERNEL::Exception& e)
6418 { throw e; }
6419
6420 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6421 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6422 {
6423 }
6424 catch(INTERP_KERNEL::Exception& e)
6425 { throw e; }
6426
6427 /*!
6428  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6429  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6430  *
6431  * \warning this is a shallow copy constructor
6432  */
6433 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6434 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6435 {
6436 }
6437 catch(INTERP_KERNEL::Exception& e)
6438 { throw e; }
6439
6440 MEDFileField1TS::MEDFileField1TS()
6441 {
6442   _content=new MEDFileField1TSWithoutSDA;
6443 }
6444
6445 /*!
6446  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6447  * method should be called (getFieldOnMeshAtLevel for example).
6448  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6449  *
6450  * \param [in] mesh - the mesh the field is lying on
6451  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6452  *          caller is to delete this field using decrRef() as it is no more needed. 
6453  */
6454 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6455 {
6456   MCAuto<DataArray> arrOut;
6457   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6458   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6459   return ret.retn();
6460 }
6461
6462 /*!
6463  * Returns a new MEDCouplingFieldDouble of a given type lying on
6464  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6465  * has not been constructed via file reading, an exception is thrown.
6466  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6467  *  \param [in] type - a spatial discretization of interest.
6468  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6469  *  \param [in] renumPol - specifies how to permute values of the result field according to
6470  *          the optional numbers of cells and nodes, if any. The valid values are
6471  *          - 0 - do not permute.
6472  *          - 1 - permute cells.
6473  *          - 2 - permute nodes.
6474  *          - 3 - permute cells and nodes.
6475  *
6476  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6477  *          caller is to delete this field using decrRef() as it is no more needed. 
6478  *  \throw If \a this field has not been constructed via file reading.
6479  *  \throw If the MED file is not readable.
6480  *  \throw If there is no mesh in the MED file.
6481  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6482  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6483  *  \sa getFieldOnMeshAtLevel()
6484  */
6485 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6486 {
6487   if(getFileName().empty())
6488     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6489   MCAuto<DataArray> arrOut;
6490   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6491   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6492   return ret.retn();
6493 }
6494
6495 /*!
6496  * Returns a new MEDCouplingFieldDouble of a given type lying on
6497  * the top level cells of the first mesh in MED file. If \a this field 
6498  * has not been constructed via file reading, an exception is thrown.
6499  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6500  *  \param [in] type - a spatial discretization of interest.
6501  *  \param [in] renumPol - specifies how to permute values of the result field according to
6502  *          the optional numbers of cells and nodes, if any. The valid values are
6503  *          - 0 - do not permute.
6504  *          - 1 - permute cells.
6505  *          - 2 - permute nodes.
6506  *          - 3 - permute cells and nodes.
6507  *
6508  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6509  *          caller is to delete this field using decrRef() as it is no more needed. 
6510  *  \throw If \a this field has not been constructed via file reading.
6511  *  \throw If the MED file is not readable.
6512  *  \throw If there is no mesh in the MED file.
6513  *  \throw If no field values of the given \a type.
6514  *  \throw If no field values lying on the top level support.
6515  *  \sa getFieldAtLevel()
6516  */
6517 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6518 {
6519   if(getFileName().empty())
6520     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6521   MCAuto<DataArray> arrOut;
6522   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6523   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6524   return ret.retn();
6525 }
6526
6527 /*!
6528  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6529  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6530  *  \param [in] type - a spatial discretization of the new field.
6531  *  \param [in] mesh - the supporting mesh.
6532  *  \param [in] renumPol - specifies how to permute values of the result field according to
6533  *          the optional numbers of cells and nodes, if any. The valid values are
6534  *          - 0 - do not permute.
6535  *          - 1 - permute cells.
6536  *          - 2 - permute nodes.
6537  *          - 3 - permute cells and nodes.
6538  *
6539  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6540  *          caller is to delete this field using decrRef() as it is no more needed. 
6541  *  \throw If no field of \a this is lying on \a mesh.
6542  *  \throw If the mesh is empty.
6543  *  \throw If no field values of the given \a type are available.
6544  *  \sa getFieldAtLevel()
6545  *  \sa getFieldOnMeshAtLevel() 
6546  */
6547 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6548 {
6549   MCAuto<DataArray> arrOut;
6550   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6551   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6552   return ret.retn();
6553 }
6554
6555 /*!
6556  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6557  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6558  *  \param [in] type - a spatial discretization of interest.
6559  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6560  *  \param [in] mesh - the supporting mesh.
6561  *  \param [in] renumPol - specifies how to permute values of the result field according to
6562  *          the optional numbers of cells and nodes, if any. The valid values are
6563  *          - 0 - do not permute.
6564  *          - 1 - permute cells.
6565  *          - 2 - permute nodes.
6566  *          - 3 - permute cells and nodes.
6567  *
6568  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6569  *          caller is to delete this field using decrRef() as it is no more needed. 
6570  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6571  *  \throw If no field of \a this is lying on \a mesh.
6572  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6573  *  \sa getFieldAtLevel()
6574  *  \sa getFieldOnMeshAtLevel() 
6575  */
6576 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6577 {
6578   MCAuto<DataArray> arrOut;
6579   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6580   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6581   return ret.retn();
6582 }
6583
6584 /*!
6585  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6586  * This method is called "Old" because in MED3 norm a field has only one meshName
6587  * attached, so this method is for readers of MED2 files. If \a this field 
6588  * has not been constructed via file reading, an exception is thrown.
6589  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6590  *  \param [in] type - a spatial discretization of interest.
6591  *  \param [in] mName - a name of the supporting mesh.
6592  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6593  *  \param [in] renumPol - specifies how to permute values of the result field according to
6594  *          the optional numbers of cells and nodes, if any. The valid values are
6595  *          - 0 - do not permute.
6596  *          - 1 - permute cells.
6597  *          - 2 - permute nodes.
6598  *          - 3 - permute cells and nodes.
6599  *
6600  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6601  *          caller is to delete this field using decrRef() as it is no more needed. 
6602  *  \throw If the MED file is not readable.
6603  *  \throw If there is no mesh named \a mName in the MED file.
6604  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6605  *  \throw If \a this field has not been constructed via file reading.
6606  *  \throw If no field of \a this is lying on the mesh named \a mName.
6607  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6608  *  \sa getFieldAtLevel()
6609  */
6610 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6611 {
6612   if(getFileName().empty())
6613     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6614   MCAuto<DataArray> arrOut;
6615   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6616   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6617   return ret.retn();
6618 }
6619
6620 /*!
6621  * Returns values and a profile of the field of a given type lying on a given support.
6622  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6623  *  \param [in] type - a spatial discretization of the field.
6624  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6625  *  \param [in] mesh - the supporting mesh.
6626  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6627  *          field of interest lies on. If the field lies on all entities of the given
6628  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6629  *          using decrRef() as it is no more needed.  
6630  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6631  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6632  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6633  *  \throw If no field of \a this is lying on \a mesh.
6634  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6635  */
6636 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6637 {
6638   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6639   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6640 }
6641
6642 /*!
6643  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6644  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6645  * "Sort By Type"), if not, an exception is thrown. 
6646  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6647  *  \param [in] field - the field to add to \a this.
6648  *  \throw If the name of \a field is empty.
6649  *  \throw If the data array of \a field is not set.
6650  *  \throw If the data array is already allocated but has different number of components
6651  *         than \a field.
6652  *  \throw If the underlying mesh of \a field has no name.
6653  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6654  */
6655 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6656 {
6657   setFileName("");
6658   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6659 }
6660
6661 /*!
6662  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6663  * can be an aggregation of several MEDCouplingFieldDouble instances.
6664  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6665  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6666  * and \a profile.
6667  *
6668  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6669  * A new profile is added only if no equal profile is missing.
6670  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6671  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6672  *  \param [in] mesh - the supporting mesh of \a field.
6673  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6674  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6675  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6676  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6677  *  \throw If the data array of \a field is not set.
6678  *  \throw If the data array of \a this is already allocated but has different number of
6679  *         components than \a field.
6680  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6681  *  \sa setFieldNoProfileSBT()
6682  */
6683 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6684 {
6685   setFileName("");
6686   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6687 }
6688
6689 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6690 {
6691   return new MEDFileField1TS(*this);
6692 }
6693
6694 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6695 {
6696   return contentNotNull()->getUndergroundDataArrayTemplate();
6697 }
6698
6699 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6700 {
6701   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6702 }
6703
6704 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6705                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6706 {
6707   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6708 }
6709
6710 //= MEDFileIntField1TS
6711
6712 MEDFileIntField1TS *MEDFileIntField1TS::New()
6713 {
6714   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6715   ret->contentNotNull();
6716   return ret.retn();
6717 }
6718
6719 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6720 {
6721   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6722   return MEDFileIntField1TS::New(fid,loadAll);
6723 }
6724
6725 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6726 {
6727   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6728   ret->contentNotNull();
6729   return ret.retn();
6730 }
6731
6732 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6733 {
6734   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6735   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6736 }
6737
6738 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6739 {
6740   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6741   ret->contentNotNull();
6742   return ret.retn();
6743 }
6744
6745 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6746 {
6747   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6748   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6749 }
6750
6751 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6752 {
6753   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6754   ret->contentNotNull();
6755   return ret.retn();
6756 }
6757
6758 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6759 {
6760   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6761   ret->contentNotNull();
6762   return ret.retn();
6763 }
6764
6765 MEDFileIntField1TS::MEDFileIntField1TS()
6766 {
6767   _content=new MEDFileIntField1TSWithoutSDA;
6768 }
6769
6770 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6771 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6772 {
6773 }
6774 catch(INTERP_KERNEL::Exception& e)
6775 { throw e; }
6776
6777 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6778 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6779 {
6780 }
6781 catch(INTERP_KERNEL::Exception& e)
6782 { throw e; }
6783
6784 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6785 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6786 {
6787 }
6788 catch(INTERP_KERNEL::Exception& e)
6789 { throw e; }
6790
6791 /*!
6792  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6793  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6794  *
6795  * \warning this is a shallow copy constructor
6796  */
6797 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6798 {
6799 }
6800
6801 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6802 {
6803   return new MEDFileIntField1TS(*this);
6804 }
6805
6806 /*!
6807  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6808  * following the given input policy.
6809  *
6810  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6811  *                            By default (true) the globals are deeply copied.
6812  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6813  */
6814 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6815 {
6816   MCAuto<MEDFileField1TS> ret;
6817   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6818   if(content)
6819     {
6820       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6821       if(!contc)
6822         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6823       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6824       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6825     }
6826   else
6827     ret=MEDFileField1TS::New();
6828   if(isDeepCpyGlobs)
6829     ret->deepCpyGlobs(*this);
6830   else
6831     ret->shallowCpyGlobs(*this);
6832   return ret.retn();
6833 }
6834
6835 /*!
6836  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6837  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6838  * "Sort By Type"), if not, an exception is thrown. 
6839  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6840  *  \param [in] field - the field to add to \a this.
6841  *  \throw If the name of \a field is empty.
6842  *  \throw If the data array of \a field is not set.
6843  *  \throw If the data array is already allocated but has different number of components
6844  *         than \a field.
6845  *  \throw If the underlying mesh of \a field has no name.
6846  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6847  */
6848 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6849 {
6850   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6851   setFileName("");
6852   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6853 }
6854
6855 /*!
6856  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6857  * can be an aggregation of several MEDCouplingFieldDouble instances.
6858  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6859  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6860  * and \a profile.
6861  *
6862  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6863  * A new profile is added only if no equal profile is missing.
6864  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6865  *  \param [in] field - the field to add to \a this.
6866  *  \param [in] mesh - the supporting mesh of \a field.
6867  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6868  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6869  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6870  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6871  *  \throw If the data array of \a field is not set.
6872  *  \throw If the data array of \a this is already allocated but has different number of
6873  *         components than \a field.
6874  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6875  *  \sa setFieldNoProfileSBT()
6876  */
6877 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6878 {
6879   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6880   setFileName("");
6881   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6882 }
6883
6884 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6885 {
6886   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6887   if(!pt)
6888     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6889   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6890   if(!ret)
6891     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6892   return ret;
6893 }
6894
6895 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6896 {
6897   if(getFileName().empty())
6898     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6899   MCAuto<DataArray> arrOut;
6900   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6901   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6902   return ret2.retn();
6903 }
6904
6905 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6906 {
6907   if(arr.isNull())
6908     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6909   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6910   if(!arrC)
6911     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6912   arrC->incrRef();
6913   return arrC;
6914 }
6915
6916 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6917 {
6918   int t1,t2;
6919   double t0(f->getTime(t1,t2));
6920   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6921   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6922   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6923   ret->setTime(t0,t1,t2); ret->setArray(arr2);
6924   return ret.retn();
6925 }
6926
6927 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6928 {
6929   if(!f)
6930     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6931   int t1,t2;
6932   double t0(f->getTime(t1,t2));
6933   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6934   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6935   ret->setTime(t0,t1,t2);
6936   return ret;
6937 }
6938
6939 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6940 {
6941   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6942 }
6943
6944 /*!
6945  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6946  * method should be called (getFieldOnMeshAtLevel for example).
6947  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6948  *
6949  * \param [in] mesh - the mesh the field is lying on
6950  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6951  *          caller is to delete this field using decrRef() as it is no more needed. 
6952  */
6953 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6954 {
6955   MCAuto<DataArray> arrOut;
6956   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6957   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6958   return ret2.retn();
6959 }
6960
6961 /*!
6962  * Returns a new MEDCouplingFieldInt of a given type lying on
6963  * the top level cells of the first mesh in MED file. If \a this field 
6964  * has not been constructed via file reading, an exception is thrown.
6965  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6966  *  \param [in] type - a spatial discretization of interest.
6967  *  \param [in] renumPol - specifies how to permute values of the result field according to
6968  *          the optional numbers of cells and nodes, if any. The valid values are
6969  *          - 0 - do not permute.
6970  *          - 1 - permute cells.
6971  *          - 2 - permute nodes.
6972  *          - 3 - permute cells and nodes.
6973  *
6974  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
6975  *          caller is to delete this field using decrRef() as it is no more needed. 
6976  *  \throw If \a this field has not been constructed via file reading.
6977  *  \throw If the MED file is not readable.
6978  *  \throw If there is no mesh in the MED file.
6979  *  \throw If no field values of the given \a type.
6980  *  \throw If no field values lying on the top level support.
6981  *  \sa getFieldAtLevel()
6982  */
6983 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6984 {
6985   if(getFileName().empty())
6986     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6987   MCAuto<DataArray> arrOut;
6988   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6989   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6990   return ret2.retn();
6991 }
6992
6993 /*!
6994  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
6995  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6996  *  \param [in] type - a spatial discretization of the new field.
6997  *  \param [in] mesh - the supporting mesh.
6998  *  \param [in] renumPol - specifies how to permute values of the result field according to
6999  *          the optional numbers of cells and nodes, if any. The valid values are
7000  *          - 0 - do not permute.
7001  *          - 1 - permute cells.
7002  *          - 2 - permute nodes.
7003  *          - 3 - permute cells and nodes.
7004  *
7005  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7006  *          caller is to delete this field using decrRef() as it is no more needed. 
7007  *  \throw If no field of \a this is lying on \a mesh.
7008  *  \throw If the mesh is empty.
7009  *  \throw If no field values of the given \a type are available.
7010  *  \sa getFieldAtLevel()
7011  *  \sa getFieldOnMeshAtLevel() 
7012  */
7013 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7014 {
7015   MCAuto<DataArray> arrOut;
7016   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7017   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7018   return ret2.retn();
7019 }
7020
7021 /*!
7022  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7023  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7024  *  \param [in] type - a spatial discretization of interest.
7025  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7026  *  \param [in] mesh - the supporting mesh.
7027  *  \param [in] renumPol - specifies how to permute values of the result field according to
7028  *          the optional numbers of cells and nodes, if any. The valid values are
7029  *          - 0 - do not permute.
7030  *          - 1 - permute cells.
7031  *          - 2 - permute nodes.
7032  *          - 3 - permute cells and nodes.
7033  *
7034  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7035  *          caller is to delete this field using decrRef() as it is no more needed. 
7036  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7037  *  \throw If no field of \a this is lying on \a mesh.
7038  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7039  *  \sa getFieldAtLevel()
7040  *  \sa getFieldOnMeshAtLevel() 
7041  */
7042 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7043 {
7044   MCAuto<DataArray> arrOut;
7045   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7046   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7047   return ret2.retn();
7048 }
7049
7050 /*!
7051  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7052  * This method is called "Old" because in MED3 norm a field has only one meshName
7053  * attached, so this method is for readers of MED2 files. If \a this field 
7054  * has not been constructed via file reading, an exception is thrown.
7055  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7056  *  \param [in] type - a spatial discretization of interest.
7057  *  \param [in] mName - a name of the supporting mesh.
7058  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7059  *  \param [in] renumPol - specifies how to permute values of the result field according to
7060  *          the optional numbers of cells and nodes, if any. The valid values are
7061  *          - 0 - do not permute.
7062  *          - 1 - permute cells.
7063  *          - 2 - permute nodes.
7064  *          - 3 - permute cells and nodes.
7065  *
7066  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7067  *          caller is to delete this field using decrRef() as it is no more needed. 
7068  *  \throw If the MED file is not readable.
7069  *  \throw If there is no mesh named \a mName in the MED file.
7070  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7071  *  \throw If \a this field has not been constructed via file reading.
7072  *  \throw If no field of \a this is lying on the mesh named \a mName.
7073  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7074  *  \sa getFieldAtLevel()
7075  */
7076 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7077 {
7078   if(getFileName().empty())
7079     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7080   MCAuto<DataArray> arrOut;
7081   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7082   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7083   return ret2.retn();
7084 }
7085
7086 /*!
7087  * Returns values and a profile of the field of a given type lying on a given support.
7088  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7089  *  \param [in] type - a spatial discretization of the field.
7090  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7091  *  \param [in] mesh - the supporting mesh.
7092  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7093  *          field of interest lies on. If the field lies on all entities of the given
7094  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7095  *          using decrRef() as it is no more needed.  
7096  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7097  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7098  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7099  *  \throw If no field of \a this is lying on \a mesh.
7100  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7101  */
7102 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7103 {
7104   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7105   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7106 }
7107
7108 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7109 {
7110   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7111   if(!pt)
7112     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7113   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7114   if(!ret)
7115     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
7116   return ret;
7117 }
7118
7119 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7120 {
7121   return contentNotNull()->getUndergroundDataArrayTemplate();
7122 }
7123
7124 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7125
7126 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7127 {
7128 }
7129
7130 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7131 {
7132 }
7133
7134 /*!
7135  * \param [in] fieldId field id in C mode
7136  */
7137 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7138 {
7139   med_field_type typcha;
7140   std::string dtunitOut;
7141   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7142   setDtUnit(dtunitOut.c_str());
7143   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7144 }
7145
7146 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7147 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7148 {
7149   setDtUnit(dtunit.c_str());
7150   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7151 }
7152 catch(INTERP_KERNEL::Exception& e)
7153 {
7154     throw e;
7155 }
7156
7157 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7158 {
7159   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7160   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7161     ret+=(*it).capacity();
7162   return ret;
7163 }
7164
7165 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7166 {
7167   std::vector<const BigMemoryObject *> ret;
7168   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7169     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7170   return ret;
7171 }
7172
7173 /*!
7174  * 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
7175  * NULL.
7176  */
7177 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7178 {
7179   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7180   ret->setInfo(_infos);
7181   int sz=(int)_time_steps.size();
7182   for(const int *id=startIds;id!=endIds;id++)
7183     {
7184       if(*id>=0 && *id<sz)
7185         {
7186           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7187           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7188           if(tse)
7189             {
7190               tse->incrRef();
7191               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7192             }
7193           ret->pushBackTimeStep(tse2);
7194         }
7195       else
7196         {
7197           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7198           oss << " ! Should be in [0," << sz << ") !";
7199           throw INTERP_KERNEL::Exception(oss.str());
7200         }
7201     }
7202   if(ret->getNumberOfTS()>0)
7203     ret->synchronizeNameScope();
7204   ret->copyNameScope(*this);
7205   return ret.retn();
7206 }
7207
7208 /*!
7209  * 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
7210  * NULL.
7211  */
7212 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7213 {
7214   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7215   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7216   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7217   ret->setInfo(_infos);
7218   int sz=(int)_time_steps.size();
7219   int j=bg;
7220   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7221     {
7222       if(j>=0 && j<sz)
7223         {
7224           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7225           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7226           if(tse)
7227             {
7228               tse->incrRef();
7229               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7230             }
7231           ret->pushBackTimeStep(tse2);
7232         }
7233       else
7234         {
7235           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7236           oss << " ! Should be in [0," << sz << ") !";
7237           throw INTERP_KERNEL::Exception(oss.str());
7238         }
7239     }
7240   if(ret->getNumberOfTS()>0)
7241     ret->synchronizeNameScope();
7242   ret->copyNameScope(*this);
7243   return ret.retn();
7244 }
7245
7246 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7247 {
7248   int id=0;
7249   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7250   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7251     {
7252       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7253       if(!cur)
7254         continue;
7255       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7256       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7257         ids->pushBackSilent(id);
7258     }
7259   return buildFromTimeStepIds(ids->begin(),ids->end());
7260 }
7261
7262 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7263 {
7264   int id=0;
7265   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7266   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7267     {
7268       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7269       if(!cur)
7270         continue;
7271       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7272       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7273         ids->pushBackSilent(id);
7274     }
7275   return buildFromTimeStepIds(ids->begin(),ids->end());
7276 }
7277
7278 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7279 {
7280   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7281     {
7282       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7283       if(!cur)
7284         continue;
7285       if(cur->presenceOfMultiDiscPerGeoType())
7286         return true;
7287     }
7288   return false;
7289 }
7290
7291 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7292 {
7293   return _infos;
7294 }
7295
7296 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7297 {
7298   _infos=info;
7299 }
7300
7301 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7302 {
7303   int ret=0;
7304   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7305     {
7306       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7307       if(pt->isDealingTS(iteration,order))
7308         return ret;
7309     }
7310   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7311   std::vector< std::pair<int,int> > vp=getIterations();
7312   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7313     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7314   throw INTERP_KERNEL::Exception(oss.str());
7315 }
7316
7317 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7318 {
7319   return *_time_steps[getTimeStepPos(iteration,order)];
7320 }
7321
7322 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7323 {
7324   return *_time_steps[getTimeStepPos(iteration,order)];
7325 }
7326
7327 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7328 {
7329   if(_time_steps.empty())
7330     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7331   return _time_steps[0]->getMeshName();
7332 }
7333
7334 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7335 {
7336   std::string oldName(getMeshName());
7337   std::vector< std::pair<std::string,std::string> > v(1);
7338   v[0].first=oldName; v[0].second=newMeshName;
7339   changeMeshNames(v);
7340 }
7341
7342 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7343 {
7344   bool ret=false;
7345   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7346     {
7347       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7348       if(cur)
7349         ret=cur->changeMeshNames(modifTab) || ret;
7350     }
7351   return ret;
7352 }
7353
7354 /*!
7355  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7356  */
7357 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7358 {
7359   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7360 }
7361
7362 /*!
7363  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7364  */
7365 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7366 {
7367   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7368 }
7369
7370 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7371                                                                        MEDFileFieldGlobsReal& glob)
7372 {
7373   bool ret=false;
7374   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7375     {
7376       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7377       if(f1ts)
7378         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7379     }
7380   return ret;
7381 }
7382
7383 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7384 {
7385   std::string startLine(bkOffset,' ');
7386   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7387   if(fmtsId>=0)
7388     oss << " (" << fmtsId << ")";
7389   oss << " has the following name: \"" << _name << "\"." << std::endl;
7390   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7391   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7392     {
7393       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7394     }
7395   int i=0;
7396   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7397     {
7398       std::string chapter(17,'0'+i);
7399       oss << startLine << chapter << std::endl;
7400       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7401       if(cur)
7402         cur->simpleRepr(bkOffset+2,oss,i);
7403       else
7404         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7405       oss << startLine << chapter << std::endl;
7406     }
7407 }
7408
7409 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7410 {
7411   std::size_t sz=_time_steps.size();
7412   std::vector< std::pair<int,int> > ret(sz);
7413   ret1.resize(sz);
7414   for(std::size_t i=0;i<sz;i++)
7415     {
7416       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7417       if(f1ts)
7418         {
7419           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7420         }
7421       else
7422         {
7423           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7424           throw INTERP_KERNEL::Exception(oss.str());
7425         }
7426     }
7427   return ret;
7428 }
7429
7430 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7431 {
7432   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7433   if(!tse2)
7434     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7435   checkCoherencyOfType(tse2);
7436   if(_time_steps.empty())
7437     {
7438       setName(tse2->getName().c_str());
7439       setInfo(tse2->getInfo());
7440     }
7441   checkThatComponentsMatch(tse2->getInfo());
7442   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7443     setDtUnit(tse->getDtUnit());
7444   _time_steps.push_back(tse);
7445 }
7446
7447 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7448 {
7449   std::size_t nbOfCompo=_infos.size();
7450   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7451     {
7452       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7453       if(cur)
7454         {
7455           if((cur->getInfo()).size()!=nbOfCompo)
7456             {
7457               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7458               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7459               throw INTERP_KERNEL::Exception(oss.str());
7460             }
7461           cur->copyNameScope(*this);
7462         }
7463     }
7464 }
7465
7466 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7467 {
7468   _time_steps.resize(nbPdt);
7469   for(int i=0;i<nbPdt;i++)
7470     {
7471       std::vector< std::pair<int,int> > ts;
7472       med_int numdt=0,numo=0;
7473       med_int meshIt=0,meshOrder=0;
7474       med_float dt=0.0;
7475       MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7476       switch(fieldTyp)
7477       {
7478         case MED_FLOAT64:
7479           {
7480             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7481             break;
7482           }
7483         case MED_INT32:
7484           {
7485             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7486             break;
7487           }
7488         default:
7489           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7490       }
7491       if(loadAll)
7492         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7493       else
7494         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7495       synchronizeNameScope();
7496     }
7497 }
7498
7499 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7500 {
7501   if(_time_steps.empty())
7502     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7503   checkThatNbOfCompoOfTSMatchThis();
7504   std::vector<std::string> infos(getInfo());
7505   int nbComp=infos.size();
7506   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7507   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7508   for(int i=0;i<nbComp;i++)
7509     {
7510       std::string info=infos[i];
7511       std::string c,u;
7512       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7513       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7514       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7515     }
7516   if(_name.empty())
7517     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7518   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7519   int nbOfTS=_time_steps.size();
7520   for(int i=0;i<nbOfTS;i++)
7521     _time_steps[i]->writeLL(fid,opts,*this);
7522 }
7523
7524 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7525 {
7526   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7527     {
7528       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7529       if(elt)
7530         elt->loadBigArraysRecursively(fid,nasc);
7531     }
7532 }
7533
7534 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7535 {
7536   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7537     {
7538       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7539       if(elt)
7540         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7541     }
7542 }
7543
7544 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7545 {
7546   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7547     {
7548       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7549       if(elt)
7550         elt->unloadArrays();
7551     }
7552 }
7553
7554 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7555 {
7556   return _time_steps.size();
7557 }
7558
7559 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7560 {
7561   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7562   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7563     {
7564       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7565       if(tmp)
7566         newTS.push_back(*it);
7567     }
7568   _time_steps=newTS;
7569 }
7570
7571 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7572 {
7573   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7574   int maxId=(int)_time_steps.size();
7575   int ii=0;
7576   std::set<int> idsToDel;
7577   for(const int *id=startIds;id!=endIds;id++,ii++)
7578     {
7579       if(*id>=0 && *id<maxId)
7580         {
7581           idsToDel.insert(*id);
7582         }
7583       else
7584         {
7585           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7586           throw INTERP_KERNEL::Exception(oss.str());
7587         }
7588     }
7589   for(int iii=0;iii<maxId;iii++)
7590     if(idsToDel.find(iii)==idsToDel.end())
7591       newTS.push_back(_time_steps[iii]);
7592   _time_steps=newTS;
7593 }
7594
7595 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7596 {
7597   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7598   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7599   if(nbOfEntriesToKill==0)
7600     return ;
7601   std::size_t sz=_time_steps.size();
7602   std::vector<bool> b(sz,true);
7603   int j=bg;
7604   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7605     b[j]=false;
7606   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7607   for(std::size_t i=0;i<sz;i++)
7608     if(b[i])
7609       newTS.push_back(_time_steps[i]);
7610   _time_steps=newTS;
7611 }
7612
7613 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7614 {
7615   int ret=0;
7616   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7617   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7618     {
7619       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7620       if(tmp)
7621         {
7622           int it2,ord;
7623           tmp->getTime(it2,ord);
7624           if(it2==iteration && order==ord)
7625             return ret;
7626           else
7627             oss << "(" << it2 << ","  << ord << "), ";
7628         }
7629     }
7630   throw INTERP_KERNEL::Exception(oss.str());
7631 }
7632
7633 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7634 {
7635   int ret=0;
7636   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7637   oss.precision(15);
7638   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7639     {
7640       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7641       if(tmp)
7642         {
7643           int it2,ord;
7644           double ti=tmp->getTime(it2,ord);
7645           if(fabs(time-ti)<eps)
7646             return ret;
7647           else
7648             oss << ti << ", ";
7649         }
7650     }
7651   throw INTERP_KERNEL::Exception(oss.str());
7652 }
7653
7654 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7655 {
7656   int lgth=_time_steps.size();
7657   std::vector< std::pair<int,int> > ret(lgth);
7658   for(int i=0;i<lgth;i++)
7659     _time_steps[i]->fillIteration(ret[i]);
7660   return ret;
7661 }
7662
7663 /*!
7664  * 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'
7665  * This method returns two things.
7666  * - The absolute dimension of 'this' in first parameter. 
7667  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7668  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7669  *
7670  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7671  * Only these 3 discretizations will be taken into account here.
7672  *
7673  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7674  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7675  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7676  *
7677  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7678  * 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'.
7679  * 
7680  * Let's consider the typical following case :
7681  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7682  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7683  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7684  *   TETRA4 and SEG2
7685  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7686  *
7687  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7688  * 
7689  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7690  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7691  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7692  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7693  */
7694 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7695 {
7696   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7697 }
7698
7699 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7700 {
7701   if(pos<0 || pos>=(int)_time_steps.size())
7702     {
7703       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7704       throw INTERP_KERNEL::Exception(oss.str());
7705     }
7706   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7707   if(item==0)
7708     {
7709       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7710       oss << "\nTry to use following method eraseEmptyTS !";
7711       throw INTERP_KERNEL::Exception(oss.str());
7712     }
7713   return item;
7714 }
7715
7716 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7717 {
7718   if(pos<0 || pos>=(int)_time_steps.size())
7719     {
7720       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7721       throw INTERP_KERNEL::Exception(oss.str());
7722     }
7723   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7724   if(item==0)
7725     {
7726       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7727       oss << "\nTry to use following method eraseEmptyTS !";
7728       throw INTERP_KERNEL::Exception(oss.str());
7729     }
7730   return item;
7731 }
7732
7733 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7734 {
7735   std::vector<std::string> ret;
7736   std::set<std::string> ret2;
7737   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7738     {
7739       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7740       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7741         if(ret2.find(*it2)==ret2.end())
7742           {
7743             ret.push_back(*it2);
7744             ret2.insert(*it2);
7745           }
7746     }
7747   return ret;
7748 }
7749
7750 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7751 {
7752   std::vector<std::string> ret;
7753   std::set<std::string> ret2;
7754   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7755     {
7756       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7757       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7758         if(ret2.find(*it2)==ret2.end())
7759           {
7760             ret.push_back(*it2);
7761             ret2.insert(*it2);
7762           }
7763     }
7764   return ret;
7765 }
7766
7767 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7768 {
7769   std::vector<std::string> ret;
7770   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7771     {
7772       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7773       ret.insert(ret.end(),tmp.begin(),tmp.end());
7774     }
7775   return ret;
7776 }
7777
7778 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7779 {
7780   std::vector<std::string> ret;
7781   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7782     {
7783       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7784       ret.insert(ret.end(),tmp.begin(),tmp.end());
7785     }
7786   return ret;
7787 }
7788
7789 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7790 {
7791   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7792     (*it)->changePflsRefsNamesGen2(mapOfModif);
7793 }
7794
7795 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7796 {
7797   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7798     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7799 }
7800
7801 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7802 {
7803   int lgth=_time_steps.size();
7804   std::vector< std::vector<TypeOfField> > ret(lgth);
7805   for(int i=0;i<lgth;i++)
7806     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7807   return ret;
7808 }
7809
7810 /*!
7811  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7812  */
7813 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
7814 {
7815   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7816 }
7817
7818 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7819 {
7820   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7821   std::size_t i=0;
7822   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7823     {
7824       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7825         ret->_time_steps[i]=(*it)->deepCopy();
7826     }
7827   return ret.retn();
7828 }
7829
7830 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7831 {
7832   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7833   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7834   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7835   for(std::size_t i=0;i<sz;i++)
7836     {
7837       ret[i]=shallowCpy();
7838       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7839     }
7840   for(std::size_t i=0;i<sz2;i++)
7841     {
7842       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7843       if(ret1.size()!=sz)
7844         {
7845           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7846           throw INTERP_KERNEL::Exception(oss.str());
7847         }
7848       ts[i]=ret1;
7849     }
7850   for(std::size_t i=0;i<sz;i++)
7851     for(std::size_t j=0;j<sz2;j++)
7852       ret[i]->_time_steps[j]=ts[j][i];
7853   return ret;
7854 }
7855
7856 /*!
7857  * This method splits into discretization each time steps in \a this.
7858  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7859  */
7860 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7861 {
7862   std::size_t sz(_time_steps.size());
7863   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7864   for(std::size_t i=0;i<sz;i++)
7865     {
7866       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7867       if(!timeStep)
7868         {
7869           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7870           throw INTERP_KERNEL::Exception(oss.str());
7871         }
7872       items[i]=timeStep->splitDiscretizations();  
7873     }
7874   //
7875   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7876   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7877   std::vector< TypeOfField > types;
7878   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7879     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7880       {
7881         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7882         if(ts.size()!=1)
7883           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7884         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7885         if(it2==types.end())
7886           types.push_back(ts[0]);
7887       }
7888   ret.resize(types.size()); ret2.resize(types.size());
7889   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7890     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7891       {
7892         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7893         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7894         ret2[pos].push_back(*it1);
7895       }
7896   for(std::size_t i=0;i<types.size();i++)
7897     {
7898       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7899       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7900         elt->pushBackTimeStep(*it1);//also updates infos in elt
7901       ret[i]=elt;
7902       elt->MEDFileFieldNameScope::operator=(*this);
7903     }
7904   return ret;
7905 }
7906
7907 /*!
7908  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7909  */
7910 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7911 {
7912   std::size_t sz(_time_steps.size());
7913   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7914   std::size_t szOut(std::numeric_limits<std::size_t>::max());
7915   for(std::size_t i=0;i<sz;i++)
7916     {
7917       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7918       if(!timeStep)
7919         {
7920           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7921           throw INTERP_KERNEL::Exception(oss.str());
7922         }
7923       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7924       if(szOut==std::numeric_limits<std::size_t>::max())
7925         szOut=items[i].size();
7926       else
7927         if(items[i].size()!=szOut)
7928           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7929     }
7930   if(szOut==std::numeric_limits<std::size_t>::max())
7931     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7932   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7933   for(std::size_t i=0;i<szOut;i++)
7934     {
7935       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7936       for(std::size_t j=0;j<sz;j++)
7937         elt->pushBackTimeStep(items[j][i]);
7938       ret[i]=elt;
7939       elt->MEDFileFieldNameScope::operator=(*this);
7940     }
7941   return ret;
7942 }
7943
7944 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7945 {
7946   _name=field->getName();
7947   if(_name.empty())
7948     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7949   if(!arr)
7950     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7951   _infos=arr->getInfoOnComponents();
7952 }
7953
7954 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7955 {
7956   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7957   if(_name!=field->getName())
7958     {
7959       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7960       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7961       throw INTERP_KERNEL::Exception(oss.str());
7962     }
7963   if(!arr)
7964     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7965   checkThatComponentsMatch(arr->getInfoOnComponents());
7966 }
7967
7968 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7969 {
7970   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7971   if(getInfo().size()!=compos.size())
7972     {
7973       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7974       oss << " number of components of element to append (" << compos.size() << ") !";
7975       throw INTERP_KERNEL::Exception(oss.str());
7976     }
7977   if(_infos!=compos)
7978     {
7979       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7980       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7981       oss << " But compo in input fields are : ";
7982       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7983       oss << " !";
7984       throw INTERP_KERNEL::Exception(oss.str());
7985     }
7986 }
7987
7988 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7989 {
7990   std::size_t sz=_infos.size();
7991   int j=0;
7992   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7993     {
7994       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7995       if(elt)
7996         if(elt->getInfo().size()!=sz)
7997           {
7998             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7999             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8000             throw INTERP_KERNEL::Exception(oss.str());
8001           }
8002     }
8003 }
8004
8005 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8006 {
8007   if(!field)
8008     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8009   if(!_time_steps.empty())
8010     checkCoherencyOfTinyInfo(field,arr);
8011   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8012   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8013   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8014   copyTinyInfoFrom(field,arr);
8015   _time_steps.push_back(obj);
8016 }
8017
8018 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8019 {
8020   if(!field)
8021     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8022   if(!_time_steps.empty())
8023     checkCoherencyOfTinyInfo(field,arr);
8024   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8025   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8026   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8027   copyTinyInfoFrom(field,arr);
8028   _time_steps.push_back(obj);
8029 }
8030
8031 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8032 {
8033   int sz=(int)_time_steps.size();
8034   if(i<0 || i>=sz)
8035     {
8036       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8037       throw INTERP_KERNEL::Exception(oss.str());
8038     }
8039   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8040   if(tsPtr)
8041     {
8042       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8043         {
8044           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8045           throw INTERP_KERNEL::Exception(oss.str());
8046         }
8047     }
8048   _time_steps[i]=ts;
8049 }
8050
8051 //= MEDFileFieldMultiTSWithoutSDA
8052
8053 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8054 {
8055   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8056 }
8057
8058 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8059 {
8060 }
8061
8062 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8063 {
8064 }
8065
8066 /*!
8067  * \param [in] fieldId field id in C mode
8068  */
8069 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8070 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8071 {
8072 }
8073 catch(INTERP_KERNEL::Exception& e)
8074 { throw e; }
8075
8076 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8077 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8078 {
8079 }
8080 catch(INTERP_KERNEL::Exception& e)
8081 { throw e; }
8082
8083 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8084 {
8085   return new MEDFileField1TSWithoutSDA;
8086 }
8087
8088 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8089 {
8090   if(!f1ts)
8091     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8092   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8093   if(!f1tsC)
8094     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8095 }
8096
8097 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8098 {
8099   return MEDFileField1TSWithoutSDA::TYPE_STR;
8100 }
8101
8102 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8103 {
8104   return new MEDFileFieldMultiTSWithoutSDA(*this);
8105 }
8106
8107 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8108 {
8109   return new MEDFileFieldMultiTSWithoutSDA;
8110 }
8111
8112 /*!
8113  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8114  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8115  */
8116 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
8117 {
8118   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8119   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8120   if(!myF1TSC)
8121     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8122   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8123 }
8124
8125 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8126 {
8127   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8128   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8129   int i=0;
8130   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8131     {
8132       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8133       if(eltToConv)
8134         {
8135           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8136           if(!eltToConvC)
8137             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8138           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8139           ret->setIteration(i,elt);
8140         }
8141     }
8142   return ret.retn();
8143 }
8144
8145 //= MEDFileAnyTypeFieldMultiTS
8146
8147 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8148 {
8149 }
8150
8151 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8152 try:MEDFileFieldGlobsReal(fid)
8153 {
8154   _content=BuildContentFrom(fid,loadAll,ms);
8155   loadGlobals(fid);
8156 }
8157 catch(INTERP_KERNEL::Exception& e)
8158 {
8159     throw e;
8160 }
8161
8162 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8163 {
8164   med_field_type typcha;
8165   std::vector<std::string> infos;
8166   std::string dtunit;
8167   int i(-1);
8168   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8169   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8170   switch(typcha)
8171   {
8172     case MED_FLOAT64:
8173       {
8174         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8175         break;
8176       }
8177     case MED_INT32:
8178       {
8179         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8180         break;
8181       }
8182     default:
8183       {
8184         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] !";
8185         throw INTERP_KERNEL::Exception(oss.str());
8186       }
8187   }
8188   ret->setDtUnit(dtunit.c_str());
8189   return ret.retn();
8190 }
8191
8192 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8193 {
8194   med_field_type typcha;
8195   //
8196   std::vector<std::string> infos;
8197   std::string dtunit,fieldName;
8198   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8199   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8200   switch(typcha)
8201   {
8202     case MED_FLOAT64:
8203       {
8204         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8205         break;
8206       }
8207     case MED_INT32:
8208       {
8209         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8210         break;
8211       }
8212     default:
8213       {
8214         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] !";
8215         throw INTERP_KERNEL::Exception(oss.str());
8216       }
8217   }
8218   ret->setDtUnit(dtunit.c_str());
8219   return ret.retn();
8220 }
8221
8222 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8223 {
8224   if(!c)
8225     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8226   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8227     {
8228       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8229       ret->_content=c;  c->incrRef();
8230       return ret.retn();
8231     }
8232   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8233     {
8234       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8235       ret->_content=c;  c->incrRef();
8236       return ret.retn();
8237     }
8238   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8239 }
8240
8241 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8242 {
8243   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8244   std::string fileName(FileNameFromFID(fid));
8245   ret->setFileName(fileName);
8246   return ret;
8247 }
8248
8249 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8250 try:MEDFileFieldGlobsReal(fid)
8251 {
8252   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8253   loadGlobals(fid);
8254 }
8255 catch(INTERP_KERNEL::Exception& e)
8256 {
8257     throw e;
8258 }
8259
8260 //= MEDFileIntFieldMultiTSWithoutSDA
8261
8262 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8263 {
8264   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8265 }
8266
8267 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8268 {
8269 }
8270
8271 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8272 {
8273 }
8274
8275 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8276 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8277 {
8278 }
8279 catch(INTERP_KERNEL::Exception& e)
8280 { throw e; }
8281
8282 /*!
8283  * \param [in] fieldId field id in C mode
8284  */
8285 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8286 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8287 {
8288 }
8289 catch(INTERP_KERNEL::Exception& e)
8290 { throw e; }
8291
8292 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8293 {
8294   return new MEDFileIntField1TSWithoutSDA;
8295 }
8296
8297 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8298 {
8299   if(!f1ts)
8300     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8301   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8302   if(!f1tsC)
8303     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8304 }
8305
8306 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8307 {
8308   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8309 }
8310
8311 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8312 {
8313   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8314 }
8315
8316 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8317 {
8318   return new MEDFileIntFieldMultiTSWithoutSDA;
8319 }
8320
8321 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8322 {
8323   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8324   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8325   int i=0;
8326   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8327     {
8328       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8329       if(eltToConv)
8330         {
8331           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8332           if(!eltToConvC)
8333             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8334           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8335           ret->setIteration(i,elt);
8336         }
8337     }
8338   return ret.retn();
8339 }
8340
8341 //= MEDFileAnyTypeFieldMultiTS
8342
8343 /*!
8344  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8345  * that has been read from a specified MED file.
8346  *  \param [in] fileName - the name of the MED file to read.
8347  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8348  *          is to delete this field using decrRef() as it is no more needed.
8349  *  \throw If reading the file fails.
8350  */
8351 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8352 {
8353   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8354   return New(fid,loadAll);
8355 }
8356
8357 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8358 {
8359   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8360   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8361   ret->loadGlobals(fid);
8362   return ret.retn();
8363 }
8364
8365 /*!
8366  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8367  * that has been read from a specified MED file.
8368  *  \param [in] fileName - the name of the MED file to read.
8369  *  \param [in] fieldName - the name of the field to read.
8370  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8371  *          is to delete this field using decrRef() as it is no more needed.
8372  *  \throw If reading the file fails.
8373  *  \throw If there is no field named \a fieldName in the file.
8374  */
8375 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8376 {
8377   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8378   return New(fid,fieldName,loadAll);
8379 }
8380
8381 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8382 {
8383   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8384   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8385   ret->loadGlobals(fid);
8386   return ret.retn();
8387 }
8388
8389 /*!
8390  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8391  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8392  *
8393  * \warning this is a shallow copy constructor
8394  */
8395 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8396 {
8397   if(!shallowCopyOfContent)
8398     {
8399       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8400       otherPtr->incrRef();
8401       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8402     }
8403   else
8404     {
8405       _content=other.shallowCpy();
8406     }
8407 }
8408
8409 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8410 {
8411   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8412   if(!ret)
8413     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8414   return ret;
8415 }
8416
8417 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8418 {
8419   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8420   if(!ret)
8421     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8422   return ret;
8423 }
8424
8425 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8426 {
8427   return contentNotNullBase()->getPflsReallyUsed2();
8428 }
8429
8430 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8431 {
8432   return contentNotNullBase()->getLocsReallyUsed2();
8433 }
8434
8435 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8436 {
8437   return contentNotNullBase()->getPflsReallyUsedMulti2();
8438 }
8439
8440 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8441 {
8442   return contentNotNullBase()->getLocsReallyUsedMulti2();
8443 }
8444
8445 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8446 {
8447   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8448 }
8449
8450 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8451 {
8452   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8453 }
8454
8455 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8456 {
8457   return contentNotNullBase()->getNumberOfTS();
8458 }
8459
8460 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8461 {
8462   contentNotNullBase()->eraseEmptyTS();
8463 }
8464
8465 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8466 {
8467   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8468 }
8469
8470 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8471 {
8472   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8473 }
8474
8475 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8476 {
8477   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8478   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8479   ret->_content=c;
8480   return ret.retn();
8481 }
8482
8483 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8484 {
8485   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8486   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8487   ret->_content=c;
8488   return ret.retn();
8489 }
8490
8491 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8492 {
8493   return contentNotNullBase()->getIterations();
8494 }
8495
8496 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8497 {
8498   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8499     pushBackTimeStep(*it);
8500 }
8501
8502 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8503 {
8504   if(!fmts)
8505     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8506   int nbOfTS(fmts->getNumberOfTS());
8507   for(int i=0;i<nbOfTS;i++)
8508     {
8509       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8510       pushBackTimeStep(elt);
8511     }
8512 }
8513
8514 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8515 {
8516   if(!f1ts)
8517     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8518   checkCoherencyOfType(f1ts);
8519   f1ts->incrRef();
8520   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8521   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8522   c->incrRef();
8523   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8524   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8525     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8526   _content->pushBackTimeStep(cSafe);
8527   appendGlobs(*f1ts,1e-12);
8528 }
8529
8530 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8531 {
8532   contentNotNullBase()->synchronizeNameScope();
8533 }
8534
8535 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8536 {
8537   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8538 }
8539
8540 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8541 {
8542   return contentNotNullBase()->getPosGivenTime(time,eps);
8543 }
8544
8545 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8546 {
8547   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8548 }
8549
8550 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8551 {
8552   return contentNotNullBase()->getTypesOfFieldAvailable();
8553 }
8554
8555 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
8556 {
8557   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8558 }
8559
8560 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8561 {
8562   return contentNotNullBase()->getName();
8563 }
8564
8565 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8566 {
8567   contentNotNullBase()->setName(name);
8568 }
8569
8570 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8571 {
8572   return contentNotNullBase()->getDtUnit();
8573 }
8574
8575 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8576 {
8577   contentNotNullBase()->setDtUnit(dtUnit);
8578 }
8579
8580 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8581 {
8582   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8583 }
8584
8585 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8586 {
8587   return contentNotNullBase()->getTimeSteps(ret1);
8588 }
8589
8590 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8591 {
8592   return contentNotNullBase()->getMeshName();
8593 }
8594
8595 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8596 {
8597   contentNotNullBase()->setMeshName(newMeshName);
8598 }
8599
8600 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8601 {
8602   return contentNotNullBase()->changeMeshNames(modifTab);
8603 }
8604
8605 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8606 {
8607   return contentNotNullBase()->getInfo();
8608 }
8609
8610 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8611 {
8612   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8613 }
8614
8615 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8616 {
8617   return contentNotNullBase()->setInfo(info);
8618 }
8619
8620 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8621 {
8622   const std::vector<std::string> ret=getInfo();
8623   return (int)ret.size();
8624 }
8625
8626 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8627 {
8628   writeGlobals(fid,*this);
8629   contentNotNullBase()->writeLL(fid,*this);
8630 }
8631
8632 /*!
8633  * This method alloc the arrays and load potentially huge arrays contained in this field.
8634  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8635  * This method can be also called to refresh or reinit values from a file.
8636  * 
8637  * \throw If the fileName is not set or points to a non readable MED file.
8638  */
8639 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8640 {
8641   if(getFileName().empty())
8642     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8643   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8644   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8645 }
8646
8647 /*!
8648  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8649  * But once data loaded once, this method does nothing.
8650  * 
8651  * \throw If the fileName is not set or points to a non readable MED file.
8652  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8653  */
8654 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8655 {
8656   if(!getFileName().empty())
8657     {
8658       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8659       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8660     }
8661 }
8662
8663 /*!
8664  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8665  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8666  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8667  * 
8668  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8669  */
8670 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8671 {
8672   contentNotNullBase()->unloadArrays();
8673 }
8674
8675 /*!
8676  * 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.
8677  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8678  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8679  * 
8680  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8681  */
8682 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8683 {
8684   if(!getFileName().empty())
8685     contentNotNullBase()->unloadArrays();
8686 }
8687
8688 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8689 {
8690   std::ostringstream oss;
8691   contentNotNullBase()->simpleRepr(0,oss,-1);
8692   simpleReprGlobs(oss);
8693   return oss.str();
8694 }
8695
8696 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8697 {
8698   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8699 }
8700
8701 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8702 {
8703   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8704   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8705   return ret;
8706 }
8707
8708 /*!
8709  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8710  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8711  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8712  */
8713 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8714 {
8715   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8716   if(!content)
8717     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8718   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8719   std::size_t sz(contentsSplit.size());
8720   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8721   for(std::size_t i=0;i<sz;i++)
8722     {
8723       ret[i]=shallowCpy();
8724       ret[i]->_content=contentsSplit[i];
8725     }
8726   return ret;
8727 }
8728
8729 /*!
8730  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8731  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8732  */
8733 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8734 {
8735   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8736   if(!content)
8737     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8738   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8739   std::size_t sz(contentsSplit.size());
8740   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8741   for(std::size_t i=0;i<sz;i++)
8742     {
8743       ret[i]=shallowCpy();
8744       ret[i]->_content=contentsSplit[i];
8745     }
8746   return ret;
8747 }
8748
8749 /*!
8750  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8751  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8752  */
8753 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8754 {
8755   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8756   if(!content)
8757     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8758   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8759   std::size_t sz(contentsSplit.size());
8760   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8761   for(std::size_t i=0;i<sz;i++)
8762     {
8763       ret[i]=shallowCpy();
8764       ret[i]->_content=contentsSplit[i];
8765     }
8766   return ret;
8767 }
8768
8769 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8770 {
8771   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8772   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8773     ret->_content=_content->deepCopy();
8774   ret->deepCpyGlobs(*this);
8775   return ret.retn();
8776 }
8777
8778 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8779 {
8780   return _content;
8781 }
8782
8783 /*!
8784  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8785  *  \param [in] iteration - the iteration number of a required time step.
8786  *  \param [in] order - the iteration order number of required time step.
8787  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8788  *          delete this field using decrRef() as it is no more needed.
8789  *  \throw If there is no required time step in \a this field.
8790  */
8791 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8792 {
8793   int pos=getPosOfTimeStep(iteration,order);
8794   return getTimeStepAtPos(pos);
8795 }
8796
8797 /*!
8798  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8799  *  \param [in] time - the time of the time step of interest.
8800  *  \param [in] eps - a precision used to compare time values.
8801  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8802  *          delete this field using decrRef() as it is no more needed.
8803  *  \throw If there is no required time step in \a this field.
8804  */
8805 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8806 {
8807   int pos=getPosGivenTime(time,eps);
8808   return getTimeStepAtPos(pos);
8809 }
8810
8811 /*!
8812  * 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.
8813  * The float64 value of time attached to the pair of integers are not considered here.
8814  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8815  *
8816  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8817  * \throw If there is a null pointer in \a vectFMTS.
8818  */
8819 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8820 {
8821   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8822   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8823   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8824   while(!lstFMTS.empty())
8825     {
8826       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8827       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8828       if(!curIt)
8829         throw INTERP_KERNEL::Exception(msg);
8830       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8831       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8832       elt.push_back(curIt); it=lstFMTS.erase(it);
8833       while(it!=lstFMTS.end())
8834         {
8835           curIt=*it;
8836           if(!curIt)
8837             throw INTERP_KERNEL::Exception(msg);
8838           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8839           if(refIts==curIts)
8840             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8841           else
8842             it++;
8843         }
8844       ret.push_back(elt);
8845     }
8846   return ret;
8847 }
8848
8849 /*!
8850  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8851  * All returned instances in a subvector can be safely loaded, rendered along time
8852  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8853  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8854  * 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).
8855  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8856  * 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.
8857  *
8858  * \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().
8859  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8860  * \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.
8861  * \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.
8862  *
8863  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8864  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8865  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8866  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8867  * \throw If mesh is null.
8868  * \throw If an element in \a vectFMTS is null.
8869  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8870  */
8871 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8872 {
8873   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8874   if(!mesh)
8875     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8876   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8877   if(vectFMTS.empty())
8878     return ret;
8879   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8880   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8881   if(!frstElt)
8882     throw INTERP_KERNEL::Exception(msg);
8883   std::size_t i=0;
8884   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8885   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8886   for(;it!=vectFMTS.end();it++,i++)
8887     {
8888       if(!(*it))
8889         throw INTERP_KERNEL::Exception(msg);
8890       TypeOfField tof0,tof1;
8891       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8892         {
8893           if(tof1!=ON_NODES)
8894             vectFMTSNotNodes.push_back(*it);
8895           else
8896             vectFMTSNodes.push_back(*it);
8897         }
8898       else
8899         vectFMTSNotNodes.push_back(*it);
8900     }
8901   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8902   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8903   ret=retCell;
8904   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8905     {
8906       i=0;
8907       bool isFetched(false);
8908       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8909         {
8910           if((*it0).empty())
8911             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8912           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8913             { ret[i].push_back(*it2); isFetched=true; }
8914         }
8915       if(!isFetched)
8916         {
8917           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8918           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8919           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8920         }
8921     }
8922   fsc=cmps;
8923   return ret;
8924 }
8925
8926 /*!
8927  * 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.
8928  * \param [out] cmps - same size than the returned vector.
8929  */
8930 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8931 {
8932   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8933   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8934   while(!lstFMTS.empty())
8935     {
8936       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8937       MEDFileAnyTypeFieldMultiTS *ref(*it);
8938       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8939       elt.push_back(ref); it=lstFMTS.erase(it);
8940       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8941       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8942       while(it!=lstFMTS.end())
8943         {
8944           MEDFileAnyTypeFieldMultiTS *curIt(*it);
8945           if(cmp->isEqual(curIt))
8946             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8947           else
8948             it++;
8949         }
8950       ret.push_back(elt); cmps.push_back(cmp);
8951     }
8952   return ret;
8953 }
8954
8955 /*!
8956  * 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.
8957  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8958  *
8959  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8960  * \throw If \a f0 or \a f1 change of spatial discretization along time.
8961  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8962  * \thorw If \a f0 and \a f1 do not have the same times steps.
8963  * \throw If mesh is null.
8964  * \throw If \a f0 or \a f1 is null.
8965  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8966  */
8967 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8968 {
8969   if(!mesh)
8970     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8971   if(!f0 || !f1)
8972     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8973   if(f0->getMeshName()!=mesh->getName())
8974     {
8975       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8976       throw INTERP_KERNEL::Exception(oss.str());
8977     }
8978   if(f1->getMeshName()!=mesh->getName())
8979     {
8980       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8981       throw INTERP_KERNEL::Exception(oss.str());
8982     }
8983   int nts=f0->getNumberOfTS();
8984   if(nts!=f1->getNumberOfTS())
8985     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8986   if(nts==0)
8987     return nts;
8988   for(int i=0;i<nts;i++)
8989     {
8990       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8991       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8992       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8993       if(tofs0.size()!=1 || tofs1.size()!=1)
8994         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8995       if(i!=0)
8996         {
8997           if(tof0!=tofs0[0] || tof1!=tofs1[0])
8998             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8999         }
9000       else
9001         { tof0=tofs0[0]; tof1=tofs1[0]; }
9002       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9003         {
9004           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() << ") !";
9005           throw INTERP_KERNEL::Exception(oss.str());
9006         }
9007       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9008         {
9009           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() << ") !";
9010           throw INTERP_KERNEL::Exception(oss.str());
9011         }
9012       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9013         {
9014           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() << ") !";
9015           throw INTERP_KERNEL::Exception(oss.str());
9016         }
9017     }
9018   return nts;
9019 }
9020
9021 /*!
9022  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9023  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9024  *
9025  * \return A new object that the caller is responsible to deallocate.
9026  */
9027 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9028 {
9029   if(!mm)
9030     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9031   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9032   int nbTS(getNumberOfTS());
9033   for(int i=0;i<nbTS;i++)
9034     {
9035       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9036       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9037       fmtsOut->pushBackTimeStep(f1tsOut);
9038     }
9039   return fmtsOut.retn();
9040 }
9041
9042 template<class T>
9043 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9044 {
9045   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9046   if(f1tss.empty())
9047     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9048   std::size_t sz(f1tss.size()),i(0);
9049   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9050   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9051     {
9052       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9053       if(!elt)
9054         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9055       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9056     }
9057   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9058   if(!retc)
9059     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9060   retc->aggregate(f1tsw,dts);
9061   ret->setDtUnit(f1tss[0]->getDtUnit());
9062   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9063 }
9064
9065 template<class T>
9066 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9067 {
9068   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9069   if(fmtss.empty())
9070     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9071   std::size_t sz(fmtss.size());
9072   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9073     {
9074       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9075       if(!elt)
9076         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9077     }
9078   int nbTS(fmtss[0]->getNumberOfTS());
9079   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9080     if((*it)->getNumberOfTS()!=nbTS)
9081       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9082   for(int iterTS=0;iterTS<nbTS;iterTS++)
9083     {
9084       std::size_t i(0);
9085       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9086       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9087       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9088         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9089       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9090       ret->pushBackTimeStep(f1ts);
9091       ret->setDtUnit(f1ts->getDtUnit());
9092     }
9093   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9094 }
9095
9096 /*!
9097  * \a dts and \a ftmss are expected to have same size.
9098  */
9099 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9100 {
9101   if(fmtss.empty())
9102     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9103   std::size_t sz(fmtss.size());
9104   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9105   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9106   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9107     {
9108       if(!(*it))
9109         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9110       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9111       if(elt1)
9112         {
9113           fmtss1.push_back(elt1);
9114           continue;
9115         }
9116       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9117       if(elt2)
9118         {
9119           fmtss2.push_back(elt2);
9120           continue;
9121         }
9122       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9123     }
9124   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9125     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9126   if(fmtss1.size()==sz)
9127     return AggregateHelperFMTS<double>(fmtss1,dts);
9128   if(fmtss2.size()!=sz)
9129     return AggregateHelperFMTS<int>(fmtss2,dts);
9130   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9131 }
9132
9133 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9134 {
9135   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9136 }
9137
9138 //= MEDFileFieldMultiTS
9139
9140 /*!
9141  * Returns a new empty instance of MEDFileFieldMultiTS.
9142  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9143  *          is to delete this field using decrRef() as it is no more needed.
9144  */
9145 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9146 {
9147   return new MEDFileFieldMultiTS;
9148 }
9149
9150 /*!
9151  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9152  * that has been read from a specified MED file.
9153  *  \param [in] fileName - the name of the MED file to read.
9154  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9155  *          is to delete this field using decrRef() as it is no more needed.
9156  *  \throw If reading the file fails.
9157  */
9158 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9159 {
9160   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9161   return New(fid,loadAll);
9162 }
9163
9164 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9165 {
9166   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9167   ret->contentNotNull();//to check that content type matches with \a this type.
9168   return ret.retn();
9169 }
9170
9171 /*!
9172  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9173  * that has been read from a specified MED file.
9174  *  \param [in] fileName - the name of the MED file to read.
9175  *  \param [in] fieldName - the name of the field to read.
9176  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9177  *          is to delete this field using decrRef() as it is no more needed.
9178  *  \throw If reading the file fails.
9179  *  \throw If there is no field named \a fieldName in the file.
9180  */
9181 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9182 {
9183   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9184   return New(fid,fieldName,loadAll);
9185 }
9186
9187 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9188 {
9189   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9190   ret->contentNotNull();//to check that content type matches with \a this type.
9191   return ret.retn();
9192 }
9193
9194 /*!
9195  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9196  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9197  *
9198  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9199  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9200  * \warning this is a shallow copy constructor
9201  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9202  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9203  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9204  *          is to delete this field using decrRef() as it is no more needed.
9205  */
9206 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9207 {
9208   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9209 }
9210
9211 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9212 {
9213   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9214   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,&entities));
9215   ret->contentNotNull();//to check that content type matches with \a this type.
9216   return ret.retn();
9217 }
9218
9219 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9220 {
9221   return new MEDFileFieldMultiTS(*this);
9222 }
9223
9224 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9225 {
9226   if(!f1ts)
9227     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9228   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9229   if(!f1tsC)
9230     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9231 }
9232
9233 /*!
9234  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9235  * following the given input policy.
9236  *
9237  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9238  *                            By default (true) the globals are deeply copied.
9239  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9240  */
9241 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9242 {
9243   MCAuto<MEDFileIntFieldMultiTS> ret;
9244   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9245   if(content)
9246     {
9247       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9248       if(!contc)
9249         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9250       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9251       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9252     }
9253   else
9254     ret=MEDFileIntFieldMultiTS::New();
9255   if(isDeepCpyGlobs)
9256     ret->deepCpyGlobs(*this);
9257   else
9258     ret->shallowCpyGlobs(*this);
9259   return ret.retn();
9260 }
9261
9262 /*!
9263  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9264  *  \param [in] pos - a time step id.
9265  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9266  *          delete this field using decrRef() as it is no more needed.
9267  *  \throw If \a pos is not a valid time step id.
9268  */
9269 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9270 {
9271   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9272   if(!item)
9273     {
9274       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9275       throw INTERP_KERNEL::Exception(oss.str());
9276     }
9277   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9278   if(itemC)
9279     {
9280       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9281       ret->shallowCpyGlobs(*this);
9282       return ret.retn();
9283     }
9284   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9285   throw INTERP_KERNEL::Exception(oss.str());
9286 }
9287
9288 /*!
9289  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9290  * mesh entities of a given dimension of the first mesh in MED file.
9291  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9292  *  \param [in] type - a spatial discretization of interest.
9293  *  \param [in] iteration - the iteration number of a required time step.
9294  *  \param [in] order - the iteration order number of required time step.
9295  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9296  *  \param [in] renumPol - specifies how to permute values of the result field according to
9297  *          the optional numbers of cells and nodes, if any. The valid values are
9298  *          - 0 - do not permute.
9299  *          - 1 - permute cells.
9300  *          - 2 - permute nodes.
9301  *          - 3 - permute cells and nodes.
9302  *
9303  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9304  *          caller is to delete this field using decrRef() as it is no more needed. 
9305  *  \throw If the MED file is not readable.
9306  *  \throw If there is no mesh in the MED file.
9307  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9308  *  \throw If no field values of the required parameters are available.
9309  */
9310 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9311 {
9312   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9313   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9314   if(!myF1TSC)
9315     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9316   MCAuto<DataArray> arrOut;
9317   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9318   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9319   return ret.retn();
9320 }
9321
9322 /*!
9323  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9324  * the top level cells of the first mesh in MED file.
9325  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9326  *  \param [in] type - a spatial discretization of interest.
9327  *  \param [in] iteration - the iteration number of a required time step.
9328  *  \param [in] order - the iteration order number of required time step.
9329  *  \param [in] renumPol - specifies how to permute values of the result field according to
9330  *          the optional numbers of cells and nodes, if any. The valid values are
9331  *          - 0 - do not permute.
9332  *          - 1 - permute cells.
9333  *          - 2 - permute nodes.
9334  *          - 3 - permute cells and nodes.
9335  *
9336  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9337  *          caller is to delete this field using decrRef() as it is no more needed. 
9338  *  \throw If the MED file is not readable.
9339  *  \throw If there is no mesh in the MED file.
9340  *  \throw If no field values of the required parameters are available.
9341  */
9342 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9343 {
9344   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9345   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9346   if(!myF1TSC)
9347     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9348   MCAuto<DataArray> arrOut;
9349   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9350   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9351   return ret.retn();
9352 }
9353
9354 /*!
9355  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9356  * method should be called (getFieldOnMeshAtLevel for example).
9357  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9358  *
9359  * \param [in] iteration - the iteration number of a required time step.
9360  * \param [in] order - the iteration order number of required time step.
9361  * \param [in] mesh - the mesh the field is lying on
9362  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9363  *          caller is to delete this field using decrRef() as it is no more needed. 
9364  */
9365 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9366 {
9367   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9368   MCAuto<DataArray> arrOut;
9369   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9370   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9371   return ret.retn();
9372 }
9373
9374 /*!
9375  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9376  * a given support.
9377  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9378  *  \param [in] type - a spatial discretization of interest.
9379  *  \param [in] iteration - the iteration number of a required time step.
9380  *  \param [in] order - the iteration order number of required time step.
9381  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9382  *  \param [in] mesh - the supporting mesh.
9383  *  \param [in] renumPol - specifies how to permute values of the result field according to
9384  *          the optional numbers of cells and nodes, if any. The valid values are
9385  *          - 0 - do not permute.
9386  *          - 1 - permute cells.
9387  *          - 2 - permute nodes.
9388  *          - 3 - permute cells and nodes.
9389  *
9390  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9391  *          caller is to delete this field using decrRef() as it is no more needed. 
9392  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9393  *  \throw If no field of \a this is lying on \a mesh.
9394  *  \throw If no field values of the required parameters are available.
9395  */
9396 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9397 {
9398   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9399   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9400   if(!myF1TSC)
9401     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9402   MCAuto<DataArray> arrOut;
9403   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9404   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9405   return ret.retn();
9406 }
9407
9408 /*!
9409  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9410  * given support. 
9411  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9412  *  \param [in] type - a spatial discretization of the new field.
9413  *  \param [in] iteration - the iteration number of a required time step.
9414  *  \param [in] order - the iteration order number of required time step.
9415  *  \param [in] mesh - the supporting mesh.
9416  *  \param [in] renumPol - specifies how to permute values of the result field according to
9417  *          the optional numbers of cells and nodes, if any. The valid values are
9418  *          - 0 - do not permute.
9419  *          - 1 - permute cells.
9420  *          - 2 - permute nodes.
9421  *          - 3 - permute cells and nodes.
9422  *
9423  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9424  *          caller is to delete this field using decrRef() as it is no more needed. 
9425  *  \throw If no field of \a this is lying on \a mesh.
9426  *  \throw If no field values of the required parameters are available.
9427  */
9428 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9429 {
9430   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9431   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9432   if(!myF1TSC)
9433     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9434   MCAuto<DataArray> arrOut;
9435   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9436   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9437   return ret.retn();
9438 }
9439
9440 /*!
9441  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9442  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9443  * This method is useful for MED2 file format when field on different mesh was autorized.
9444  */
9445 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9446 {
9447   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9448   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9449   if(!myF1TSC)
9450     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9451   MCAuto<DataArray> arrOut;
9452   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9453   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9454   return ret.retn();
9455 }
9456
9457 /*!
9458  * Returns values and a profile of the field of a given type, of a given time step,
9459  * lying on a given support.
9460  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9461  *  \param [in] type - a spatial discretization of the field.
9462  *  \param [in] iteration - the iteration number of a required time step.
9463  *  \param [in] order - the iteration order number of required time step.
9464  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9465  *  \param [in] mesh - the supporting mesh.
9466  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9467  *          field of interest lies on. If the field lies on all entities of the given
9468  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9469  *          using decrRef() as it is no more needed.  
9470  *  \param [in] glob - the global data storing profiles and localization.
9471  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9472  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9473  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9474  *  \throw If no field of \a this is lying on \a mesh.
9475  *  \throw If no field values of the required parameters are available.
9476  */
9477 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9478 {
9479   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9480   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9481   if(!myF1TSC)
9482     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9483   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9484   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9485 }
9486
9487 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9488 {
9489   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9490   if(!pt)
9491     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9492   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9493   if(!ret)
9494     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
9495   return ret;
9496 }
9497
9498 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9499 {
9500   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9501   if(!pt)
9502     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9503   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9504   if(!ret)
9505     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
9506   return ret;
9507 }
9508
9509 /*!
9510  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9511  * the given field is checked if its elements are sorted suitable for writing to MED file
9512  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9513  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9514  *  \param [in] field - the field to add to \a this.
9515  *  \throw If the name of \a field is empty.
9516  *  \throw If the data array of \a field is not set.
9517  *  \throw If existing time steps have different name or number of components than \a field.
9518  *  \throw If the underlying mesh of \a field has no name.
9519  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9520  */
9521 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9522 {
9523   const DataArrayDouble *arr=0;
9524   if(field)
9525     arr=field->getArray();
9526   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9527 }
9528
9529 /*!
9530  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9531  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9532  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9533  * and \a profile.
9534  *
9535  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9536  * A new profile is added only if no equal profile is missing.
9537  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9538  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9539  *  \param [in] mesh - the supporting mesh of \a field.
9540  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9541  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9542  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9543  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9544  *  \throw If the data array of \a field is not set.
9545  *  \throw If the data array of \a this is already allocated but has different number of
9546  *         components than \a field.
9547  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9548  *  \sa setFieldNoProfileSBT()
9549  */
9550 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9551 {
9552   const DataArrayDouble *arr=0;
9553   if(field)
9554     arr=field->getArray();
9555   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9556 }
9557
9558 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9559 {
9560   _content=new MEDFileFieldMultiTSWithoutSDA;
9561 }
9562
9563 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9564 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9565 {
9566 }
9567 catch(INTERP_KERNEL::Exception& e)
9568 { throw e; }
9569
9570 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9571 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9572 {
9573 }
9574 catch(INTERP_KERNEL::Exception& e)
9575 { throw e; }
9576
9577 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9578 {
9579 }
9580
9581 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
9582 {
9583   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9584 }
9585
9586 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9587 {
9588   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9589 }
9590
9591 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9592 {
9593   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9594 }
9595
9596 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9597 {
9598   return MEDFileFieldMultiTS::New();
9599 }
9600
9601 //= MEDFileAnyTypeFieldMultiTSIterator
9602
9603 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9604 {
9605   if(fmts)
9606     {
9607       fmts->incrRef();
9608       _nb_iter=fmts->getNumberOfTS();
9609     }
9610 }
9611
9612 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9613 {
9614 }
9615
9616 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9617 {
9618   if(_iter_id<_nb_iter)
9619     {
9620       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9621       if(fmts)
9622         return fmts->getTimeStepAtPos(_iter_id++);
9623       else
9624         return 0;
9625     }
9626   else
9627     return 0;
9628 }
9629
9630 //= MEDFileIntFieldMultiTS
9631
9632 /*!
9633  * Returns a new empty instance of MEDFileFieldMultiTS.
9634  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9635  *          is to delete this field using decrRef() as it is no more needed.
9636  */
9637 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9638 {
9639   return new MEDFileIntFieldMultiTS;
9640 }
9641
9642 /*!
9643  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9644  * that has been read from a specified MED file.
9645  *  \param [in] fileName - the name of the MED file to read.
9646  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9647  *          is to delete this field using decrRef() as it is no more needed.
9648  *  \throw If reading the file fails.
9649  */
9650 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9651 {
9652   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9653   return New(fid,loadAll);
9654 }
9655
9656 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9657 {
9658   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9659   ret->contentNotNull();//to check that content type matches with \a this type.
9660   return ret.retn();
9661 }
9662
9663 /*!
9664  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9665  * that has been read from a specified MED file.
9666  *  \param [in] fileName - the name of the MED file to read.
9667  *  \param [in] fieldName - the name of the field to read.
9668  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9669  *          is to delete this field using decrRef() as it is no more needed.
9670  *  \throw If reading the file fails.
9671  *  \throw If there is no field named \a fieldName in the file.
9672  */
9673 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9674 {
9675   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9676   return New(fid,fieldName,loadAll);
9677 }
9678
9679 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9680 {
9681   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9682   ret->contentNotNull();//to check that content type matches with \a this type.
9683   return ret.retn();
9684 }
9685
9686 /*!
9687  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9688  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9689  *
9690  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9691  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9692  * \warning this is a shallow copy constructor
9693  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9694  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9695  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9696  *          is to delete this field using decrRef() as it is no more needed.
9697  */
9698 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9699 {
9700   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9701 }
9702
9703 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9704 {
9705   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9706   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,&entities));
9707   ret->contentNotNull();//to check that content type matches with \a this type.
9708   return ret.retn();
9709 }
9710
9711 /*!
9712  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9713  * following the given input policy.
9714  *
9715  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9716  *                            By default (true) the globals are deeply copied.
9717  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9718  */
9719 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9720 {
9721   MCAuto<MEDFileFieldMultiTS> ret;
9722   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9723   if(content)
9724     {
9725       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9726       if(!contc)
9727         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9728       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9729       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9730     }
9731   else
9732     ret=MEDFileFieldMultiTS::New();
9733   if(isDeepCpyGlobs)
9734     ret->deepCpyGlobs(*this);
9735   else
9736     ret->shallowCpyGlobs(*this);
9737   return ret.retn();
9738 }
9739
9740 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9741 {
9742   return new MEDFileIntFieldMultiTS(*this);
9743 }
9744
9745 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9746 {
9747   if(!f1ts)
9748     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9749   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9750   if(!f1tsC)
9751     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9752 }
9753
9754 /*!
9755  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9756  * method should be called (getFieldOnMeshAtLevel for example).
9757  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9758  *
9759  * \param [in] iteration - the iteration number of a required time step.
9760  * \param [in] order - the iteration order number of required time step.
9761  * \param [in] mesh - the mesh the field is lying on
9762  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9763  *          caller is to delete this field using decrRef() as it is no more needed. 
9764  */
9765 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9766 {
9767   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9768   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9769   if(!myF1TSC)
9770     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9771   MCAuto<DataArray> arrOut;
9772   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9773   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9774   return ret2.retn();
9775 }
9776
9777 /*!
9778  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9779  * mesh entities of a given dimension of the first mesh in MED file.
9780  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9781  *  \param [in] type - a spatial discretization of interest.
9782  *  \param [in] iteration - the iteration number of a required time step.
9783  *  \param [in] order - the iteration order number of required time step.
9784  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9785  *  \param [in] renumPol - specifies how to permute values of the result field according to
9786  *          the optional numbers of cells and nodes, if any. The valid values are
9787  *          - 0 - do not permute.
9788  *          - 1 - permute cells.
9789  *          - 2 - permute nodes.
9790  *          - 3 - permute cells and nodes.
9791  *
9792  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9793  *          caller is to delete this field using decrRef() as it is no more needed. 
9794  *  \throw If the MED file is not readable.
9795  *  \throw If there is no mesh in the MED file.
9796  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9797  *  \throw If no field values of the required parameters are available.
9798  */
9799 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9800 {
9801   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9802   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9803   if(!myF1TSC)
9804     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9805   MCAuto<DataArray> arr;
9806   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9807   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9808   return ret2.retn();
9809 }
9810
9811 /*!
9812  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9813  * the top level cells of the first mesh in MED file.
9814  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9815  *  \param [in] type - a spatial discretization of interest.
9816  *  \param [in] iteration - the iteration number of a required time step.
9817  *  \param [in] order - the iteration order number of required time step.
9818  *  \param [in] renumPol - specifies how to permute values of the result field according to
9819  *          the optional numbers of cells and nodes, if any. The valid values are
9820  *          - 0 - do not permute.
9821  *          - 1 - permute cells.
9822  *          - 2 - permute nodes.
9823  *          - 3 - permute cells and nodes.
9824  *
9825  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9826  *          caller is to delete this field using decrRef() as it is no more needed. 
9827  *  \throw If the MED file is not readable.
9828  *  \throw If there is no mesh in the MED file.
9829  *  \throw If no field values of the required parameters are available.
9830  */
9831 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9832 {
9833   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9834   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9835   if(!myF1TSC)
9836     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9837   MCAuto<DataArray> arr;
9838   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9839   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9840   return ret2.retn();
9841 }
9842
9843 /*!
9844  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9845  * a given support.
9846  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9847  *  \param [in] type - a spatial discretization of interest.
9848  *  \param [in] iteration - the iteration number of a required time step.
9849  *  \param [in] order - the iteration order number of required time step.
9850  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9851  *  \param [in] mesh - the supporting mesh.
9852  *  \param [in] renumPol - specifies how to permute values of the result field according to
9853  *          the optional numbers of cells and nodes, if any. The valid values are
9854  *          - 0 - do not permute.
9855  *          - 1 - permute cells.
9856  *          - 2 - permute nodes.
9857  *          - 3 - permute cells and nodes.
9858  *
9859  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9860  *          caller is to delete this field using decrRef() as it is no more needed. 
9861  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9862  *  \throw If no field of \a this is lying on \a mesh.
9863  *  \throw If no field values of the required parameters are available.
9864  */
9865 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9866 {
9867   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9868   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9869   if(!myF1TSC)
9870     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9871   MCAuto<DataArray> arr;
9872   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9873   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9874   return ret2.retn();
9875 }
9876
9877 /*!
9878  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9879  * given support. 
9880  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9881  *  \param [in] type - a spatial discretization of the new field.
9882  *  \param [in] iteration - the iteration number of a required time step.
9883  *  \param [in] order - the iteration order number of required time step.
9884  *  \param [in] mesh - the supporting mesh.
9885  *  \param [out] arrOut - the DataArrayInt containing values of field.
9886  *  \param [in] renumPol - specifies how to permute values of the result field according to
9887  *          the optional numbers of cells and nodes, if any. The valid values are
9888  *          - 0 - do not permute.
9889  *          - 1 - permute cells.
9890  *          - 2 - permute nodes.
9891  *          - 3 - permute cells and nodes.
9892  *
9893  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9894  *          caller is to delete this field using decrRef() as it is no more needed. 
9895  *  \throw If no field of \a this is lying on \a mesh.
9896  *  \throw If no field values of the required parameters are available.
9897  */
9898 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9899 {
9900   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9901   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9902   if(!myF1TSC)
9903     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9904   MCAuto<DataArray> arr;
9905   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9906   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9907   return ret2.retn();
9908 }
9909
9910 /*!
9911  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9912  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9913  * This method is useful for MED2 file format when field on different mesh was autorized.
9914  */
9915 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9916 {
9917   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9918   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9919   if(!myF1TSC)
9920     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9921   MCAuto<DataArray> arr;
9922   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9923   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9924   return ret2.retn();
9925 }
9926
9927 /*!
9928  * Returns values and a profile of the field of a given type, of a given time step,
9929  * lying on a given support.
9930  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9931  *  \param [in] type - a spatial discretization of the field.
9932  *  \param [in] iteration - the iteration number of a required time step.
9933  *  \param [in] order - the iteration order number of required time step.
9934  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9935  *  \param [in] mesh - the supporting mesh.
9936  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9937  *          field of interest lies on. If the field lies on all entities of the given
9938  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9939  *          using decrRef() as it is no more needed.  
9940  *  \param [in] glob - the global data storing profiles and localization.
9941  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9942  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9943  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9944  *  \throw If no field of \a this is lying on \a mesh.
9945  *  \throw If no field values of the required parameters are available.
9946  */
9947 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9948 {
9949   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9950   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9951   if(!myF1TSC)
9952     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9953   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9954   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9955 }
9956
9957 /*!
9958  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9959  *  \param [in] pos - a time step id.
9960  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9961  *          delete this field using decrRef() as it is no more needed.
9962  *  \throw If \a pos is not a valid time step id.
9963  */
9964 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9965 {
9966   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9967   if(!item)
9968     {
9969       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9970       throw INTERP_KERNEL::Exception(oss.str());
9971     }
9972   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9973   if(itemC)
9974     {
9975       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9976       ret->shallowCpyGlobs(*this);
9977       return ret.retn();
9978     }
9979   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9980   throw INTERP_KERNEL::Exception(oss.str());
9981 }
9982
9983 /*!
9984  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
9985  * the given field is checked if its elements are sorted suitable for writing to MED file
9986  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9987  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9988  *  \param [in] field - the field to add to \a this.
9989  *  \throw If the name of \a field is empty.
9990  *  \throw If the data array of \a field is not set.
9991  *  \throw If existing time steps have different name or number of components than \a field.
9992  *  \throw If the underlying mesh of \a field has no name.
9993  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9994  */
9995 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
9996 {
9997   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9998   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
9999 }
10000
10001 /*!
10002  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10003  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10004  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10005  * and \a profile.
10006  *
10007  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10008  * A new profile is added only if no equal profile is missing.
10009  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10010  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10011  *  \param [in] arrOfVals - the values of the field \a field used.
10012  *  \param [in] mesh - the supporting mesh of \a field.
10013  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10014  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10015  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10016  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10017  *  \throw If the data array of \a field is not set.
10018  *  \throw If the data array of \a this is already allocated but has different number of
10019  *         components than \a field.
10020  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10021  *  \sa setFieldNoProfileSBT()
10022  */
10023 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10024 {
10025   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10026   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10027 }
10028
10029 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10030 {
10031   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10032   if(!pt)
10033     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10034   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10035   if(!ret)
10036     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
10037   return ret;
10038 }
10039
10040 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10041 {
10042   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10043   if(!pt)
10044     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10045   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10046   if(!ret)
10047     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
10048   return ret;
10049 }
10050
10051 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10052 {
10053   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10054 }
10055
10056 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10057 {
10058 }
10059
10060 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10061 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10062 {
10063 }
10064 catch(INTERP_KERNEL::Exception& e)
10065 { throw e; }
10066
10067 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10068 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10069 {
10070 }
10071 catch(INTERP_KERNEL::Exception& e)
10072 { throw e; }
10073
10074 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10075 {
10076   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10077 }
10078
10079 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10080 {
10081   return MEDFileIntFieldMultiTS::New();
10082 }
10083
10084 //= MEDFileFields
10085
10086 MEDFileFields *MEDFileFields::New()
10087 {
10088   return new MEDFileFields;
10089 }
10090
10091 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10092 {
10093   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10094   return New(fid,loadAll);
10095 }
10096
10097 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10098 {
10099   return new MEDFileFields(fid,loadAll,0,0);
10100 }
10101
10102 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10103 {
10104   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10105   return new MEDFileFields(fid,loadAll,ms,0);
10106 }
10107
10108 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10109 {
10110   MEDFileUtilities::CheckFileForRead(fileName);
10111   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10112   return new MEDFileFields(fid,loadAll,0,&entities);
10113 }
10114
10115 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10116 {
10117   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10118   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10119   return ret;
10120 }
10121
10122 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10123 {
10124   std::vector<const BigMemoryObject *> ret;
10125   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10126     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10127   return ret;
10128 }
10129
10130 MEDFileFields *MEDFileFields::deepCopy() const
10131 {
10132   MCAuto<MEDFileFields> ret(shallowCpy());
10133   std::size_t i(0);
10134   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10135     {
10136       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10137         ret->_fields[i]=(*it)->deepCopy();
10138     }
10139   ret->deepCpyGlobs(*this);
10140   return ret.retn();
10141 }
10142
10143 MEDFileFields *MEDFileFields::shallowCpy() const
10144 {
10145   return new MEDFileFields(*this);
10146 }
10147
10148 /*!
10149  * This method scans for all fields in \a this which time steps ids are common. Time step are discriminated by the pair of integer (iteration,order) whatever
10150  * the double time value. If all returned time steps are \b exactly those for all fields in \a this output parameter \a areThereSomeForgottenTS will be set to false.
10151  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10152  *
10153  * \param [out] areThereSomeForgottenTS - indicates to the caller if there is some time steps in \a this that are not present for all fields in \a this.
10154  * \return the sorted list of time steps (specified with a pair of integer iteration first and order second) present for all fields in \a this.
10155  * 
10156  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10157  */
10158 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10159 {
10160   std::set< std::pair<int,int> > s;
10161   bool firstShot=true;
10162   areThereSomeForgottenTS=false;
10163   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10164     {
10165       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10166         continue;
10167       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10168       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10169       if(firstShot)
10170         { s=s1; firstShot=false; }
10171       else
10172         {
10173           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10174           if(s!=s2)
10175             areThereSomeForgottenTS=true;
10176           s=s2;
10177         }
10178     }
10179   std::vector< std::pair<int,int> > ret;
10180   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10181   return ret;
10182 }
10183
10184 int MEDFileFields::getNumberOfFields() const
10185 {
10186   return _fields.size();
10187 }
10188
10189 std::vector<std::string> MEDFileFields::getFieldsNames() const
10190 {
10191   std::vector<std::string> ret(_fields.size());
10192   int i(0);
10193   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10194     {
10195       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10196       if(f)
10197         {
10198           ret[i]=f->getName();
10199         }
10200       else
10201         {
10202           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10203           throw INTERP_KERNEL::Exception(oss.str());
10204         }
10205     }
10206   return ret;
10207 }
10208
10209 std::vector<std::string> MEDFileFields::getMeshesNames() const
10210 {
10211   std::vector<std::string> ret;
10212   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10213     {
10214       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10215       if(cur)
10216         ret.push_back(cur->getMeshName());
10217     }
10218   return ret;
10219 }
10220
10221 std::string MEDFileFields::simpleRepr() const
10222 {
10223   std::ostringstream oss;
10224   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10225   simpleRepr(0,oss);
10226   return oss.str();
10227 }
10228
10229 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10230 {
10231   int nbOfFields(getNumberOfFields());
10232   std::string startLine(bkOffset,' ');
10233   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10234   int i=0;
10235   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10236     {
10237       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10238       if(cur)
10239         {
10240           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10241         }
10242       else
10243         {
10244           oss << startLine << "  - not defined !" << std::endl;
10245         }
10246     }
10247   i=0;
10248   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10249     {
10250       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10251       std::string chapter(17,'0'+i);
10252       oss << startLine << chapter << std::endl;
10253       if(cur)
10254         {
10255           cur->simpleRepr(bkOffset+2,oss,i);
10256         }
10257       else
10258         {
10259           oss << startLine << "  - not defined !" << std::endl;
10260         }
10261       oss << startLine << chapter << std::endl;
10262     }
10263   simpleReprGlobs(oss);
10264 }
10265
10266 MEDFileFields::MEDFileFields()
10267 {
10268 }
10269
10270 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10271 try:MEDFileFieldGlobsReal(fid)
10272 {
10273   int nbFields(MEDnField(fid));
10274   _fields.resize(nbFields);
10275   med_field_type typcha;
10276   for(int i=0;i<nbFields;i++)
10277     {
10278       std::vector<std::string> infos;
10279       std::string fieldName,dtunit;
10280       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10281       switch(typcha)
10282       {
10283         case MED_FLOAT64:
10284           {
10285             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10286             break;
10287           }
10288         case MED_INT32:
10289           {
10290             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10291             break;
10292           }
10293         default:
10294           {
10295             std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10296             throw INTERP_KERNEL::Exception(oss.str());
10297           }
10298       }
10299     }
10300   loadAllGlobals(fid);
10301 }
10302 catch(INTERP_KERNEL::Exception& e)
10303 {
10304     throw e;
10305 }
10306
10307 void MEDFileFields::writeLL(med_idt fid) const
10308 {
10309   int i=0;
10310   writeGlobals(fid,*this);
10311   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10312     {
10313       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10314       if(!elt)
10315         {
10316           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10317           throw INTERP_KERNEL::Exception(oss.str());
10318         }
10319       elt->writeLL(fid,*this);
10320     }
10321 }
10322
10323 /*!
10324  * This method alloc the arrays and load potentially huge arrays contained in this field.
10325  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10326  * This method can be also called to refresh or reinit values from a file.
10327  * 
10328  * \throw If the fileName is not set or points to a non readable MED file.
10329  */
10330 void MEDFileFields::loadArrays()
10331 {
10332   if(getFileName().empty())
10333     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10334   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10335   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10336     {
10337       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10338       if(elt)
10339         elt->loadBigArraysRecursively(fid,*elt);
10340     }
10341 }
10342
10343 /*!
10344  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10345  * But once data loaded once, this method does nothing.
10346  * 
10347  * \throw If the fileName is not set or points to a non readable MED file.
10348  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10349  */
10350 void MEDFileFields::loadArraysIfNecessary()
10351 {
10352   if(!getFileName().empty())
10353     {
10354       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10355       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10356         {
10357           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10358           if(elt)
10359             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10360         }
10361     }
10362 }
10363
10364 /*!
10365  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10366  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10367  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10368  * 
10369  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10370  */
10371 void MEDFileFields::unloadArrays()
10372 {
10373   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10374     {
10375       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10376       if(elt)
10377         elt->unloadArrays();
10378     }
10379 }
10380
10381 /*!
10382  * 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.
10383  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10384  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10385  * 
10386  * \sa MEDFileFields::loadArraysIfNecessary
10387  */
10388 void MEDFileFields::unloadArraysWithoutDataLoss()
10389 {
10390   if(!getFileName().empty())
10391     unloadArrays();
10392 }
10393
10394 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10395 {
10396   std::vector<std::string> ret;
10397   std::set<std::string> ret2;
10398   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10399     {
10400       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10401       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10402         if(ret2.find(*it2)==ret2.end())
10403           {
10404             ret.push_back(*it2);
10405             ret2.insert(*it2);
10406           }
10407     }
10408   return ret;
10409 }
10410
10411 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10412 {
10413   std::vector<std::string> ret;
10414   std::set<std::string> ret2;
10415   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10416     {
10417       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10418       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10419         if(ret2.find(*it2)==ret2.end())
10420           {
10421             ret.push_back(*it2);
10422             ret2.insert(*it2);
10423           }
10424     }
10425   return ret;
10426 }
10427
10428 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10429 {
10430   std::vector<std::string> ret;
10431   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10432     {
10433       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10434       ret.insert(ret.end(),tmp.begin(),tmp.end());
10435     }
10436   return ret;
10437 }
10438
10439 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10440 {
10441   std::vector<std::string> ret;
10442   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10443     {
10444       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10445       ret.insert(ret.end(),tmp.begin(),tmp.end());
10446     }
10447   return ret;
10448 }
10449
10450 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10451 {
10452   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10453     (*it)->changePflsRefsNamesGen2(mapOfModif);
10454 }
10455
10456 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10457 {
10458   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10459     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10460 }
10461
10462 void MEDFileFields::resize(int newSize)
10463 {
10464   _fields.resize(newSize);
10465 }
10466
10467 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10468 {
10469   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10470     pushField(*it);
10471 }
10472
10473 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10474 {
10475   if(!field)
10476     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10477   _fields.push_back(field->getContent());
10478   appendGlobs(*field,1e-12);
10479 }
10480
10481 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10482 {
10483   if(!field)
10484     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10485   if(i>=(int)_fields.size())
10486     _fields.resize(i+1);
10487   _fields[i]=field->getContent();
10488   appendGlobs(*field,1e-12);
10489 }
10490
10491 void MEDFileFields::destroyFieldAtPos(int i)
10492 {
10493   destroyFieldsAtPos(&i,&i+1);
10494 }
10495
10496 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10497 {
10498   std::vector<bool> b(_fields.size(),true);
10499   for(const int *i=startIds;i!=endIds;i++)
10500     {
10501       if(*i<0 || *i>=(int)_fields.size())
10502         {
10503           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10504           throw INTERP_KERNEL::Exception(oss.str());
10505         }
10506       b[*i]=false;
10507     }
10508   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10509   std::size_t j=0;
10510   for(std::size_t i=0;i<_fields.size();i++)
10511     if(b[i])
10512       fields[j++]=_fields[i];
10513   _fields=fields;
10514 }
10515
10516 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10517 {
10518   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10519   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10520   std::vector<bool> b(_fields.size(),true);
10521   int k=bg;
10522   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10523     {
10524       if(k<0 || k>=(int)_fields.size())
10525         {
10526           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10527           throw INTERP_KERNEL::Exception(oss.str());
10528         }
10529       b[k]=false;
10530     }
10531   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10532   std::size_t j(0);
10533   for(std::size_t i=0;i<_fields.size();i++)
10534     if(b[i])
10535       fields[j++]=_fields[i];
10536   _fields=fields;
10537 }
10538
10539 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10540 {
10541   bool ret(false);
10542   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10543     {
10544       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10545       if(cur)
10546         ret=cur->changeMeshNames(modifTab) || ret;
10547     }
10548   return ret;
10549 }
10550
10551 /*!
10552  * \param [in] meshName the name of the mesh that will be renumbered.
10553  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10554  *             This code corresponds to the distribution of types in the corresponding mesh.
10555  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10556  * \param [in] renumO2N the old to new renumber array.
10557  * \return If true a renumbering has been performed. The structure in \a this has been modified. If false, nothing has been done: it is typically the case if \a meshName is not refered by any 
10558  *         field in \a this.
10559  */
10560 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10561 {
10562   bool ret(false);
10563   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10564     {
10565       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10566       if(fmts)
10567         {
10568           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10569         }
10570     }
10571   return ret;
10572 }
10573
10574 /*!
10575  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10576  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10577  *
10578  * \return A new object that the caller is responsible to deallocate.
10579  */
10580 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10581 {
10582   if(!mm)
10583     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10584   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10585   int nbFields(getNumberOfFields());
10586   for(int i=0;i<nbFields;i++)
10587     {
10588       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10589       if(!fmts)
10590         {
10591           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10592           throw INTERP_KERNEL::Exception(oss.str());
10593         }
10594       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10595       fsOut->pushField(fmtsOut);
10596     }
10597   return fsOut.retn();
10598 }
10599
10600 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10601 {
10602   if(i<0 || i>=(int)_fields.size())
10603     {
10604       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10605       throw INTERP_KERNEL::Exception(oss.str());
10606     }
10607   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10608   if(!fmts)
10609     return 0;
10610   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10611   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10612   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10613   if(fmtsC)
10614     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10615   else if(fmtsC2)
10616     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10617   else
10618     {
10619       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10620       throw INTERP_KERNEL::Exception(oss.str());
10621     }
10622   ret->shallowCpyGlobs(*this);
10623   return ret.retn();
10624 }
10625
10626 /*!
10627  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10628  * This method is accessible in python using __getitem__ with a list in input.
10629  * \return a new object that the caller should deal with.
10630  */
10631 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10632 {
10633   MCAuto<MEDFileFields> ret=shallowCpy();
10634   std::size_t sz=std::distance(startIds,endIds);
10635   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10636   int j=0;
10637   for(const int *i=startIds;i!=endIds;i++,j++)
10638     {
10639       if(*i<0 || *i>=(int)_fields.size())
10640         {
10641           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10642           throw INTERP_KERNEL::Exception(oss.str());
10643         }
10644       fields[j]=_fields[*i];
10645     }
10646   ret->_fields=fields;
10647   return ret.retn();
10648 }
10649
10650 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10651 {
10652   return getFieldAtPos(getPosFromFieldName(fieldName));
10653 }
10654
10655 /*!
10656  * This method removes, if any, fields in \a this having no time steps.
10657  * If there is one or more than one such field in \a this true is returned and those fields will not be referenced anymore in \a this.
10658  * 
10659  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10660  */
10661 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10662 {
10663   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10664   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10665     {
10666       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10667       if(elt)
10668         {
10669           if(elt->getNumberOfTS()>0)
10670             newFields.push_back(*it);
10671         }
10672     }
10673   if(_fields.size()==newFields.size())
10674     return false;
10675   _fields=newFields;
10676   return true;
10677 }
10678
10679 /*!
10680  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10681  * This method can be seen as a filter applied on \a this, that returns an object containing
10682  * reduced the list of fields compared to those in \a this. The returned object is a new object but the object on which it lies are only
10683  * shallow copied from \a this.
10684  * 
10685  * \param [in] meshName - the name of the mesh on w
10686  * \return a new object that the caller should deal with.
10687  */
10688 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10689 {
10690   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10691   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10692     {
10693       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10694       if(!cur)
10695         continue;
10696       if(cur->getMeshName()==meshName)
10697         {
10698           cur->incrRef();
10699           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10700           ret->_fields.push_back(cur2);
10701         }
10702     }
10703   ret->shallowCpyOnlyUsedGlobs(*this);
10704   return ret.retn();
10705 }
10706
10707 /*!
10708  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10709  * Input time steps are specified using a pair of integer (iteration, order).
10710  * This method can be seen as a filter applied on \a this, that returns an object containing the same number of fields than those in \a this,
10711  * but for each multitimestep only the time steps in \a timeSteps are kept.
10712  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10713  * 
10714  * The returned object points to shallow copy of elements in \a this.
10715  * 
10716  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10717  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10718  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10719  */
10720 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10721 {
10722   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10723   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10724     {
10725       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10726       if(!cur)
10727         continue;
10728       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10729       ret->_fields.push_back(elt);
10730     }
10731   ret->shallowCpyOnlyUsedGlobs(*this);
10732   return ret.retn();
10733 }
10734
10735 /*!
10736  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10737  */
10738 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10739 {
10740   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10741   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10742     {
10743       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10744       if(!cur)
10745         continue;
10746       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10747       if(elt->getNumberOfTS()!=0)
10748         ret->_fields.push_back(elt);
10749     }
10750   ret->shallowCpyOnlyUsedGlobs(*this);
10751   return ret.retn();
10752 }
10753
10754 MEDFileFieldsIterator *MEDFileFields::iterator()
10755 {
10756   return new MEDFileFieldsIterator(this);
10757 }
10758
10759 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10760 {
10761   std::string tmp(fieldName);
10762   std::vector<std::string> poss;
10763   for(std::size_t i=0;i<_fields.size();i++)
10764     {
10765       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10766       if(f)
10767         {
10768           std::string fname(f->getName());
10769           if(tmp==fname)
10770             return i;
10771           else
10772             poss.push_back(fname);
10773         }
10774     }
10775   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10776   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10777   oss << " !";
10778   throw INTERP_KERNEL::Exception(oss.str());
10779 }
10780
10781 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10782 {
10783   if(fs)
10784     {
10785       fs->incrRef();
10786       _nb_iter=fs->getNumberOfFields();
10787     }
10788 }
10789
10790 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10791 {
10792 }
10793
10794 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10795 {
10796   if(_iter_id<_nb_iter)
10797     {
10798       MEDFileFields *fs(_fs);
10799       if(fs)
10800         return fs->getFieldAtPos(_iter_id++);
10801       else
10802         return 0;
10803     }
10804   else
10805     return 0;
10806 }