]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Management of pfls
[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 "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
34
35 #include <algorithm>
36 #include <iterator>
37
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
42
43 using namespace MEDCoupling;
44
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
47
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
50
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
52 {
53   return new MEDFileFieldLoc(fid,locName);
54 }
55
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
57 {
58   return new MEDFileFieldLoc(fid,id);
59 }
60
61 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)
62 {
63   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
64 }
65
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
67 {
68   med_geometry_type geotype;
69   med_geometry_type sectiongeotype;
70   int nsectionmeshcell;
71   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
74   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76   _nb_node_per_cell=cm.getNumberOfNodes();
77   _ref_coo.resize(_dim*_nb_node_per_cell);
78   _gs_coo.resize(_dim*_nb_gauss_pt);
79   _w.resize(_nb_gauss_pt);
80   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
81 }
82
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
84 {
85   med_geometry_type geotype;
86   med_geometry_type sectiongeotype;
87   int nsectionmeshcell;
88   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
92   _name=locName;
93   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95   _nb_node_per_cell=cm.getNumberOfNodes();
96   _ref_coo.resize(_dim*_nb_node_per_cell);
97   _gs_coo.resize(_dim*_nb_gauss_pt);
98   _w.resize(_nb_gauss_pt);
99   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
100 }
101
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103                                  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),
104                                      _w(w)
105 {
106   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107   _dim=cm.getDimension();
108   _nb_node_per_cell=cm.getNumberOfNodes();
109   _nb_gauss_pt=_w.size();
110 }
111
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
113 {
114   return new MEDFileFieldLoc(*this);
115 }
116
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
118 {
119   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
120 }
121
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
123 {
124   return std::vector<const BigMemoryObject *>();
125 }
126
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
128 {
129   static const char OFF7[]="\n    ";
130   oss << "\"" << _name << "\"" << OFF7;
131   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132   oss << "Dimension=" << _dim << OFF7;
133   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
138 }
139
140 void MEDFileFieldLoc::setName(const std::string& name)
141 {
142   _name=name;
143 }
144
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
146 {
147   if(_name!=other._name)
148     return false;
149   if(_dim!=other._dim)
150     return false;
151   if(_nb_gauss_pt!=other._nb_gauss_pt)
152     return false;
153   if(_nb_node_per_cell!=other._nb_node_per_cell)
154     return false;
155   if(_geo_type!=other._geo_type)
156     return false;
157   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
158     return false;
159   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
160     return false;
161   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162     return false;
163
164   return true;
165 }
166
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
168 {
169   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);
170 }
171
172 std::string MEDFileFieldLoc::repr() const
173 {
174   std::ostringstream oss; oss.precision(15);
175   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
177   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
178   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
179   oss << "\n  - Ref coords are : ";
180   int sz=_ref_coo.size();
181   if(sz%_dim==0)
182     {
183       int nbOfTuples=sz/_dim;
184       for(int i=0;i<nbOfTuples;i++)
185         {
186           oss << "(";
187           for(int j=0;j<_dim;j++)
188             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
189           oss << ") ";
190         }
191     }
192   else
193     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194   oss << "\n  - Gauss coords in reference element : ";
195   sz=_gs_coo.size();
196   if(sz%_dim==0)
197     {
198       int nbOfTuples=sz/_dim;
199       for(int i=0;i<nbOfTuples;i++)
200         {
201           oss << "(";
202           for(int j=0;j<_dim;j++)
203             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
204           oss << ") ";
205         }
206     }
207   else
208     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
210   return oss.str();
211 }
212
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
214 {
215   _type=field->getTypeOfField();
216   _start=start;
217   switch(_type)
218   {
219     case ON_CELLS:
220       {
221         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222         _end=_start+nbOfCells;
223         _nval=nbOfCells;
224         break;
225       }
226     case ON_GAUSS_NE:
227       {
228         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229         const int *arrPtr=arr->getConstPointer();
230         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232         _nval=nbOfCells;
233         break;
234       }
235     case ON_GAUSS_PT:
236       {
237         const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238         const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239         const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
240         if(!disc2)
241           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242         const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243         MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244         const int *dai2Ptr(dai2->getConstPointer());
245         int nbi(gsLoc.getWeights().size());
246         MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247         MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248         const int *da3Ptr(da3->getConstPointer());
249         if(da3->getNumberOfTuples()!=nbOfCells)
250           {//profile : for gauss even in NoProfile !!!
251             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
252             _profile=oss.str();
253             da3->setName(_profile.c_str());
254             glob.appendProfile(da3);
255           }
256         MCAuto<DataArrayInt> da4(DataArrayInt::New());
257         _nval=da3->getNbOfElems();
258         da4->alloc(_nval*nbi,1);
259         int *da4Ptr(da4->getPointer());
260         for(int i=0;i<_nval;i++)
261           {
262             int ref=dai2Ptr[offset+da3Ptr[i]];
263             for(int j=0;j<nbi;j++)
264               *da4Ptr++=ref+j;
265           }
266         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267         _localization=oss2.str();
268         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269         _end=_start+_nval*nbi;
270         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
271         break;
272       }
273     default:
274       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275   }
276   start=_end;
277 }
278
279 /*!
280  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281  * \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).
282  * \param [in] multiTypePfl is the end user profile specified in high level API
283  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284  * \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.
285  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286  * \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.
287  */
288 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)
289 {
290   _profile.clear();
291   _type=field->getTypeOfField();
292   std::string pflName(multiTypePfl->getName());
293   std::ostringstream oss; oss << pflName;
294   if(_type!=ON_NODES)
295     {
296       if(!isPflAlone)
297         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
298     }
299   else
300     { oss << "_NODE"; }
301   if(locIds)
302     {
303       if(pflName.empty())
304         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305       if(_type!=ON_GAUSS_PT)
306         {
307           locIds->setName(oss.str());
308           glob.appendProfile(locIds);
309           _profile=oss.str();
310         }
311     }
312   _start=start;
313   switch(_type)
314   {
315     case ON_NODES:
316       {
317         _nval=idsInPfl->getNumberOfTuples();
318         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
319         _end=_start+_nval;
320         break;
321       }
322     case ON_CELLS:
323       {
324         _nval=idsInPfl->getNumberOfTuples();
325         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326         _end=_start+_nval;
327         break;
328       }
329     case ON_GAUSS_NE:
330       {
331         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334         arr3->computeOffsetsFull();
335         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336         int trueNval=tmp->getNumberOfTuples();
337         _nval=idsInPfl->getNumberOfTuples();
338         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339         _end=_start+trueNval;
340         break;
341       }
342     case ON_GAUSS_PT:
343       {
344         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
345         if(!disc2)
346           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
352         //
353         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
355         //
356         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
357         int trueNval=0;
358         for(const int *pt=da4->begin();pt!=da4->end();pt++)
359           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360         tmp->alloc(trueNval,1);
361         int *tmpPtr=tmp->getPointer();
362         for(const int *pt=da4->begin();pt!=da4->end();pt++)
363           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
364             *tmpPtr++=j;
365         //
366         _nval=da4->getNumberOfTuples();
367         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368         _end=_start+trueNval;
369         oss << "_loc_" << _loc_id;
370         if(locIds)
371           {
372             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373             da5->setName(oss.str());
374             glob.appendProfile(da5);
375             _profile=oss.str();
376           }
377         else
378           {
379             if(!da3->isIota(nbOfEltsInWholeMesh))
380               {
381                 da3->setName(oss.str());
382                 glob.appendProfile(da3);
383                 _profile=oss.str();
384               }
385           }
386         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387         _localization=oss2.str();
388         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
389         break;
390       }
391     default:
392       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
393   }
394   start=_end;
395 }
396
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
398 {
399   _start=start;
400   _nval=arrr->getNumberOfTuples();
401   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
402   _end=_start+_nval;
403   start=_end;
404 }
405
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
407 {
408   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
409 }
410
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
412 {
413   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
414 }
415
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
417 {
418   return new MEDFileFieldPerMeshPerTypePerDisc(other);
419 }
420
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
422 {
423   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
424 }
425
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
427 {
428   std::vector<const BigMemoryObject *> ret(1);
429   ret[0]=(const PartDefinition*)_pd;
430   return ret;
431 }
432
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
434 {
435   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
436   ret->_father=father;
437   return ret.retn();
438 }
439
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
442 {
443   if(pd)
444     pd->incrRef();
445 }
446 catch(INTERP_KERNEL::Exception& e)
447 {
448     throw e;
449 }
450
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
452 {
453 }
454
455 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)
456 {
457 }
458
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
461 {
462 }
463
464 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)
465 {
466   const PartDefinition *pd(_pd);
467   if(!pd)
468     {
469       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
470       int nbi,tmp1;
471       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472       if(_end-_start!=nbValsInFile*nbi)
473         {
474           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 !";
475           throw INTERP_KERNEL::Exception(oss.str());
476         }
477       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
478     }
479   else
480     {
481       if(!_profile.empty())
482         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
484       int profilesize,nbi;
485       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
487       if(spd)
488         {
489           int start,stop,step;
490           spd->getSlice(start,stop,step);
491           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492           med_filter filter=MED_FILTER_INIT;
493           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496                                    /*lastblocksize=useless because count=1*/0,&filter);
497           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498           MEDfilterClose(&filter);
499           return ;
500         }
501       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
502       if(dpd)
503         {
504           dpd->checkConsistencyLight();
505           MCAuto<DataArrayInt> myIds(dpd->toDAI());
506           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508           myIds->applyLin(1,-a);
509           int nbOfEltsToLoad(b-a+1);
510           med_filter filter=MED_FILTER_INIT;
511           {//TODO : manage int32 !
512             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517                                      /*lastblocksize=useless because count=1*/0,&filter);
518             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
522           }
523           MEDfilterClose(&filter);
524         }
525       else
526         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
527     }
528 }
529
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
531 {
532   return _father;
533 }
534
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
536 {
537   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539   std::string fieldName(nasc.getName()),meshName(getMeshName());
540   int iteration(getIteration()),order(getOrder()),profilesize,nbi;
541   TypeOfField type(getType());
542   med_geometry_type mgeoti;
543   med_entity_type menti;
544   _father->entriesForMEDfile(type,mgeoti,menti);
545   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
546   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
547   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
548   const PartDefinition *pd(_pd);
549   if(!pd)
550     {
551       _nval=zeNVal;
552     }
553   else
554     {
555       if(!_profile.empty())
556         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
557       _nval=pd->getNumberOfElems();
558     }
559   _start=start;
560   _end=start+_nval*nbi;
561   start=_end;
562   if(type==ON_CELLS && !_localization.empty())
563     {
564       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
565         setType(ON_GAUSS_PT);
566       else
567         {
568           setType(ON_GAUSS_NE);
569           _localization.clear();
570         }
571     }
572 }
573
574 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
575 {
576   std::string fieldName(nasc.getName()),meshName(getMeshName());
577   int iteration(getIteration()),order(getOrder());
578   TypeOfField type(getType());
579   med_geometry_type mgeoti;
580   med_entity_type menti;
581   _father->entriesForMEDfile(type,mgeoti,menti);
582   if(_start>_end)
583     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
584   if(_start==_end)
585     return ;
586   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
587   if(_start<0 || _start>=arr->getNumberOfTuples())
588     {
589       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
590       throw INTERP_KERNEL::Exception(oss.str());
591     }
592   if(_end<0 || _end>arr->getNumberOfTuples())
593     {
594       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
595       throw INTERP_KERNEL::Exception(oss.str());
596     }
597   int nbOfCompo(arr->getNumberOfComponents());
598   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
599   if(arrD)
600     {
601       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
602       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
603       return ;
604     }
605   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
606   if(arrI)
607     {
608       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
609       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
610       return ;
611     }
612   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
613 }
614
615 /*!
616  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
617  */
618 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
619 {
620   int delta=_end-_start;
621   _start=newValueOfStart;
622   _end=_start+delta;
623 }
624
625 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
626 {
627   return _father->getIteration();
628 }
629
630 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
631 {
632   return _father->getOrder();
633 }
634
635 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
636 {
637   return _father->getTime();
638 }
639
640 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
641 {
642   return _father->getMeshName();
643 }
644
645 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
646 {
647   const char startLine[]="    ## ";
648   std::string startLine2(bkOffset,' ');
649   startLine2+=startLine;
650   INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
651   oss << startLine2 << "Localization #" << id << "." << std::endl;
652   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
653   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
654   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
655   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
656 }
657
658 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
659 {
660   return _type;
661 }
662
663 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
664 {
665   return _father->getGeoType();
666 }
667
668 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
669 {
670   types.insert(_type);
671 }
672
673 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
674 {
675   _type=newType;
676 }
677
678 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
679 {
680   return _father->getNumberOfComponents();
681 }
682
683 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
684 {
685   return _end-_start;
686 }
687
688 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
689 {
690   return _father->getOrCreateAndGetArray();
691 }
692
693 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
694 {
695   const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
696   return fath->getOrCreateAndGetArray();
697 }
698
699 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
700 {
701   return _father->getInfo();
702 }
703
704 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
705 {
706   return _profile;
707 }
708
709 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
710 {
711   _profile=newPflName;
712 }
713
714 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
715 {
716   return _localization;
717 }
718
719 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
720 {
721   _localization=newLocName;
722 }
723
724 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
725 {
726   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
727     {
728       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
729         {
730           _profile=(*it2).second;
731           return;
732         }
733     }
734 }
735
736 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
737 {
738   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
739     {
740       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
741         {
742           _localization=(*it2).second;
743           return;
744         }
745     }
746 }
747
748 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
749 {
750   if(type!=_type)
751     return ;
752   dads.push_back(std::pair<int,int>(_start,_end));
753   geoTypes.push_back(getGeoType());
754   if(_profile.empty())
755     pfls.push_back(0);
756   else
757     {
758       pfls.push_back(glob->getProfile(_profile.c_str()));
759     }
760   if(_localization.empty())
761     locs.push_back(-1);
762   else
763     {
764       locs.push_back(glob->getLocalizationId(_localization.c_str()));
765     }
766 }
767
768 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
769 {
770   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));
771   startEntryId++;
772 }
773
774 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
775 {
776   TypeOfField type=getType();
777   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
778   med_geometry_type mgeoti;
779   med_entity_type menti;
780   _father->entriesForMEDfile(getType(),mgeoti,menti);
781   const DataArray *arr(getOrCreateAndGetArray());
782   if(!arr)
783     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
784   if(!arr->isAllocated())
785     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
786   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
787   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
788   const unsigned char *locToWrite=0;
789   if(arrD)
790     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
791   else if(arrI)
792     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
793   else
794     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
795   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
796                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
797                                                    locToWrite));
798 }
799
800 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
801 {
802   type=_type;
803   pfl=_profile;
804   loc=_localization;
805   dad.first=_start; dad.second=_end;
806 }
807
808 /*!
809  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
810  *             This code corresponds to the distribution of types in the corresponding mesh.
811  * \param [out] ptToFill memory zone where the output will be stored.
812  * \return the size of data pushed into output param \a ptToFill
813  */
814 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
815 {
816   _loc_id=offset;
817   std::ostringstream oss;
818   std::size_t nbOfType=codeOfMesh.size()/3;
819   int found=-1;
820   for(std::size_t i=0;i<nbOfType && found==-1;i++)
821     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
822       found=(int)i;
823   if(found==-1)
824     {
825       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
826       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
827       throw INTERP_KERNEL::Exception(oss.str());
828     }
829   int *work=ptToFill;
830   if(_profile.empty())
831     {
832       if(_nval!=codeOfMesh[3*found+1])
833         {
834           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
835           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
836           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
837           throw INTERP_KERNEL::Exception(oss.str());
838         }
839       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
840         *work++=ii;
841     }
842   else
843     {
844       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
845       if(pfl->getNumberOfTuples()!=_nval)
846         {
847           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
848           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
849           oss << _nval;
850           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
851           throw INTERP_KERNEL::Exception(oss.str());
852         }
853       int offset2=codeOfMesh[3*found+2];
854       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
855         {
856           if(*pflId<codeOfMesh[3*found+1])
857             *work++=offset2+*pflId;
858         }
859     }
860   return _nval;
861 }
862
863 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
864 {
865   for(int i=_start;i<_end;i++)
866     *ptToFill++=i;
867   return _end-_start;
868 }
869
870 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
871 {
872   switch(type)
873   {
874     case ON_CELLS:
875       return -2;
876     case ON_GAUSS_NE:
877       return -1;
878     case ON_GAUSS_PT:
879       return locId;
880     default:
881       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
882   }
883 }
884
885 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
886 {
887   int id=0;
888   std::map<std::pair<std::string,TypeOfField>,int> m;
889   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
890   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
891     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
892       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
893   ret.resize(id);
894   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
895     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
896   return ret;
897 }
898
899 /*!
900  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
901  * 
902  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
903  * \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.
904  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
905  * \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)
906  * \param [in,out] glob if necessary by the method, new profiles can be added to it
907  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
908  * \param [out] result All new entries will be appended on it.
909  * \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 !)
910  */
911 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
912                                                        const DataArrayInt *explicitIdsInMesh,
913                                                        const std::vector<int>& newCode,
914                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
915                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
916 {
917   if(entriesOnSameDisc.empty())
918     return false;
919   TypeOfField type=entriesOnSameDisc[0]->getType();
920   int szEntities=0,szTuples=0;
921   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
922     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
923   int nbi=szTuples/szEntities;
924   if(szTuples%szEntities!=0)
925     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
926   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
927   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
928   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
929   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
930   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
931   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
932   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
933   int id=0;
934   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
935     {
936       int startOfEltIdOfChunk=(*it)->_start;
937       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
938       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
939       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
940       //
941       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
942       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
943       //
944       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
945       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
946     }
947   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
948   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
949   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
950   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
951   //
952   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
953   //
954   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
955   arrPart->renumberInPlace(renumTupleIds->begin());
956   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
957   bool ret=false;
958   const int *idIt=diffVals->begin();
959   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
960   int offset2=0;
961   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
962     {
963       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
964       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
965       int nbEntityElts=subIds->getNumberOfTuples();
966       bool ret2;
967       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
968           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
969                                       offset+offset2,
970                                       li,glob,ret2);
971       ret=ret || ret2;
972       result.push_back(eltToAdd);
973       offset2+=nbEntityElts*nbi;
974     }
975   ret=ret || li.empty();
976   return ret;
977 }
978
979 /*!
980  * \param [in] typeF type of field of new chunk
981  * \param [in] geoType the geometric type of the chunk
982  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
983  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
984  * \param [in] nbi number of integration points
985  * \param [in] offset The offset in the **global array of data**.
986  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
987  *                 to the new chunk to create.
988  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
989  * \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
990  *              and corresponding entry erased from \a entriesOnSameDisc.
991  * \return a newly allocated chunk
992  */
993 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
994                                                                                                   bool isPfl, int nbi, int offset,
995                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
996                                                                                                   MEDFileFieldGlobsReal& glob,
997                                                                                                   bool &notInExisting)
998 {
999   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1000   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1001   for(;it!=entriesOnSameDisc.end();it++)
1002     {
1003       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1004         {
1005           if(!isPfl)
1006             {
1007               if((*it)->_profile.empty())
1008                 break;
1009               else
1010                 if(!(*it)->_profile.empty())
1011                   {
1012                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1013                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1014                       break;
1015                   }
1016             }
1017         }
1018     }
1019   if(it==entriesOnSameDisc.end())
1020     {
1021       notInExisting=true;
1022       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1023       ret->_type=typeF;
1024       ret->_loc_id=(int)geoType;
1025       ret->_nval=nbMeshEntities;
1026       ret->_start=offset;
1027       ret->_end=ret->_start+ret->_nval*nbi;
1028       if(isPfl)
1029         {
1030           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1031           glob.appendProfile(idsOfMeshElt);
1032           ret->_profile=idsOfMeshElt->getName();
1033         }
1034       //tony treatment of localization
1035       return ret;
1036     }
1037   else
1038     {
1039       notInExisting=false;
1040       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1041       ret->_loc_id=(int)geoType;
1042       ret->setNewStart(offset);
1043       entriesOnSameDisc.erase(it);
1044       return ret;
1045     }
1046
1047 }
1048
1049 ////////////////////////////////////
1050
1051 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1052  {
1053  }
1054
1055 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1056 {
1057   _father=father;
1058 }
1059
1060 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1061 {
1062   std::size_t i=0;
1063   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1064     {
1065       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1066         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1067     }
1068 }
1069
1070 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1071 {
1072   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1073 }
1074
1075 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1076 {
1077   std::vector<const BigMemoryObject *> ret;
1078   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1079     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1080   return ret;
1081 }
1082
1083 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1084 {
1085   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1088 }
1089
1090 /*!
1091  * This method is the most general one. No optimization is done here.
1092  * \param [in] multiTypePfl is the end user profile specified in high level API
1093  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094  * \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.
1095  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097  * \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.
1098  */
1099 void MEDFileFieldPerMeshPerTypeCommon::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)
1100 {
1101   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1104 }
1105
1106 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1107 {
1108   _field_pm_pt_pd.resize(1);
1109   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1111 }
1112
1113 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1114 {
1115   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116   if(!arr || !arr->isAllocated())
1117     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1118   _field_pm_pt_pd.resize(1);
1119   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120   _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.
1121 }
1122
1123 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1124 {
1125   TypeOfField type=field->getTypeOfField();
1126   if(type!=ON_GAUSS_PT)
1127     {
1128       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129       int sz=_field_pm_pt_pd.size();
1130       bool found=false;
1131       for(int j=0;j<sz && !found;j++)
1132         {
1133           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1134             {
1135               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136               found=true;
1137             }
1138         }
1139       if(!found)
1140         {
1141           _field_pm_pt_pd.resize(sz+1);
1142           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1143         }
1144       std::vector<int> ret(1,(int)sz);
1145       return ret;
1146     }
1147   else
1148     {
1149       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150       int sz2=ret2.size();
1151       std::vector<int> ret3(sz2);
1152       int k=0;
1153       for(int i=0;i<sz2;i++)
1154         {
1155           int sz=_field_pm_pt_pd.size();
1156           int locIdToFind=ret2[i];
1157           bool found=false;
1158           for(int j=0;j<sz && !found;j++)
1159             {
1160               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1161                 {
1162                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1163                   ret3[k++]=j;
1164                   found=true;
1165                 }
1166             }
1167           if(!found)
1168             {
1169               _field_pm_pt_pd.resize(sz+1);
1170               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1171               ret3[k++]=sz;
1172             }
1173         }
1174       return ret3;
1175     }
1176 }
1177
1178 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1179 {
1180   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1182   if(!disc2)
1183     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1185   if(!da)
1186     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189   if(retTmp->presenceOfValue(-1))
1190     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191   std::vector<int> ret(retTmp->begin(),retTmp->end());
1192   return ret;
1193 }
1194
1195 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1196 {
1197   TypeOfField type=field->getTypeOfField();
1198   if(type!=ON_GAUSS_PT)
1199     {
1200       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201       int sz=_field_pm_pt_pd.size();
1202       bool found=false;
1203       for(int j=0;j<sz && !found;j++)
1204         {
1205           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1206             {
1207               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1208               found=true;
1209             }
1210         }
1211       if(!found)
1212         {
1213           _field_pm_pt_pd.resize(sz+1);
1214           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1215         }
1216       std::vector<int> ret(1,0);
1217       return ret;
1218     }
1219   else
1220     {
1221       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222       int sz2=ret2.size();
1223       std::vector<int> ret3(sz2);
1224       int k=0;
1225       for(int i=0;i<sz2;i++)
1226         {
1227           int sz=_field_pm_pt_pd.size();
1228           int locIdToFind=ret2[i];
1229           bool found=false;
1230           for(int j=0;j<sz && !found;j++)
1231             {
1232               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1233                 {
1234                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1235                   ret3[k++]=j;
1236                   found=true;
1237                 }
1238             }
1239           if(!found)
1240             {
1241               _field_pm_pt_pd.resize(sz+1);
1242               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1243               ret3[k++]=sz;
1244             }
1245         }
1246       return ret3;
1247     }
1248 }
1249
1250 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1251 {
1252   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1254   if(!disc2)
1255     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1257   if(!da)
1258     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261   if(retTmp->presenceOfValue(-1))
1262     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263   std::vector<int> ret(retTmp->begin(),retTmp->end());
1264   return ret;
1265 }
1266
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1268 {
1269   return _father;
1270 }
1271
1272 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1273 {
1274   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1275   int curDim((int)cm.getDimension());
1276   if(dim!=std::numeric_limits<int>::max())
1277     {
1278       if(dim!=curDim)
1279         return false;
1280     }
1281   else
1282     dim=curDim;
1283   return true;
1284 }
1285
1286 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1287 {
1288   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1289     {
1290       (*it)->fillTypesOfFieldAvailable(types);
1291     }
1292 }
1293
1294 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1295 {
1296   int sz=_field_pm_pt_pd.size();
1297   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1298   for(int i=0;i<sz;i++)
1299     {
1300       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1301     }
1302 }
1303
1304 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1305 {
1306   return _father->getIteration();
1307 }
1308
1309 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1310 {
1311   return _father->getOrder();
1312 }
1313
1314 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1315 {
1316   return _father->getTime();
1317 }
1318
1319 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1320 {
1321   return _father->getMeshName();
1322 }
1323
1324 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1325 {
1326   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1327     {
1328       globalSz+=(*it)->getNumberOfTuples();
1329     }
1330   nbOfEntries+=(int)_field_pm_pt_pd.size();
1331 }
1332
1333 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1334 {
1335   return _father->getNumberOfComponents();
1336 }
1337
1338 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1339 {
1340   std::size_t nb(0);
1341   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1342     {
1343       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1344       if(fmtd)
1345         nb++;
1346     }
1347   return nb>1;
1348 }
1349
1350 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1351 {
1352   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1353   elt.takeRef(disc);
1354   _field_pm_pt_pd.push_back(elt);
1355 }
1356
1357 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1358 {
1359   return _father->getOrCreateAndGetArray();
1360 }
1361
1362 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1363 {
1364   const MEDFileFieldPerMesh *fath=_father;
1365   return fath->getOrCreateAndGetArray();
1366 }
1367
1368 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1369 {
1370   return _father->getInfo();
1371 }
1372
1373 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1374 {
1375   std::vector<std::string> ret;
1376   std::set<std::string> ret2;
1377   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1378     {
1379       std::string tmp=(*it1)->getProfile();
1380       if(!tmp.empty())
1381         if(ret2.find(tmp)==ret2.end())
1382           {
1383             ret.push_back(tmp);
1384             ret2.insert(tmp);
1385           }
1386     }
1387   return ret;
1388 }
1389
1390 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1391 {
1392   std::vector<std::string> ret;
1393   std::set<std::string> ret2;
1394   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1395     {
1396       std::string tmp=(*it1)->getLocalization();
1397       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1398         if(ret2.find(tmp)==ret2.end())
1399           {
1400             ret.push_back(tmp);
1401             ret2.insert(tmp);
1402           }
1403     }
1404   return ret;
1405 }
1406
1407 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1408 {
1409   std::vector<std::string> ret;
1410   std::set<std::string> ret2;
1411   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1412     {
1413       std::string tmp=(*it1)->getProfile();
1414       if(!tmp.empty())
1415         ret.push_back(tmp);
1416     }
1417   return ret;
1418 }
1419
1420 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1421 {
1422   std::vector<std::string> ret;
1423   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1424     {
1425       std::string tmp=(*it1)->getLocalization();
1426       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1427         ret.push_back(tmp);
1428     }
1429   return ret;
1430 }
1431
1432 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1433 {
1434   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1435     (*it1)->changePflsRefsNamesGen(mapOfModif);
1436 }
1437
1438 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1439 {
1440   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1441     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1442 }
1443
1444 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1445 {
1446   if(_field_pm_pt_pd.empty())
1447     {
1448       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1449       throw INTERP_KERNEL::Exception(oss.str());
1450     }
1451   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1452     return _field_pm_pt_pd[locId];
1453   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1454   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1455   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1456   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1457 }
1458
1459 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1460 {
1461   if(_field_pm_pt_pd.empty())
1462     {
1463       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1464       throw INTERP_KERNEL::Exception(oss.str());
1465     }
1466   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1467     return _field_pm_pt_pd[locId];
1468   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1469   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1470   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1471   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1472 }
1473
1474 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1475 {
1476   int i=0;
1477   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1478     {
1479       (*it)->fillValues(i,startEntryId,entries);
1480     }
1481 }
1482
1483 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1484 {
1485   _field_pm_pt_pd=leaves;
1486   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1487     (*it)->setFather(this);
1488 }
1489
1490 /*!
1491  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1492  *  \param [out] its - list of pair (start,stop) kept
1493  *  \return bool - false if the type of field \a tof is not contained in \a this.
1494  */
1495 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1496 {
1497   bool ret(false);
1498   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1499   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1500     if((*it)->getType()==tof)
1501       {
1502         newPmPtPd.push_back(*it);
1503         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1504         (*it)->setNewStart(globalNum);
1505         globalNum=(*it)->getEnd();
1506         its.push_back(bgEnd);
1507         ret=true;
1508       }
1509   if(ret)
1510     _field_pm_pt_pd=newPmPtPd;
1511   return ret;
1512 }
1513
1514 /*!
1515  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1516  *  \param [out] its - list of pair (start,stop) kept
1517  *  \return bool - false if the type of field \a tof is not contained in \a this.
1518  */
1519 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1520 {
1521   if(_field_pm_pt_pd.size()<=idOfDisc)
1522     return false;
1523   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1524   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1525   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1526   elt->setNewStart(globalNum);
1527   globalNum=elt->getEnd();
1528   its.push_back(bgEnd);
1529   _field_pm_pt_pd=newPmPtPd;
1530   return true;
1531 }
1532
1533 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1534 {
1535   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1537 }
1538
1539 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1540 {
1541   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542     (*it)->loadBigArray(fid,nasc);
1543 }
1544
1545 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1546 {
1547   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1548     {
1549       (*it)->copyOptionsFrom(*this);
1550       (*it)->writeLL(fid,nasc);
1551     }
1552 }
1553
1554 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1555 {
1556   switch(ikType)
1557   {
1558     case ON_CELLS:
1559       medfGeoType=typmai3[(int)ikGeoType];
1560       return MED_CELL;
1561     case ON_NODES:
1562       medfGeoType=MED_NONE;
1563       return MED_NODE;
1564     case ON_GAUSS_NE:
1565       medfGeoType=typmai3[(int)ikGeoType];
1566       return MED_NODE_ELEMENT;
1567     case ON_GAUSS_PT:
1568       medfGeoType=typmai3[(int)ikGeoType];
1569       return MED_CELL;
1570     default:
1571       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1572   }
1573   return MED_UNDEF_ENTITY_TYPE;
1574 }
1575
1576 //////////////////////////////////////////////////
1577
1578 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1579 {
1580   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1581 }
1582
1583 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1584 {
1585   return new MEDFileFieldPerMeshPerType(fath,geoType);
1586 }
1587
1588 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1589 {
1590   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1591   ret->setFather(father);
1592   ret->deepCopyElements();
1593   return ret.retn();
1594 }
1595
1596 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
1597 {
1598   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1599     {
1600       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1601       if(meshDim!=(int)cm.getDimension())
1602         return ;
1603     }
1604   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1605     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1606 }
1607
1608 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1609 {
1610   return _geo_type;
1611 }
1612
1613 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1614 {
1615   ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1616 }
1617
1618 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1619 {
1620   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1621   int curDim((int)cm.getDimension());
1622   dim=std::max(dim,curDim);
1623 }
1624
1625 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1626 {
1627   const char startLine[]="  ## ";
1628   std::string startLine2(bkOffset,' ');
1629   std::string startLine3(startLine2);
1630   startLine3+=startLine;
1631   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1632     {
1633       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1634       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1635     }
1636   else
1637     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1638   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1639   int i=0;
1640   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1641     {
1642       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1643       if(cur)
1644         cur->simpleRepr(bkOffset,oss,i);
1645       else
1646         {
1647           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1648         }
1649     }
1650 }
1651
1652 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1653 {
1654   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1655   return std::string(cm.getRepr());
1656 }
1657
1658 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1659 {
1660 }
1661
1662 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1663 {
1664   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1665   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1666   med_geometry_type mgeoti;
1667   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1668   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1669   _field_pm_pt_pd.resize(nbProfiles);
1670   for(int i=0;i<nbProfiles;i++)
1671     {
1672       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1673     }
1674   if(type==ON_CELLS)
1675     {
1676       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1677       for(int i=0;i<nbProfiles2;i++)
1678         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1679     }
1680 }
1681
1682 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)
1683 {
1684   MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1685   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1686   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1687     {
1688       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1689         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1690     }
1691   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1692     {
1693       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1694       ret->_field_pm_pt_pd.push_back(agg);
1695     }
1696   return ret;
1697 }
1698
1699 //////////////////////////////////////////////////
1700
1701 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1702 {
1703   if(!entities)
1704     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1705   const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1706   if(!entities2)
1707     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1708   const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1709   return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1710 }
1711
1712 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1713 {
1714   _se.takeRef(se);
1715   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1716   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1717   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1718   _field_pm_pt_pd.resize(nbProfiles);
1719   for(int i=0;i<nbProfiles;i++)
1720     {
1721       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1722     }
1723 }
1724
1725 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1726 {
1727   return _se->getDynGT();
1728 }
1729
1730 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1731 {
1732   return _se->getName();
1733 }
1734
1735 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1736 {
1737   throw INTERP_KERNEL::Exception("not implemented yet !");
1738 }
1739
1740 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1741 {
1742   gt=getDynGT();
1743   ent=MED_STRUCT_ELEMENT;
1744 }
1745
1746 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1747 {
1748   throw INTERP_KERNEL::Exception("not implemented yet !");
1749 }
1750
1751 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1752 {
1753   const char startLine[]="  ## ";
1754   std::string startLine2(bkOffset,' ');
1755   std::string startLine3(startLine2);
1756   startLine3+=startLine;
1757   oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1758   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1759   int i=0;
1760   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1761     {
1762       if((*it).isNotNull())
1763         (*it)->simpleRepr(bkOffset,oss,i);
1764       else
1765         {
1766           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1767         }
1768     }
1769 }
1770
1771 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1772 {
1773   throw INTERP_KERNEL::Exception("not implemented yet !");
1774 }
1775
1776 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1777 {
1778   MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1779   ret->setFather(father);
1780   ret->deepCopyElements();
1781   return ret.retn();
1782 }
1783
1784 void MEDFileFieldPerMeshPerTypeDyn::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
1785 {
1786   throw INTERP_KERNEL::Exception("not implemented yet !");
1787 }
1788
1789 //////////////////////////////////////////////////
1790
1791 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1792 {
1793   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1794 }
1795
1796 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1797 {
1798   return new MEDFileFieldPerMesh(fath,mesh);
1799 }
1800
1801 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1802 {
1803   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1804 }
1805
1806 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1807 {
1808   std::vector<const BigMemoryObject *> ret;
1809   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1810     ret.push_back(*it);
1811   return ret;
1812 }
1813
1814 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1815 {
1816   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1817   ret->_father=father;
1818   std::size_t i=0;
1819   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1820     {
1821       if((*it).isNotNull())
1822         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1823     }
1824   return ret.retn();
1825 }
1826
1827 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1828 {
1829   std::string startLine(bkOffset,' ');
1830   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1831   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1832   int i=0;
1833   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1834     {
1835       if((*it).isNotNull())
1836         (*it)->simpleRepr(bkOffset,oss,i);
1837       else
1838         {
1839           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1840         }
1841     }
1842 }
1843
1844 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1845 {
1846   _mesh_name=mesh->getName();
1847   mesh->getTime(_mesh_iteration,_mesh_order);
1848 }
1849
1850 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1851 {
1852   int nbOfTypes=code.size()/3;
1853   int offset=0;
1854   for(int i=0;i<nbOfTypes;i++)
1855     {
1856       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1857       int nbOfCells=code[3*i+1];
1858       int pos=addNewEntryIfNecessary(type);
1859       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1860       offset+=nbOfCells;
1861     }
1862 }
1863
1864 /*!
1865  * This method is the most general one. No optimization is done here.
1866  * \param [in] multiTypePfl is the end user profile specified in high level API
1867  * \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].
1868  * \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.
1869  * \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.
1870  * \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.
1871  * \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.
1872  */
1873 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)
1874 {
1875   int nbOfTypes(code.size()/3);
1876   for(int i=0;i<nbOfTypes;i++)
1877     {
1878       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1879       int pos=addNewEntryIfNecessary(type);
1880       DataArrayInt *pfl=0;
1881       if(code[3*i+2]!=-1)
1882         pfl=idsPerType[code[3*i+2]];
1883       int nbOfTupes2=code2.size()/3;
1884       int found=0;
1885       for(;found<nbOfTupes2;found++)
1886         if(code[3*i]==code2[3*found])
1887           break;
1888       if(found==nbOfTupes2)
1889         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1890       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1891     }
1892 }
1893
1894 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1895 {
1896   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1897   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1898 }
1899
1900 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1901 {
1902   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1903   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1904 }
1905
1906 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1907 {
1908   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1909     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1910 }
1911
1912 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1913 {
1914   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1915     (*it)->loadBigArraysRecursively(fid,nasc);
1916 }
1917
1918 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1919 {
1920   int nbOfTypes=_field_pm_pt.size();
1921   for(int i=0;i<nbOfTypes;i++)
1922     {
1923       _field_pm_pt[i]->copyOptionsFrom(*this);
1924       _field_pm_pt[i]->writeLL(fid,nasc);
1925     }
1926 }
1927
1928 void MEDFileFieldPerMesh::getDimension(int& dim) const
1929 {
1930   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1931     (*it)->getDimension(dim);
1932 }
1933
1934 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1935 {
1936   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1937     if(!(*it)->isUniqueLevel(dim))
1938       return false;
1939   return true;
1940 }
1941
1942 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1943 {
1944   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1945     (*it)->fillTypesOfFieldAvailable(types);
1946 }
1947
1948 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
1949 {
1950   int sz=_field_pm_pt.size();
1951   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1952   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1953   for(int i=0;i<sz;i++)
1954     {
1955       types[i]=_field_pm_pt[i]->getGeoType();
1956       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1957     }
1958   return ret;
1959 }
1960
1961 double MEDFileFieldPerMesh::getTime() const
1962 {
1963   int tmp1,tmp2;
1964   return _father->getTime(tmp1,tmp2);
1965 }
1966
1967 int MEDFileFieldPerMesh::getIteration() const
1968 {
1969   return _father->getIteration();
1970 }
1971
1972 int MEDFileFieldPerMesh::getOrder() const
1973 {
1974   return _father->getOrder();
1975 }
1976
1977 int MEDFileFieldPerMesh::getNumberOfComponents() const
1978 {
1979   return _father->getNumberOfComponents();
1980 }
1981
1982 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1983 {
1984   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1985     {
1986       if((*it).isNull())
1987         continue;
1988       if((*it)->presenceOfMultiDiscPerGeoType())
1989         return true;
1990     }
1991   return false;
1992 }
1993
1994 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1995 {
1996   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1997     if((*it).isNotNull())
1998       {
1999         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2000         if(pt)
2001           return true;
2002       }
2003   return false;
2004 }
2005
2006 bool MEDFileFieldPerMesh::onlyStructureElements() const
2007 {
2008   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2009     if((*it).isNotNull())
2010       {
2011         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2012         if(!pt)
2013           return false;
2014       }
2015   return true;
2016 }
2017
2018 void MEDFileFieldPerMesh::killStructureElements()
2019 {
2020   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2021   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2022     {
2023       if((*it).isNotNull())
2024         {
2025           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2026           if(!pt)
2027             res.push_back(*it);
2028         }
2029     }
2030   _field_pm_pt=res;
2031 }
2032
2033 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2034 {
2035   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2036   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2037     {
2038       if((*it).isNotNull())
2039         {
2040           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2041           if(pt)
2042             res.push_back(*it);
2043         }
2044     }
2045   _field_pm_pt=res;
2046 }
2047
2048 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2049 {
2050   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2051   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2052     {
2053       if((*it).isNotNull())
2054         {
2055           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2056           if(!pt)
2057             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2058           if(pt->getModelName()==seName)
2059             res.push_back(*it);
2060         }
2061     }
2062   _field_pm_pt=res;
2063 }
2064
2065 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2066 {
2067   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2068     {
2069       if((*it).isNotNull())
2070         {
2071           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2072           if(pt)
2073             {
2074               ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2075             }
2076           else
2077             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2078         }
2079     }
2080 }
2081
2082 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2083 {
2084   if(!_father)
2085     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2086   return _father->getOrCreateAndGetArray();
2087 }
2088
2089 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2090 {
2091   if(!_father)
2092     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2093   return _father->getOrCreateAndGetArray();
2094 }
2095
2096 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2097 {
2098   return _father->getInfo();
2099 }
2100
2101 /*!
2102  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2103  * 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.
2104  * It returns 2 output vectors :
2105  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2106  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2107  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2108  */
2109 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)
2110 {
2111   int notNullPflsSz=0;
2112   int nbOfArrs=geoTypes.size();
2113   for(int i=0;i<nbOfArrs;i++)
2114     if(pfls[i])
2115       notNullPflsSz++;
2116   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2117   int nbOfDiffGeoTypes=geoTypes3.size();
2118   code.resize(3*nbOfDiffGeoTypes);
2119   notNullPfls.resize(notNullPflsSz);
2120   notNullPflsSz=0;
2121   int j=0;
2122   for(int i=0;i<nbOfDiffGeoTypes;i++)
2123     {
2124       int startZone=j;
2125       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2126       std::vector<const DataArrayInt *> notNullTmp;
2127       if(pfls[j])
2128         notNullTmp.push_back(pfls[j]);
2129       j++;
2130       for(;j<nbOfArrs;j++)
2131         if(geoTypes[j]==refType)
2132           {
2133             if(pfls[j])
2134               notNullTmp.push_back(pfls[j]);
2135           }
2136         else
2137           break;
2138       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2139       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2140       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2141       code[3*i]=(int)refType;
2142       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2143       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2144       if(notNullTmp.empty())
2145         code[3*i+2]=-1;
2146       else
2147         {
2148           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2149           code[3*i+2]=notNullPflsSz++;
2150         }
2151     }
2152 }
2153
2154 /*!
2155  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2156  */
2157 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)
2158 {
2159   int sz=dads.size();
2160   int ret=0;
2161   for(int i=0;i<sz;i++)
2162     {
2163       if(locs[i]==-1)
2164         {
2165           if(type!=ON_GAUSS_NE)
2166             ret+=dads[i].second-dads[i].first;
2167           else
2168             {
2169               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2170               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2171             }
2172         }
2173       else
2174         {
2175           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2176           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2177         }
2178     }
2179   return ret;
2180 }
2181
2182 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2183 {
2184   std::vector<std::string> ret;
2185   std::set<std::string> ret2;
2186   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2187     {
2188       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2189       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2190         if(ret2.find(*it2)==ret2.end())
2191           {
2192             ret.push_back(*it2);
2193             ret2.insert(*it2);
2194           }
2195     }
2196   return ret;
2197 }
2198
2199 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2200 {
2201   std::vector<std::string> ret;
2202   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2203     {
2204       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2205       ret.insert(ret.end(),tmp.begin(),tmp.end());
2206     }
2207   return ret;
2208 }
2209
2210 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2211 {
2212   std::vector<std::string> ret;
2213   std::set<std::string> ret2;
2214   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2215     {
2216       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2217       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2218         if(ret2.find(*it2)==ret2.end())
2219           {
2220             ret.push_back(*it2);
2221             ret2.insert(*it2);
2222           }
2223     }
2224   return ret;
2225 }
2226
2227 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2228 {
2229   std::vector<std::string> ret;
2230   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2231     {
2232       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2233       ret.insert(ret.end(),tmp.begin(),tmp.end());
2234     }
2235   return ret;
2236 }
2237
2238 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2239 {
2240   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2241     {
2242       if((*it).first==_mesh_name)
2243         {
2244           _mesh_name=(*it).second;
2245           return true;
2246         }
2247     }
2248   return false;
2249 }
2250
2251 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2252 {
2253   if(_field_pm_pt.size()!=1)
2254     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2255   if(_field_pm_pt[0].isNull())
2256     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2257   MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2258   if(!pt)
2259     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2260   if(pt->getNumberOfLoc()!=1)
2261     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2262   const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2263   if(!disc)
2264     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2265   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2266   disc2->setType(ON_NODES);
2267   MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2268   disc2->setFather(pt2);
2269   pt2->setFather(this);
2270   pt2->pushDiscretization(disc2);
2271   _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2272 }
2273
2274 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2275                                                       MEDFileFieldGlobsReal& glob)
2276 {
2277   if(_mesh_name!=meshName)
2278     return false;
2279   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2280   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2281   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2282   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2283   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2284   getUndergroundDataArrayExt(entries);
2285   DataArray *arr0(getOrCreateAndGetArray());//tony
2286   if(!arr0)
2287     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2288   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2289   if(!arr0)
2290     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2291   int sz=0;
2292   if(!arr)
2293     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2294   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2295     {
2296       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2297         {
2298           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2299           sz+=(*it).second.second-(*it).second.first;
2300         }
2301       else
2302         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2303     }
2304   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2305   ////////////////////
2306   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2307   int *workI2=explicitIdsOldInMesh->getPointer();
2308   int sz1=0,sz2=0,sid=1;
2309   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2310   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2311   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2312     {
2313       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2314       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2315       int *workI=explicitIdsOldInArr->getPointer();
2316       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2317         {
2318           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2319           (*itL2)->setLocId(sz2);
2320           (*itL2)->_tmp_work1=(*itL2)->getStart();
2321           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2322         }
2323       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2324     }
2325   explicitIdsOldInMesh->reAlloc(sz2);
2326   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2327   ////////////////////
2328   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2329   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2330   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2331   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2332     {
2333       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2334       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2335       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2336     }
2337   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2338   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2339   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2340     {
2341       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2342       int newStart=elt->getLocId();
2343       elt->setLocId((*it)->getGeoType());
2344       elt->setNewStart(newStart);
2345       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2346       entriesKeptNew.push_back(elt);
2347       entriesKeptNew2.push_back(elt);
2348     }
2349   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2350   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2351   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2352   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2353   bool ret=false;
2354   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2355     {
2356       sid=0;
2357       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2358         {
2359           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2360           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2361           }*/
2362       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2363                                                             glob,arr2,otherEntriesNew) || ret;
2364     }
2365   if(!ret)
2366     return false;
2367   // Assign new dispatching
2368   assignNewLeaves(otherEntriesNew);
2369   arr->deepCopyFrom(*arr2);
2370   return true;
2371 }
2372
2373 /*!
2374  * \param [in,out] globalNum a global numbering counter for the renumbering.
2375  * \param [out] its - list of pair (start,stop) kept
2376  */
2377 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2378 {
2379   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2380   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2381     {
2382       std::vector< std::pair<int,int> > its2;
2383       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2384         {
2385           ret.push_back(*it);
2386           its.insert(its.end(),its2.begin(),its2.end());
2387         }
2388     }
2389   _field_pm_pt=ret;
2390 }
2391
2392 /*!
2393  * \param [in,out] globalNum a global numbering counter for the renumbering.
2394  * \param [out] its - list of pair (start,stop) kept
2395  */
2396 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2397 {
2398   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2399   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2400     {
2401       std::vector< std::pair<int,int> > its2;
2402       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2403         {
2404           ret.push_back(*it);
2405           its.insert(its.end(),its2.begin(),its2.end());
2406         }
2407     }
2408   _field_pm_pt=ret;
2409 }
2410
2411 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2412 {
2413   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2414   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2415     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2416   //
2417   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2418   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2419   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2420   for(;it1!=types.end();it1++,it2++)
2421     {
2422       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2423       elt->setLeaves((*it1).second);
2424       MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2425       *it2=elt2;
2426     }
2427   _field_pm_pt=fieldPmPt;
2428 }
2429
2430 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2431 {
2432   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2433     (*it)->changePflsRefsNamesGen(mapOfModif);
2434 }
2435
2436 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2437 {
2438   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2439     (*it)->changeLocsRefsNamesGen(mapOfModif);
2440 }
2441
2442 /*!
2443  * \param [in] mesh is the whole mesh
2444  */
2445 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2446 {
2447   if(_field_pm_pt.empty())
2448     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2449   //
2450   std::vector< std::pair<int,int> > dads;
2451   std::vector<const DataArrayInt *> pfls;
2452   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2453   std::vector<int> locs,code;
2454   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2455   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2456     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2457   // Sort by types
2458   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2459   if(code.empty())
2460     {
2461       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2462       throw INTERP_KERNEL::Exception(oss.str());
2463     }
2464   //
2465   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2466   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2467   if(type!=ON_NODES)
2468     {
2469       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2470       if(!arr)
2471         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2472       else
2473         {
2474           MCAuto<DataArrayInt> arr2(arr);
2475           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2476         }
2477     }
2478   else
2479     {
2480       if(code.size()!=3)
2481         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2482       int nb=code[1];
2483       if(code[2]==-1)
2484         {
2485           if(nb!=mesh->getNumberOfNodes())
2486             {
2487               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2488               oss << " nodes in mesh !";
2489               throw INTERP_KERNEL::Exception(oss.str());
2490             }
2491           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2492         }
2493       else
2494         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2495     }
2496 }
2497
2498 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2499 {
2500   if(_field_pm_pt.empty())
2501     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2502   //
2503   std::vector<std::pair<int,int> > dads;
2504   std::vector<const DataArrayInt *> pfls;
2505   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2506   std::vector<int> locs,code;
2507   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2508   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2509     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2510   // Sort by types
2511   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2512   if(code.empty())
2513     {
2514       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2515       throw INTERP_KERNEL::Exception(oss.str());
2516     }
2517   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2518   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2519   if(type!=ON_NODES)
2520     {
2521       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2522       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2523     }
2524   else
2525     {
2526       if(code.size()!=3)
2527         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2528       int nb=code[1];
2529       if(code[2]==-1)
2530         {
2531           if(nb!=mesh->getNumberOfNodes())
2532             {
2533               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2534               oss << " nodes in mesh !";
2535               throw INTERP_KERNEL::Exception(oss.str());
2536             }
2537         }
2538       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2539     }
2540   //
2541   return 0;
2542 }
2543
2544 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2545 {
2546   int globalSz=0;
2547   int nbOfEntries=0;
2548   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2549     {
2550       (*it)->getSizes(globalSz,nbOfEntries);
2551     }
2552   entries.resize(nbOfEntries);
2553   nbOfEntries=0;
2554   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2555     {
2556       (*it)->fillValues(nbOfEntries,entries);
2557     }
2558 }
2559
2560 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2561 {
2562   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2563     {
2564       if((*it)->getGeoType()==typ)
2565         return (*it)->getLeafGivenLocId(locId);
2566     }
2567   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2568   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2569   oss << "Possiblities are : ";
2570   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2571     {
2572       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2573       oss << "\"" << cm2.getRepr() << "\", ";
2574     }
2575   throw INTERP_KERNEL::Exception(oss.str());
2576 }
2577
2578 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2579 {
2580   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2581     {
2582       if((*it)->getGeoType()==typ)
2583         return (*it)->getLeafGivenLocId(locId);
2584     }
2585   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2586   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2587   oss << "Possiblities are : ";
2588   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2589     {
2590       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2591       oss << "\"" << cm2.getRepr() << "\", ";
2592     }
2593   throw INTERP_KERNEL::Exception(oss.str());
2594 }
2595
2596 /*!
2597  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2598  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2599  * \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.
2600  * \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.
2601  */
2602 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)
2603 {
2604   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2605   if(pms.empty())
2606     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2607   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2608     {
2609       if(!(*it).second)
2610         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2611       if(!(*it).second->getProfile().empty())
2612         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2613       if(!(*it).second->getLocalization().empty())
2614         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2615     }
2616   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2617   std::size_t i(0);
2618   std::vector< std::pair<int,int> > filteredDTS;
2619   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2620     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2621       if((*it2).first==gt)
2622         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2623   if(pms.size()!=filteredDTS.size())
2624     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2625   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2626   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2627   int zeStart(start),nval(0);
2628   for(;it1!=pms.end();it1++,it2++)
2629     {
2630       if((*it1).first!=(*it2).first)
2631         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2632       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2633       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2634       start+=e1-s1;
2635       nval+=((*it1).second)->getNumberOfVals();
2636     }
2637   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2638   return ret;
2639 }
2640
2641 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)
2642 {
2643   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2644   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2645   std::size_t i(0);
2646   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2647     {
2648       const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2649       for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2650         {
2651           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2652           const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2653           if(!elt)
2654             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2655           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2656         }
2657     }
2658   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2659     {
2660       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2661       MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2662       ret->_field_pm_pt.push_back(agg2);
2663     }
2664   return ret;
2665 }
2666
2667 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2668 {
2669   int i=0;
2670   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2671   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2672   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2673     {
2674       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2675       if(type==curType)
2676         return i;
2677       else
2678         {
2679           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2680           if(pos>pos2)
2681             it2=it+1;
2682         }
2683     }
2684   int ret=std::distance(_field_pm_pt.begin(),it2);
2685   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2686   return ret;
2687 }
2688
2689 /*!
2690  * 'dads' and 'locs' input parameters have the same number of elements
2691  * \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
2692  */
2693 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2694                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2695                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2696 {
2697   isPfl=false;
2698   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2699   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2700   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2701   const std::vector<std::string>& infos=getInfo();
2702   da->setInfoOnComponents(infos);
2703   da->setName("");
2704   if(type==ON_GAUSS_PT)
2705     {
2706       int offset=0;
2707       int nbOfArrs=dads.size();
2708       for(int i=0;i<nbOfArrs;i++)
2709         {
2710           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2711           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2712           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2713           MCAuto<DataArrayInt> di=DataArrayInt::New();
2714           di->alloc(nbOfElems,1);
2715           di->iota(offset);
2716           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2717           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2718           offset+=nbOfElems;
2719         }
2720     }
2721   arrOut=da;
2722   return ret.retn();
2723 }
2724
2725 /*!
2726  * 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.
2727  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2728  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2729  * The order of cells in the returned field is those imposed by the profile.
2730  * \param [in] mesh is the global mesh.
2731  */
2732 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2733                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2734                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2735                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2736 {
2737   if(da->isIota(mesh->getNumberOfCells()))
2738     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2739   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2740   m2->setName(mesh->getName().c_str());
2741   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2742   isPfl=true;
2743   return ret.retn();
2744 }
2745
2746 /*!
2747  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2748  */
2749 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2750                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2751                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2752 {
2753   if(da->isIota(mesh->getNumberOfNodes()))
2754     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2755   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2756   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2757   if(meshu)
2758     {
2759       if(meshu->getNodalConnectivity()==0)
2760         {
2761           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2762           int nb=da->getNbOfElems();
2763           const int *ptr=da->getConstPointer();
2764           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2765           meshuc->allocateCells(nb);
2766           for(int i=0;i<nb;i++)
2767             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2768           meshuc->finishInsertingCells();
2769           ret->setMesh(meshuc);
2770           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2771           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2772           disc->checkCoherencyBetween(meshuc,arrOut);
2773           return ret.retn();
2774         }
2775     }
2776   //
2777   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2778   isPfl=true;
2779   DataArrayInt *arr2=0;
2780   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2781   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2782   MCAuto<DataArrayInt> arr3(arr2);
2783   int nnodes=mesh2->getNumberOfNodes();
2784   if(nnodes==(int)da->getNbOfElems())
2785     {
2786       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2787       arrOut->renumberInPlace(da3->getConstPointer());
2788       mesh2->setName(mesh->getName().c_str());
2789       ret->setMesh(mesh2);
2790       return ret.retn();
2791     }
2792   else
2793     {
2794       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 !!!";
2795       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2796       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2797       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2798       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2799       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2800       throw INTERP_KERNEL::Exception(oss.str());
2801     }
2802   return 0;
2803 }
2804
2805 /*!
2806  * This method is the most light method of field retrieving.
2807  */
2808 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2809 {
2810   if(!pflIn)
2811     {
2812       pflOut=DataArrayInt::New();
2813       pflOut->alloc(nbOfElems,1);
2814       pflOut->iota(0);
2815     }
2816   else
2817     {
2818       pflOut=const_cast<DataArrayInt*>(pflIn);
2819       pflOut->incrRef();
2820     }
2821   MCAuto<DataArrayInt> safePfl(pflOut);
2822   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2823   const std::vector<std::string>& infos=getInfo();
2824   int nbOfComp=infos.size();
2825   for(int i=0;i<nbOfComp;i++)
2826     da->setInfoOnComponent(i,infos[i].c_str());
2827   safePfl->incrRef();
2828   return da.retn();
2829 }
2830
2831
2832 /// @cond INTERNAL
2833
2834 class MFFPMIter
2835 {
2836 public:
2837   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2838   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2839   virtual ~MFFPMIter() { }
2840   virtual void begin() = 0;
2841   virtual bool finished() const = 0;
2842   virtual void next() = 0;
2843   virtual int current() const = 0;
2844 };
2845
2846 class MFFPMIterSimple : public MFFPMIter
2847 {
2848 public:
2849   MFFPMIterSimple():_pos(0) { }
2850   void begin() { _pos=0; }
2851   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2852   void next() { _pos++; }
2853   int current() const { return _pos; }
2854 private:
2855   int _pos;
2856 };
2857
2858 class MFFPMIter2 : public MFFPMIter
2859 {
2860 public:
2861   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2862   void begin() { _it=_ids.begin(); }
2863   bool finished() const { return _it==_ids.end(); }
2864   void next() { _it++; }
2865   int current() const { return *_it; }
2866 private:
2867   std::vector<int> _ids;
2868   std::vector<int>::const_iterator _it;
2869 };
2870
2871 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2872 {
2873   if(!entities)
2874     return new MFFPMIterSimple;
2875   else
2876     {
2877       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2878       if(entities2)
2879         {
2880           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2881           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2882           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2883             {
2884               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2885                 tmp.push_back((*it).second);
2886             }
2887           return new MFFPMIter2(tmp);
2888         }
2889       return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2890     }
2891 }
2892
2893 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2894 {
2895   if(!entities)
2896     return true;
2897   else
2898     {
2899       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2900       if(entities2)
2901         {
2902           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2903           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2904             if((*it).first==ON_NODES)
2905               return true;
2906           return false;
2907         }
2908       return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2909     }
2910 }
2911
2912 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2913 {
2914   std::size_t sz(cts.size());
2915   _ids.resize(sz);
2916   for(std::size_t i=0;i<sz;i++)
2917     {
2918       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2919       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2920         _ids[i]=(int)std::distance(typmai2,loc);
2921       else
2922         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2923     }
2924 }
2925
2926 /// @endcond
2927
2928 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2929     _father(fath)
2930 {
2931   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2932   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2933   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2934   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2935   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2936   for(iter0->begin();!iter0->finished();iter0->next())
2937     {
2938       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2939       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2940       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2941       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2942       if(nbProfile>0 || nbProfile2>0)
2943         {
2944           const PartDefinition *pd(0);
2945           if(mmu)
2946             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2947           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2948           if(nbProfile>0)
2949             _mesh_name=name0;
2950           else
2951             _mesh_name=name1;
2952         }
2953     }
2954   if(MFFPMIter::IsPresenceOfNode(entities))
2955     {
2956       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2957       if(nbProfile>0)
2958         {
2959           const PartDefinition *pd(0);
2960           if(mmu)
2961             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2962           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2963           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2964         }
2965     }
2966   if(!entities)
2967     return ;
2968   std::vector<int> dynGT(entities->getDynGTAvail());
2969   for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2970     {
2971       int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2972       if(nbPfl>0)
2973         {
2974           _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2975           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2976         }
2977     }
2978 }
2979
2980 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2981 {
2982   copyTinyInfoFrom(mesh);
2983 }
2984
2985 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2986 {
2987   if(id>=(int)_pfls.size())
2988     _pfls.resize(id+1);
2989   _pfls[id]=DataArrayInt::New();
2990   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2991   _pfls[id]->setName(pflName);
2992   _pfls[id]->alloc(lgth,1);
2993   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2994   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2995 }
2996
2997 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2998 {
2999   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3000   int sz;
3001   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3002   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3003   if(i>=(int)_pfls.size())
3004     _pfls.resize(i+1);
3005   _pfls[i]=DataArrayInt::New();
3006   _pfls[i]->alloc(sz,1);
3007   _pfls[i]->setName(pflCpp.c_str());
3008   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3009   _pfls[i]->applyLin(1,-1,0);//Converting into C format
3010 }
3011
3012 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3013 {
3014   int nbOfPfls=_pfls.size();
3015   for(int i=0;i<nbOfPfls;i++)
3016     {
3017       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3018       cpy->applyLin(1,1,0);
3019       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3020       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3021       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3022     }
3023   //
3024   int nbOfLocs=_locs.size();
3025   for(int i=0;i<nbOfLocs;i++)
3026     _locs[i]->writeLL(fid);
3027 }
3028
3029 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3030 {
3031   std::vector<std::string> pfls=getPfls();
3032   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3033     {
3034       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3035       if(it2==pfls.end())
3036         {
3037           _pfls.push_back(*it);
3038         }
3039       else
3040         {
3041           int id=std::distance(pfls.begin(),it2);
3042           if(!(*it)->isEqual(*_pfls[id]))
3043             {
3044               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3045               throw INTERP_KERNEL::Exception(oss.str());
3046             }
3047         }
3048     }
3049   std::vector<std::string> locs=getLocs();
3050   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3051     {
3052       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3053       if(it2==locs.end())
3054         {
3055           _locs.push_back(*it);
3056         }
3057       else
3058         {
3059           int id=std::distance(locs.begin(),it2);
3060           if(!(*it)->isEqual(*_locs[id],eps))
3061             {
3062               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3063               throw INTERP_KERNEL::Exception(oss.str());
3064             }
3065         }
3066     }
3067 }
3068
3069 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3070 {
3071   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3072     getProfile((*it).c_str());
3073 }
3074
3075 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3076 {
3077   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3078     getLocalization((*it).c_str());
3079 }
3080
3081 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3082 {
3083   std::vector<std::string> profiles=real.getPflsReallyUsed();
3084   int sz=profiles.size();
3085   _pfls.resize(sz);
3086   for(int i=0;i<sz;i++)
3087     loadProfileInFile(fid,i,profiles[i].c_str());
3088   //
3089   std::vector<std::string> locs=real.getLocsReallyUsed();
3090   sz=locs.size();
3091   _locs.resize(sz);
3092   for(int i=0;i<sz;i++)
3093     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3094 }
3095
3096 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3097 {
3098   int nProfil=MEDnProfile(fid);
3099   for(int i=0;i<nProfil;i++)
3100     loadProfileInFile(fid,i);
3101   int sz=MEDnLocalization(fid);
3102   _locs.resize(sz);
3103   for(int i=0;i<sz;i++)
3104     {
3105       _locs[i]=MEDFileFieldLoc::New(fid,i);
3106     }
3107 }
3108
3109 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3110 {
3111   return new MEDFileFieldGlobs(fid);
3112 }
3113
3114 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3115 {
3116   return new MEDFileFieldGlobs;
3117 }
3118
3119 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3120 {
3121   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3122 }
3123
3124 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3125 {
3126   std::vector<const BigMemoryObject *> ret;
3127   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3128     ret.push_back((const DataArrayInt *)*it);
3129   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3130     ret.push_back((const MEDFileFieldLoc *)*it);
3131   return ret;
3132 }
3133
3134 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3135 {
3136   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3137   std::size_t i=0;
3138   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3139     {
3140       if((const DataArrayInt *)*it)
3141         ret->_pfls[i]=(*it)->deepCopy();
3142     }
3143   i=0;
3144   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3145     {
3146       if((const MEDFileFieldLoc*)*it)
3147         ret->_locs[i]=(*it)->deepCopy();
3148     }
3149   return ret.retn();
3150 }
3151
3152 /*!
3153  * \throw if a profile in \a pfls in not in \a this.
3154  * \throw if a localization in \a locs in not in \a this.
3155  * \sa MEDFileFieldGlobs::deepCpyPart
3156  */
3157 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3158 {
3159   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3160   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3161     {
3162       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3163       if(!pfl)
3164         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3165       pfl->incrRef();
3166       MCAuto<DataArrayInt> pfl2(pfl);
3167       ret->_pfls.push_back(pfl2);
3168     }
3169   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3170     {
3171       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3172       if(!loc)
3173         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3174       loc->incrRef();
3175       MCAuto<MEDFileFieldLoc> loc2(loc);
3176       ret->_locs.push_back(loc2);
3177     }
3178   ret->setFileName(getFileName());
3179   return ret.retn();
3180 }
3181
3182 /*!
3183  * \throw if a profile in \a pfls in not in \a this.
3184  * \throw if a localization in \a locs in not in \a this.
3185  * \sa MEDFileFieldGlobs::shallowCpyPart
3186  */
3187 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3188 {
3189   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3190   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3191     {
3192       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3193       if(!pfl)
3194         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3195       ret->_pfls.push_back(pfl->deepCopy());
3196     }
3197   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3198     {
3199       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3200       if(!loc)
3201         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3202       ret->_locs.push_back(loc->deepCopy());
3203     }
3204   ret->setFileName(getFileName());
3205   return ret.retn();
3206 }
3207
3208 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3209 {
3210 }
3211
3212 MEDFileFieldGlobs::MEDFileFieldGlobs()
3213 {
3214 }
3215
3216 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3217 {
3218 }
3219
3220 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3221 {
3222   oss << "Profiles :\n";
3223   std::size_t n=_pfls.size();
3224   for(std::size_t i=0;i<n;i++)
3225     {
3226       oss << "  - #" << i << " ";
3227       const DataArrayInt *pfl=_pfls[i];
3228       if(pfl)
3229         oss << "\"" << pfl->getName() << "\"\n";
3230       else
3231         oss << "EMPTY !\n";
3232     }
3233   n=_locs.size();
3234   oss << "Localizations :\n";
3235   for(std::size_t i=0;i<n;i++)
3236     {
3237       oss << "  - #" << i << " ";
3238       const MEDFileFieldLoc *loc=_locs[i];
3239       if(loc)
3240         loc->simpleRepr(oss);
3241       else
3242         oss<< "EMPTY !\n";
3243     }
3244 }
3245
3246 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3247 {
3248   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3249     {
3250       DataArrayInt *elt(*it);
3251       if(elt)
3252         {
3253           std::string name(elt->getName());
3254           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3255             {
3256               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3257                 {
3258                   elt->setName((*it2).second.c_str());
3259                   return;
3260                 }
3261             }
3262         }
3263     }
3264 }
3265
3266 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3267 {
3268   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3269     {
3270       MEDFileFieldLoc *elt(*it);
3271       if(elt)
3272         {
3273           std::string name(elt->getName());
3274           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3275             {
3276               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3277                 {
3278                   elt->setName((*it2).second.c_str());
3279                   return;
3280                 }
3281             }
3282         }
3283     }
3284 }
3285
3286 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3287 {
3288   if(locId<0 || locId>=(int)_locs.size())
3289     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3290   return _locs[locId]->getNbOfGaussPtPerCell();
3291 }
3292
3293 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3294 {
3295   return getLocalizationFromId(getLocalizationId(locName));
3296 }
3297
3298 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3299 {
3300   if(locId<0 || locId>=(int)_locs.size())
3301     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3302   return *_locs[locId];
3303 }
3304
3305 /// @cond INTERNAL
3306 namespace MEDCouplingImpl
3307 {
3308   class LocFinder
3309   {
3310   public:
3311     LocFinder(const std::string& loc):_loc(loc) { }
3312     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3313   private:
3314     const std::string &_loc;
3315   };
3316
3317   class PflFinder
3318   {
3319   public:
3320     PflFinder(const std::string& pfl):_pfl(pfl) { }
3321     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3322   private:
3323     const std::string& _pfl;
3324   };
3325 }
3326 /// @endcond
3327
3328 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3329 {
3330   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3331   if(it==_locs.end())
3332     {
3333       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3334       for(it=_locs.begin();it!=_locs.end();it++)
3335         oss << "\"" << (*it)->getName() << "\", ";
3336       throw INTERP_KERNEL::Exception(oss.str());
3337     }
3338   return std::distance(_locs.begin(),it);
3339 }
3340
3341 /*!
3342  * The returned value is never null.
3343  */
3344 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3345 {
3346   std::string pflNameCpp(pflName);
3347   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3348   if(it==_pfls.end())
3349     {
3350       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3351       for(it=_pfls.begin();it!=_pfls.end();it++)
3352         oss << "\"" << (*it)->getName() << "\", ";
3353       throw INTERP_KERNEL::Exception(oss.str());
3354     }
3355   return *it;
3356 }
3357
3358 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3359 {
3360   if(pflId<0 || pflId>=(int)_pfls.size())
3361     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3362   return _pfls[pflId];
3363 }
3364
3365 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3366 {
3367   if(locId<0 || locId>=(int)_locs.size())
3368     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3369   return *_locs[locId];
3370 }
3371
3372 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3373 {
3374   return getLocalizationFromId(getLocalizationId(locName));
3375 }
3376
3377 /*!
3378  * The returned value is never null.
3379  */
3380 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3381 {
3382   std::string pflNameCpp(pflName);
3383   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3384   if(it==_pfls.end())
3385     {
3386       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3387       for(it=_pfls.begin();it!=_pfls.end();it++)
3388         oss << "\"" << (*it)->getName() << "\", ";
3389       throw INTERP_KERNEL::Exception(oss.str());
3390     }
3391   return *it;
3392 }
3393
3394 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3395 {
3396   if(pflId<0 || pflId>=(int)_pfls.size())
3397     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3398   return _pfls[pflId];
3399 }
3400
3401 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3402 {
3403   std::vector< MCAuto<DataArrayInt> > newPfls;
3404   int i=0;
3405   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3406     {
3407       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3408         newPfls.push_back(*it);
3409     }
3410   _pfls=newPfls;
3411 }
3412
3413 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3414 {
3415   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3416   int i=0;
3417   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3418     {
3419       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3420         newLocs.push_back(*it);
3421     }
3422   _locs=newLocs;
3423 }
3424
3425 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3426 {
3427   int sz=_pfls.size();
3428   std::vector<std::string> ret(sz);
3429   for(int i=0;i<sz;i++)
3430     ret[i]=_pfls[i]->getName();
3431   return ret;
3432 }
3433
3434 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3435 {
3436   int sz=_locs.size();
3437   std::vector<std::string> ret(sz);
3438   for(int i=0;i<sz;i++)
3439     ret[i]=_locs[i]->getName();
3440   return ret;
3441 }
3442
3443 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3444 {
3445   std::vector<std::string> v=getPfls();
3446   std::string s(pflName);
3447   return std::find(v.begin(),v.end(),s)!=v.end();
3448 }
3449
3450 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3451 {
3452   std::vector<std::string> v=getLocs();
3453   std::string s(locName);
3454   return std::find(v.begin(),v.end(),s)!=v.end();
3455 }
3456
3457 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3458 {
3459   std::map<int,std::vector<int> > m;
3460   int i=0;
3461   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3462     {
3463       const DataArrayInt *tmp=(*it);
3464       if(tmp)
3465         {
3466           m[tmp->getHashCode()].push_back(i);
3467         }
3468     }
3469   std::vector< std::vector<int> > ret;
3470   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3471     {
3472       if((*it2).second.size()>1)
3473         {
3474           std::vector<int> ret0;
3475           bool equalityOrNot=false;
3476           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3477             {
3478               std::vector<int>::const_iterator it4=it3; it4++;
3479               for(;it4!=(*it2).second.end();it4++)
3480                 {
3481                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3482                     {
3483                       if(!equalityOrNot)
3484                         ret0.push_back(*it3);
3485                       ret0.push_back(*it4);
3486                       equalityOrNot=true;
3487                     }
3488                 }
3489             }
3490           if(!ret0.empty())
3491             ret.push_back(ret0);
3492         }
3493     }
3494   return ret;
3495 }
3496
3497 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3498 {
3499   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3500 }
3501
3502 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3503 {
3504   std::string name(pfl->getName());
3505   if(name.empty())
3506     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3507   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3508     if(name==(*it)->getName())
3509       {
3510         if(!pfl->isEqual(*(*it)))
3511           {
3512             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3513             throw INTERP_KERNEL::Exception(oss.str());
3514           }
3515       }
3516   pfl->incrRef();
3517   _pfls.push_back(pfl);
3518 }
3519
3520 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)
3521 {
3522   std::string name(locName);
3523   if(name.empty())
3524     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3525   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3526   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3527     if((*it)->isName(locName))
3528       {
3529         if(!(*it)->isEqual(*obj,1e-12))
3530           {
3531             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3532             throw INTERP_KERNEL::Exception(oss.str());
3533           }
3534       }
3535   _locs.push_back(obj);
3536 }
3537
3538 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3539 {
3540   std::vector<std::string> names=getPfls();
3541   return CreateNewNameNotIn("NewPfl_",names);
3542 }
3543
3544 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3545 {
3546   std::vector<std::string> names=getLocs();
3547   return CreateNewNameNotIn("NewLoc_",names);
3548 }
3549
3550 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3551 {
3552   for(std::size_t sz=0;sz<100000;sz++)
3553     {
3554       std::ostringstream tryName;
3555       tryName << prefix << sz;
3556       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3557         return tryName.str();
3558     }
3559   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3560 }
3561
3562 /*!
3563  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3564  *  \param [in] fname - the file name.
3565  */
3566 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3567 {
3568 }
3569
3570 /*!
3571  * Creates an empty MEDFileFieldGlobsReal.
3572  */
3573 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3574 {
3575 }
3576
3577 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3578 {
3579   return 0;
3580 }
3581
3582 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3583 {
3584   std::vector<const BigMemoryObject *> ret;
3585   ret.push_back((const MEDFileFieldGlobs *)_globals);
3586   return ret;
3587 }
3588
3589 /*!
3590  * Returns a string describing profiles and Gauss points held in \a this.
3591  *  \return std::string - the description string.
3592  */
3593 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3594 {
3595   const MEDFileFieldGlobs *glob=_globals;
3596   std::ostringstream oss2; oss2 << glob;
3597   std::string stars(oss2.str().length(),'*');
3598   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3599   if(glob)
3600     glob->simpleRepr(oss);
3601   else
3602     oss << "NO GLOBAL INFORMATION !\n";
3603 }
3604
3605 void MEDFileFieldGlobsReal::resetContent()
3606 {
3607   _globals=MEDFileFieldGlobs::New();
3608 }
3609
3610 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3611 {
3612 }
3613
3614 /*!
3615  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3616  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3617  */
3618 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3619 {
3620   _globals=other._globals;
3621 }
3622
3623 /*!
3624  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3625  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3626  */
3627 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3628 {
3629   const MEDFileFieldGlobs *otherg(other._globals);
3630   if(!otherg)
3631     return ;
3632   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3633 }
3634
3635 /*!
3636  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3637  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3638  */
3639 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3640 {
3641   const MEDFileFieldGlobs *otherg(other._globals);
3642   if(!otherg)
3643     return ;
3644   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3645 }
3646
3647 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3648 {
3649   _globals=other._globals;
3650   if((const MEDFileFieldGlobs *)_globals)
3651     _globals=other._globals->deepCopy();
3652 }
3653
3654 /*!
3655  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3656  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3657  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3658  *         \a this and \a other MEDFileFieldGlobsReal.
3659  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3660  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3661  */
3662 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3663 {
3664   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3665   if(thisGlobals==otherGlobals)
3666     return ;
3667   if(!thisGlobals)
3668     {
3669       _globals=other._globals;
3670       return ;
3671     }
3672   _globals->appendGlobs(*other._globals,eps);
3673 }
3674
3675 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3676 {
3677   checkGlobsPflsPartCoherency();
3678   checkGlobsLocsPartCoherency();
3679 }
3680
3681 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3682 {
3683   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3684 }
3685
3686 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3687 {
3688   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3689 }
3690
3691 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3692 {
3693   contentNotNull()->loadProfileInFile(fid,id,pflName);
3694 }
3695
3696 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3697 {
3698   contentNotNull()->loadProfileInFile(fid,id);
3699 }
3700
3701 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3702 {
3703   contentNotNull()->loadGlobals(fid,*this);
3704 }
3705
3706 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3707 {
3708   contentNotNull()->loadAllGlobals(fid);
3709 }
3710
3711 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3712 {
3713   contentNotNull()->writeGlobals(fid,opt);
3714 }
3715
3716 /*!
3717  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3718  * or getPflsReallyUsedMulti().
3719  *  \return std::vector<std::string> - a sequence of names of all profiles.
3720  */
3721 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3722 {
3723   return contentNotNull()->getPfls();
3724 }
3725
3726 /*!
3727  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3728  * or getLocsReallyUsedMulti().
3729  *  \return std::vector<std::string> - a sequence of names of all localizations.
3730  */
3731 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3732 {
3733   return contentNotNull()->getLocs();
3734 }
3735
3736 /*!
3737  * Checks if the profile with a given name exists.
3738  *  \param [in] pflName - the profile name of interest.
3739  *  \return bool - \c true if the profile named \a pflName exists.
3740  */
3741 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3742 {
3743   return contentNotNull()->existsPfl(pflName);
3744 }
3745
3746 /*!
3747  * Checks if the localization with a given name exists.
3748  *  \param [in] locName - the localization name of interest.
3749  *  \return bool - \c true if the localization named \a locName exists.
3750  */
3751 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3752 {
3753   return contentNotNull()->existsLoc(locName);
3754 }
3755
3756 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3757 {
3758   return contentNotNull()->createNewNameOfPfl();
3759 }
3760
3761 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3762 {
3763   return contentNotNull()->createNewNameOfLoc();
3764 }
3765
3766 /*!
3767  * Sets the name of a MED file.
3768  *  \param [inout] fileName - the file name.
3769  */
3770 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3771 {
3772   contentNotNull()->setFileName(fileName);
3773 }
3774
3775 /*!
3776  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3777  * in the same order.
3778  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3779  *          Each item of this sequence is a vector containing ids of equal profiles.
3780  */
3781 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3782 {
3783   return contentNotNull()->whichAreEqualProfiles();
3784 }
3785
3786 /*!
3787  * Finds equal localizations.
3788  *  \param [in] eps - a precision used to compare real values of the localizations.
3789  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3790  *          Each item of this sequence is a vector containing ids of equal localizations.
3791  */
3792 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3793 {
3794   return contentNotNull()->whichAreEqualLocs(eps);
3795 }
3796
3797 /*!
3798  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3799  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3800  *        this sequence is a pair whose 
3801  *        - the first item is a vector of profile names to replace by the second item,
3802  *        - the second item is a profile name to replace every profile name of the first item.
3803  */
3804 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3805 {
3806   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3807 }
3808
3809 /*!
3810  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3811  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3812  *        this sequence is a pair whose 
3813  *        - the first item is a vector of localization names to replace by the second item,
3814  *        - the second item is a localization name to replace every localization name of the first item.
3815  */
3816 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3817 {
3818   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3819 }
3820
3821 /*!
3822  * Replaces references to some profiles (a reference is a profile name) by references
3823  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3824  * them-selves accordingly. <br>
3825  * This method is a generalization of changePflName().
3826  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3827  *        this sequence is a pair whose 
3828  *        - the first item is a vector of profile names to replace by the second item,
3829  *        - the second item is a profile name to replace every profile of the first item.
3830  * \sa changePflsRefsNamesGen()
3831  * \sa changePflName()
3832  */
3833 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3834 {
3835   changePflsRefsNamesGen(mapOfModif);
3836   changePflsNamesInStruct(mapOfModif);
3837 }
3838
3839 /*!
3840  * Replaces references to some localizations (a reference is a localization name) by references
3841  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3842  * them-selves accordingly. <br>
3843  * This method is a generalization of changeLocName().
3844  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3845  *        this sequence is a pair whose 
3846  *        - the first item is a vector of localization names to replace by the second item,
3847  *        - the second item is a localization name to replace every localization of the first item.
3848  * \sa changeLocsRefsNamesGen()
3849  * \sa changeLocName()
3850  */
3851 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3852 {
3853   changeLocsRefsNamesGen(mapOfModif);
3854   changeLocsNamesInStruct(mapOfModif);
3855 }
3856
3857 /*!
3858  * Renames the profile having a given name and updates references to this profile.
3859  *  \param [in] oldName - the name of the profile to rename.
3860  *  \param [in] newName - a new name of the profile.
3861  * \sa changePflsNames().
3862  */
3863 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3864 {
3865   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3866   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3867   mapOfModif[0]=p;
3868   changePflsNames(mapOfModif);
3869 }
3870
3871 /*!
3872  * Renames the localization having a given name and updates references to this localization.
3873  *  \param [in] oldName - the name of the localization to rename.
3874  *  \param [in] newName - a new name of the localization.
3875  * \sa changeLocsNames().
3876  */
3877 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3878 {
3879   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3880   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3881   mapOfModif[0]=p;
3882   changeLocsNames(mapOfModif);
3883 }
3884
3885 /*!
3886  * Removes duplicated profiles. Returns a map used to update references to removed 
3887  * profiles via changePflsRefsNamesGen().
3888  * Equal profiles are found using whichAreEqualProfiles().
3889  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3890  *          a sequence describing the performed replacements of profiles. Each element of
3891  *          this sequence is a pair whose
3892  *          - the first item is a vector of profile names replaced by the second item,
3893  *          - the second item is a profile name replacing every profile of the first item.
3894  */
3895 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3896 {
3897   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3898   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3899   int i=0;
3900   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3901     {
3902       std::vector< std::string > tmp((*it).size());
3903       int j=0;
3904       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3905         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3906       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3907       ret[i]=p;
3908       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3909       killProfileIds(tmp2);
3910     }
3911   changePflsRefsNamesGen(ret);
3912   return ret;
3913 }
3914
3915 /*!
3916  * Removes duplicated localizations. Returns a map used to update references to removed 
3917  * localizations via changeLocsRefsNamesGen().
3918  * Equal localizations are found using whichAreEqualLocs().
3919  *  \param [in] eps - a precision used to compare real values of the localizations.
3920  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3921  *          a sequence describing the performed replacements of localizations. Each element of
3922  *          this sequence is a pair whose
3923  *          - the first item is a vector of localization names replaced by the second item,
3924  *          - the second item is a localization name replacing every localization of the first item.
3925  */
3926 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3927 {
3928   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3929   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3930   int i=0;
3931   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3932     {
3933       std::vector< std::string > tmp((*it).size());
3934       int j=0;
3935       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3936         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3937       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3938       ret[i]=p;
3939       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3940       killLocalizationIds(tmp2);
3941     }
3942   changeLocsRefsNamesGen(ret);
3943   return ret;
3944 }
3945
3946 /*!
3947  * Returns number of Gauss points per cell in a given localization.
3948  *  \param [in] locId - an id of the localization of interest.
3949  *  \return int - the number of the Gauss points per cell.
3950  */
3951 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3952 {
3953   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3954 }
3955
3956 /*!
3957  * Returns an id of a localization by its name.
3958  *  \param [in] loc - the localization name of interest.
3959  *  \return int - the id of the localization.
3960  *  \throw If there is no a localization named \a loc.
3961  */
3962 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3963 {
3964   return contentNotNull()->getLocalizationId(loc);
3965 }
3966
3967 /*!
3968  * Returns the name of the MED file.
3969  *  \return const std::string&  - the MED file name.
3970  */
3971 std::string MEDFileFieldGlobsReal::getFileName() const
3972 {
3973   return contentNotNull()->getFileName();
3974 }
3975
3976 /*!
3977  * Returns a localization object by its name.
3978  *  \param [in] locName - the name of the localization of interest.
3979  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3980  *  \throw If there is no a localization named \a locName.
3981  */
3982 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3983 {
3984   return contentNotNull()->getLocalization(locName);
3985 }
3986
3987 /*!
3988  * Returns a localization object by its id.
3989  *  \param [in] locId - the id of the localization of interest.
3990  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3991  *  \throw If there is no a localization with id \a locId.
3992  */
3993 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3994 {
3995   return contentNotNull()->getLocalizationFromId(locId);
3996 }
3997
3998 /*!
3999  * Returns a profile array by its name.
4000  *  \param [in] pflName - the name of the profile of interest.
4001  *  \return const DataArrayInt * - the profile array having the name \a pflName.
4002  *  \throw If there is no a profile named \a pflName.
4003  */
4004 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4005 {
4006   return contentNotNull()->getProfile(pflName);
4007 }
4008
4009 /*!
4010  * Returns a profile array by its id.
4011  *  \param [in] pflId - the id of the profile of interest.
4012  *  \return const DataArrayInt * - the profile array having the id \a pflId.
4013  *  \throw If there is no a profile with id \a pflId.
4014  */
4015 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4016 {
4017   return contentNotNull()->getProfileFromId(pflId);
4018 }
4019
4020 /*!
4021  * Returns a localization object, apt for modification, by its id.
4022  *  \param [in] locId - the id of the localization of interest.
4023  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
4024  *          having the id \a locId.
4025  *  \throw If there is no a localization with id \a locId.
4026  */
4027 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4028 {
4029   return contentNotNull()->getLocalizationFromId(locId);
4030 }
4031
4032 /*!
4033  * Returns a localization object, apt for modification, by its name.
4034  *  \param [in] locName - the name of the localization of interest.
4035  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
4036  *          having the name \a locName.
4037  *  \throw If there is no a localization named \a locName.
4038  */
4039 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4040 {
4041   return contentNotNull()->getLocalization(locName);
4042 }
4043
4044 /*!
4045  * Returns a profile array, apt for modification, by its name.
4046  *  \param [in] pflName - the name of the profile of interest.
4047  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4048  *  \throw If there is no a profile named \a pflName.
4049  */
4050 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4051 {
4052   return contentNotNull()->getProfile(pflName);
4053 }
4054
4055 /*!
4056  * Returns a profile array, apt for modification, by its id.
4057  *  \param [in] pflId - the id of the profile of interest.
4058  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4059  *  \throw If there is no a profile with id \a pflId.
4060  */
4061 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4062 {
4063   return contentNotNull()->getProfileFromId(pflId);
4064 }
4065
4066 /*!
4067  * Removes profiles given by their ids. No data is updated to track this removal.
4068  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
4069  */
4070 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4071 {
4072   contentNotNull()->killProfileIds(pflIds);
4073 }
4074
4075 /*!
4076  * Removes localizations given by their ids. No data is updated to track this removal.
4077  *  \param [in] locIds - a sequence of ids of the localizations to remove.
4078  */
4079 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4080 {
4081   contentNotNull()->killLocalizationIds(locIds);
4082 }
4083
4084 /*!
4085  * Stores a profile array.
4086  *  \param [in] pfl - the profile array to store.
4087  *  \throw If the name of \a pfl is empty.
4088  *  \throw If a profile with the same name as that of \a pfl already exists but contains
4089  *         different ids.
4090  */
4091 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4092 {
4093   contentNotNull()->appendProfile(pfl);
4094 }
4095
4096 /*!
4097  * Adds a new localization of Gauss points.
4098  *  \param [in] locName - the name of the new localization.
4099  *  \param [in] geoType - a geometrical type of the reference cell.
4100  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4101  *         must be \c nbOfNodesPerCell * \c dimOfType.
4102  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4103  *         must be  _wg_.size() * \c dimOfType.
4104  *  \param [in] w - the weights of Gauss points.
4105  *  \throw If \a locName is empty.
4106  *  \throw If a localization with the name \a locName already exists but is
4107  *         different form the new one.
4108  */
4109 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)
4110 {
4111   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4112 }
4113
4114 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4115 {
4116   MEDFileFieldGlobs *g(_globals);
4117   if(!g)
4118     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4119   return g;
4120 }
4121
4122 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4123 {
4124   const MEDFileFieldGlobs *g(_globals);
4125   if(!g)
4126     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4127   return g;
4128 }
4129
4130 //= MEDFileFieldNameScope
4131
4132 MEDFileFieldNameScope::MEDFileFieldNameScope()
4133 {
4134 }
4135
4136 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4137 {
4138 }
4139
4140 /*!
4141  * Returns the name of \a this field.
4142  *  \return std::string - a string containing the field name.
4143  */
4144 std::string MEDFileFieldNameScope::getName() const
4145 {
4146   return _name;
4147 }
4148
4149 /*!
4150  * Sets name of \a this field
4151  *  \param [in] name - the new field name.
4152  */
4153 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4154 {
4155   _name=fieldName;
4156 }
4157
4158 std::string MEDFileFieldNameScope::getDtUnit() const
4159 {
4160   return _dt_unit;
4161 }
4162
4163 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4164 {
4165   _dt_unit=dtUnit;
4166 }
4167
4168 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4169 {
4170   _name=other._name;
4171   _dt_unit=other._dt_unit;
4172 }
4173
4174 //= MEDFileAnyTypeField1TSWithoutSDA
4175
4176 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4177 {
4178   _field_per_mesh.resize(other._field_per_mesh.size());
4179   std::size_t i=0;
4180   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4181     {
4182       if((const MEDFileFieldPerMesh *)*it)
4183         _field_per_mesh[i]=(*it)->deepCopy(this);
4184     }
4185 }
4186
4187 /*!
4188  * Prints a string describing \a this field into a stream. This string is outputted 
4189  * by \c print Python command.
4190  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4191  *  \param [in,out] oss - the out stream.
4192  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4193  *          info id printed, else, not.
4194  */
4195 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4196 {
4197   std::string startOfLine(bkOffset,' ');
4198   oss << startOfLine << "Field ";
4199   if(bkOffset==0)
4200     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4201   oss << "on one time Step ";
4202   if(f1tsId>=0)
4203     oss << "(" << f1tsId << ") ";
4204   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4205   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4206   const DataArray *arr=getUndergroundDataArray();
4207   if(arr)
4208     {
4209       const std::vector<std::string> &comps=arr->getInfoOnComponents();
4210       if(f1tsId<0)
4211         {
4212           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4213           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4214             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
4215         }
4216       if(arr->isAllocated())
4217         {
4218           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4219         }
4220       else
4221         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4222     }
4223   else
4224     {
4225       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4226     }
4227   oss << startOfLine << "----------------------" << std::endl;
4228   if(!_field_per_mesh.empty())
4229     {
4230       int i=0;
4231       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4232         {
4233           const MEDFileFieldPerMesh *cur=(*it2);
4234           if(cur)
4235             cur->simpleRepr(bkOffset,oss,i);
4236           else
4237             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4238         }
4239     }
4240   else
4241     {
4242       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4243     }
4244   oss << startOfLine << "----------------------" << std::endl;
4245 }
4246
4247 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4248 {
4249   const DataArray *arr(getUndergroundDataArray());
4250   if(!arr)
4251     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4252   int nbOfCompo=arr->getNumberOfComponents();
4253   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4254   for(int i=0;i<nbOfCompo;i++)
4255     {
4256       ret[i]=deepCopy();
4257       std::vector<int> v(1,i);
4258       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4259       ret[i]->setArray(arr2);
4260     }
4261   return ret;
4262 }
4263
4264 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)
4265 {
4266 }
4267
4268 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4269 {
4270 }
4271
4272 /*!
4273  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4274  * empty. Returns -1 if this in on nodes.
4275  *  \return int - the dimension of \a this.
4276  */
4277 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4278 {
4279   int ret=-2;
4280   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4281     (*it)->getDimension(ret);
4282   return ret;
4283 }
4284
4285 /*!
4286  * Returns the mesh name.
4287  *  \return std::string - a string holding the mesh name.
4288  *  \throw If \c _field_per_mesh.empty()
4289  */
4290 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4291 {
4292   if(_field_per_mesh.empty())
4293     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4294   return _field_per_mesh[0]->getMeshName();
4295 }
4296
4297 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4298 {
4299   std::string oldName(getMeshName());
4300   std::vector< std::pair<std::string,std::string> > v(1);
4301   v[0].first=oldName; v[0].second=newMeshName;
4302   changeMeshNames(v);
4303 }
4304
4305 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4306 {
4307   bool ret=false;
4308   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4309     {
4310       MEDFileFieldPerMesh *cur(*it);
4311       if(cur)
4312         ret=cur->changeMeshNames(modifTab) || ret;
4313     }
4314   return ret;
4315 }
4316
4317 /*!
4318  * Returns the number of iteration of the state of underlying mesh.
4319  *  \return int - the iteration number.
4320  *  \throw If \c _field_per_mesh.empty()
4321  */
4322 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4323 {
4324   if(_field_per_mesh.empty())
4325     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4326   return _field_per_mesh[0]->getMeshIteration();
4327 }
4328
4329 /*!
4330  * Returns the order number of iteration of the state of underlying mesh.
4331  *  \return int - the order number.
4332  *  \throw If \c _field_per_mesh.empty()
4333  */
4334 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4335 {
4336   if(_field_per_mesh.empty())
4337     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4338   return _field_per_mesh[0]->getMeshOrder();
4339 }
4340
4341 /*!
4342  * Checks if \a this field is tagged by a given iteration number and a given
4343  * iteration order number.
4344  *  \param [in] iteration - the iteration number of interest.
4345  *  \param [in] order - the iteration order number of interest.
4346  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4347  *          \a this->getOrder() == \a order.
4348  */
4349 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4350 {
4351   return iteration==_iteration && order==_order;
4352 }
4353
4354 /*!
4355  * Returns number of iteration and order number of iteration when
4356  * \a this field has been calculated.
4357  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4358  *          order number.
4359  */
4360 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4361 {
4362   std::pair<int,int> p;
4363   fillIteration(p);
4364   return p;
4365 }
4366
4367 /*!
4368  * Returns number of iteration and order number of iteration when
4369  * \a this field has been calculated.
4370  *  \param [in,out] p - a pair returning the iteration number and the iteration
4371  *          order number.
4372  */
4373 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4374 {
4375   p.first=_iteration;
4376   p.second=_order;
4377 }
4378
4379 /*!
4380  * Returns all types of spatial discretization of \a this field.
4381  *  \param [in,out] types - a sequence of types of \a this field.
4382  */
4383 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4384 {
4385   std::set<TypeOfField> types2;
4386   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4387     {
4388       (*it)->fillTypesOfFieldAvailable(types2);
4389     }
4390   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4391   std::copy(types2.begin(),types2.end(),bi);
4392 }
4393
4394 /*!
4395  * Returns all types of spatial discretization of \a this field.
4396  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4397  *          of \a this field.
4398  */
4399 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4400 {
4401   std::vector<TypeOfField> ret;
4402   fillTypesOfFieldAvailable(ret);
4403   return ret;
4404 }
4405
4406 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4407 {
4408   std::vector<std::string> ret;
4409   std::set<std::string> ret2;
4410   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4411     {
4412       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4413       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4414         if(ret2.find(*it2)==ret2.end())
4415           {
4416             ret.push_back(*it2);
4417             ret2.insert(*it2);
4418           }
4419     }
4420   return ret;
4421 }
4422
4423 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4424 {
4425   std::vector<std::string> ret;
4426   std::set<std::string> ret2;
4427   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4428     {
4429       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4430       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4431         if(ret2.find(*it2)==ret2.end())
4432           {
4433             ret.push_back(*it2);
4434             ret2.insert(*it2);
4435           }
4436     }
4437   return ret;
4438 }
4439
4440 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4441 {
4442   std::vector<std::string> ret;
4443   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4444     {
4445       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4446       ret.insert(ret.end(),tmp.begin(),tmp.end());
4447     }
4448   return ret;
4449 }
4450
4451 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4452 {
4453   std::vector<std::string> ret;
4454   std::set<std::string> ret2;
4455   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4456     {
4457       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4458       ret.insert(ret.end(),tmp.begin(),tmp.end());
4459     }
4460   return ret;
4461 }
4462
4463 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4464 {
4465   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4466     (*it)->changePflsRefsNamesGen(mapOfModif);
4467 }
4468
4469 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4470 {
4471   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4472     (*it)->changeLocsRefsNamesGen(mapOfModif);
4473 }
4474
4475 /*!
4476  * Returns all attributes of parts of \a this field lying on a given mesh.
4477  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4478  * item of every of returned sequences refers to the _i_-th part of \a this field.
4479  * Thus all sequences returned by this method are of the same length equal to number
4480  * of different types of supporting entities.<br>
4481  * A field part can include sub-parts with several different spatial discretizations,
4482  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4483  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4484  * of a nested sequence corresponds to a type of spatial discretization.<br>
4485  * This method allows for iteration over MEDFile DataStructure without any overhead.
4486  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4487  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4488  *          not checked if \a mname == \c NULL).
4489  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4490  *          a field part is returned. 
4491  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4492  *          This sequence is of the same length as \a types. 
4493  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4494  *          discretization. A profile name can be empty.
4495  *          Length of this and of nested sequences is the same as that of \a typesF.
4496  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4497  *          discretization. A localization name can be empty.
4498  *          Length of this and of nested sequences is the same as that of \a typesF.
4499  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4500  *          of ids of tuples within the data array, per each type of spatial
4501  *          discretization within one mesh entity type. 
4502  *          Length of this and of nested sequences is the same as that of \a typesF.
4503  *  \throw If no field is lying on \a mname.
4504  */
4505 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
4506 {
4507   int meshId=0;
4508   if(!mname.empty())
4509     meshId=getMeshIdFromMeshName(mname);
4510   else
4511     if(_field_per_mesh.empty())
4512       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4513   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4514 }
4515
4516 /*!
4517  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4518  * maximal absolute dimension and values returned via the out parameter \a levs are 
4519  * dimensions relative to the maximal absolute dimension. <br>
4520  * This method is designed for MEDFileField1TS instances that have a discretization
4521  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4522  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4523  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4524  * Only these 3 discretizations will be taken into account here. If \a this is
4525  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4526  * This method is useful to make the link between the dimension of the underlying mesh
4527  * and the levels of \a this, because it is possible that the highest dimension of \a this
4528  * field is not equal to the dimension of the underlying mesh.
4529  * 
4530  * Let's consider the following case:
4531  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4532  * TETRA4, HEXA8, TRI3 and SEG2.
4533  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4534  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4535  *
4536  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4537  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4538  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4539  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4540  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4541  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4542  * For example<br>
4543  * to retrieve the highest level of
4544  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4545  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4546  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4547  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4548  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4549  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4550  *          not checked if \a mname == \c NULL).
4551  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4552  *          absolute one. They are in decreasing order. This sequence is cleared before
4553  *          filling it in.
4554  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4555  *  \throw If no field is lying on \a mname.
4556  */
4557 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4558 {
4559   levs.clear();
4560   int meshId=getMeshIdFromMeshName(mname);
4561   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4562   std::vector< std::vector<TypeOfField> > typesF;
4563   std::vector< std::vector<std::string> > pfls, locs;
4564   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4565   if(types.empty())
4566     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4567   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4568   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4569     return -1;
4570   st.erase(INTERP_KERNEL::NORM_ERROR);
4571   std::set<int> ret1;
4572   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4573     {
4574       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4575       ret1.insert((int)cm.getDimension());
4576     }
4577   int ret=*std::max_element(ret1.begin(),ret1.end());
4578   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4579   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4580   return ret;
4581 }
4582
4583 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4584 {
4585   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4586     if((*it).isNotNull())
4587       (*it)->convertMedBallIntoClassic();
4588 }
4589
4590 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4591 {
4592   if(!pfl)
4593     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4594   std::string name(pfl->getName());
4595   pfl->checkAllocated();
4596   if(pfl->getNumberOfComponents()!=1)
4597     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4598   if(name.empty())
4599     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4600   if(_field_per_mesh.size()!=1)
4601     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4602   MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4603   if(fpm.isNull())
4604     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4605   MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4606   if(disc->getType()!=tof)
4607     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4608   int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4609   DataArray *arr(getUndergroundDataArray());
4610   int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4611   if(delta<0)
4612     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4613   MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4614   MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4615   MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4616   arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4617   arrOut->copyStringInfoFrom(*arr);
4618   arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4619   arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4620   arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4621   setArray(arrOut);
4622   disc->setEnd(e-delta);
4623   disc->setProfile(name);
4624 }
4625
4626 /*!
4627  * \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.
4628  * \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.
4629  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4630  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4631  */
4632 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4633 {
4634   int mid=getMeshIdFromMeshName(mName);
4635   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4636 }
4637
4638 /*!
4639  * \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.
4640  * \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.
4641  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4642  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4643  */
4644 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4645 {
4646   int mid=getMeshIdFromMeshName(mName);
4647   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4648 }
4649
4650 /*!
4651  * \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.
4652  */
4653 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4654 {
4655   if(_field_per_mesh.empty())
4656     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4657   if(mName.empty())
4658     return 0;
4659   std::string mName2(mName);
4660   int ret=0;
4661   std::vector<std::string> msg;
4662   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4663     if(mName2==(*it)->getMeshName())
4664       return ret;
4665     else
4666       msg.push_back((*it)->getMeshName());
4667   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4668   oss << "Possible meshes are : ";
4669   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4670     oss << "\"" << (*it2) << "\" ";
4671   throw INTERP_KERNEL::Exception(oss.str());
4672 }
4673
4674 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4675 {
4676   if(!mesh)
4677     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4678   std::string tmp(mesh->getName());
4679   if(tmp.empty())
4680     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4681   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4682   int i=0;
4683   for(;it!=_field_per_mesh.end();it++,i++)
4684     {
4685       if((*it)->getMeshName()==tmp)
4686         return i;
4687     }
4688   int sz=_field_per_mesh.size();
4689   _field_per_mesh.resize(sz+1);
4690   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4691   return sz;
4692 }
4693
4694 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4695                                                                    MEDFileFieldGlobsReal& glob)
4696 {
4697   bool ret=false;
4698   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4699     {
4700       MEDFileFieldPerMesh *fpm(*it);
4701       if(fpm)
4702         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4703     }
4704   return ret;
4705 }
4706
4707 /*!
4708  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4709  * splitting that leads to single spatial discretization of this.
4710  *
4711  * \sa splitMultiDiscrPerGeoTypes
4712  */
4713 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4714 {
4715   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4716   std::vector< std::vector<TypeOfField> > typesF;
4717   std::vector< std::vector<std::string> > pfls,locs;
4718   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4719   std::set<TypeOfField> allEnt;
4720   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4721     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4722       allEnt.insert(*it2);
4723   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4724   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4725   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4726     {
4727       std::vector< std::pair<int,int> > its;
4728       ret[i]=shallowCpy();
4729       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4730       ret[i]->updateData(newLgth,its);
4731     }
4732   return ret;
4733 }
4734
4735 /*!
4736  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4737  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4738  *
4739  * \sa splitDiscretizations
4740  */
4741 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4742 {
4743   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4744   std::vector< std::vector<TypeOfField> > typesF;
4745   std::vector< std::vector<std::string> > pfls,locs;
4746   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4747   std::set<TypeOfField> allEnt;
4748   std::size_t nbOfMDPGT(0),ii(0);
4749   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4750     {
4751       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4752       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4753         allEnt.insert(*it2);
4754     }
4755   if(allEnt.size()!=1)
4756     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4757   if(nbOfMDPGT==0)
4758     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4759   if(nbOfMDPGT==1)
4760     {
4761       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4762       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4763       return ret0;
4764     }
4765   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4766   for(std::size_t i=0;i<nbOfMDPGT;i++)
4767     {
4768       std::vector< std::pair<int,int> > its;
4769       ret[i]=shallowCpy();
4770       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4771       ret[i]->updateData(newLgth,its);
4772     }
4773   return ret;
4774 }
4775
4776 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4777 {
4778   int globalCounter(0);
4779   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4780     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4781   return globalCounter;
4782 }
4783
4784 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4785 {
4786   int globalCounter(0);
4787   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4788     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4789   return globalCounter;
4790 }
4791
4792 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4793 {
4794   if(_nb_of_tuples_to_be_allocated>=0)
4795     {
4796       _nb_of_tuples_to_be_allocated=newLgth;
4797       const DataArray *oldArr(getUndergroundDataArray());
4798       if(oldArr)
4799         {
4800           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4801           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4802           setArray(newArr);
4803           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4804         }
4805       return ;
4806     }
4807   if(_nb_of_tuples_to_be_allocated==-1)
4808     return ;
4809   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4810     {
4811       const DataArray *oldArr(getUndergroundDataArray());
4812       if(!oldArr || !oldArr->isAllocated())
4813         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4814       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4815       newArr->alloc(newLgth,getNumberOfComponents());
4816       if(oldArr)
4817         newArr->copyStringInfoFrom(*oldArr);
4818       int pos=0;
4819       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4820         {
4821           if((*it).second<(*it).first)
4822             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4823           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4824           pos+=(*it).second-(*it).first;
4825         }
4826       setArray(newArr);
4827       return ;
4828     }
4829   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4830 }
4831
4832 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4833 {
4834   if(_field_per_mesh.empty())
4835     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4836   if(_field_per_mesh.size()>1)
4837     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4838   _field_per_mesh[0]->copyOptionsFrom(opts);
4839   _field_per_mesh[0]->writeLL(fid,nasc);
4840 }
4841
4842 /*!
4843  * 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.
4844  * If false is returned the memory allocation is not required.
4845  */
4846 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4847 {
4848   if(_nb_of_tuples_to_be_allocated>=0)
4849     {
4850       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4851       _nb_of_tuples_to_be_allocated=-2;
4852       return true;
4853     }
4854   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4855     return false;
4856   if(_nb_of_tuples_to_be_allocated==-1)
4857     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4858   if(_nb_of_tuples_to_be_allocated<-3)
4859     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4860   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4861 }
4862
4863 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4864 {
4865   med_int numdt,numit;
4866   med_float dt;
4867   med_int nmesh;
4868   med_bool localMesh;
4869   med_int meshnumdt,meshnumit;
4870   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4871   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4872   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4873   if(_iteration!=numdt || _order!=numit)
4874     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4875   _field_per_mesh.resize(nmesh);
4876   //
4877   MEDFileMesh *mm(0);
4878   if(ms)
4879     {
4880       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4881       mm=ms->getMeshWithName(meshNameCpp);
4882     }
4883   //
4884   for(int i=0;i<nmesh;i++)
4885     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4886   _nb_of_tuples_to_be_allocated=0;
4887   for(int i=0;i<nmesh;i++)
4888     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4889 }
4890
4891 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4892 {
4893   allocIfNecessaryTheArrayToReceiveDataFromFile();
4894   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4895     (*it)->loadBigArraysRecursively(fid,nasc);
4896 }
4897
4898 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4899 {
4900   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4901     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4902       (*it)->loadBigArraysRecursively(fid,nasc);
4903 }
4904
4905 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4906 {
4907   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4908   loadBigArraysRecursively(fid,nasc);
4909 }
4910
4911 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4912 {
4913   DataArray *thisArr(getUndergroundDataArray());
4914   if(thisArr && thisArr->isAllocated())
4915     {
4916       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4917       thisArr->desallocate();
4918     }
4919 }
4920
4921 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4922 {
4923   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4924 }
4925
4926 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4927 {
4928   std::vector<const BigMemoryObject *> ret;
4929   if(getUndergroundDataArray())
4930     ret.push_back(getUndergroundDataArray());
4931   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4932     ret.push_back((const MEDFileFieldPerMesh *)*it);
4933   return ret;
4934 }
4935
4936 /*!
4937  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4938  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4939  * "Sort By Type"), if not, an exception is thrown. 
4940  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4941  *  \param [in] arr - the array of values.
4942  *  \param [in,out] glob - the global data where profiles and localization present in
4943  *          \a field, if any, are added.
4944  *  \throw If the name of \a field is empty.
4945  *  \throw If the data array of \a field is not set.
4946  *  \throw If \a this->_arr is already allocated but has different number of components
4947  *         than \a field.
4948  *  \throw If the underlying mesh of \a field has no name.
4949  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4950  */
4951 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4952 {
4953   const MEDCouplingMesh *mesh=field->getMesh();
4954   //
4955   TypeOfField type=field->getTypeOfField();
4956   std::vector<DataArrayInt *> dummy;
4957   int start=copyTinyInfoFrom(field,arr);
4958   int pos=addNewEntryIfNecessary(mesh);
4959   if(type!=ON_NODES)
4960     {
4961       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4962       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4963     }
4964   else
4965     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4966 }
4967
4968 /*!
4969  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4970  * of a given mesh are used as the support of the given field (a real support is not used). 
4971  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4972  * Order of underlying mesh entities of the given field specified by \a profile parameter
4973  * is not prescribed; this method permutes field values to have them sorted by element
4974  * type as required for writing to MED file. A new profile is added only if no equal
4975  * profile is missing. 
4976  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4977  *  \param [in] arrOfVals - the values of the field \a field used.
4978  *  \param [in] mesh - the supporting mesh of \a field.
4979  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4980  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4981  *  \param [in,out] glob - the global data where profiles and localization present in
4982  *          \a field, if any, are added.
4983  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4984  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4985  *  \throw If the data array of \a field is not set.
4986  *  \throw If \a this->_arr is already allocated but has different number of components
4987  *         than \a field.
4988  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4989  *  \sa setFieldNoProfileSBT()
4990  */
4991 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4992 {
4993   if(!field)
4994     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4995   if(!arrOfVals || !arrOfVals->isAllocated())
4996     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4997   TypeOfField type=field->getTypeOfField();
4998   std::vector<DataArrayInt *> idsInPflPerType;
4999   std::vector<DataArrayInt *> idsPerType;
5000   std::vector<int> code,code2;
5001   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5002   if(type!=ON_NODES)
5003     {
5004       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5005       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5006       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
5007       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5008       // start of check
5009       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5010       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5011       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5012         {
5013           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5014           throw INTERP_KERNEL::Exception(oss.str());
5015         }
5016       // end of check
5017       int start=copyTinyInfoFrom(field,arrOfVals);
5018       code2=m->getDistributionOfTypes();
5019       //
5020       int pos=addNewEntryIfNecessary(m);
5021       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5022     }
5023   else
5024     {
5025       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5026         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5027       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5028       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5029       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5030       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5031         {
5032           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5033           throw INTERP_KERNEL::Exception(oss.str());
5034         }
5035       int start=copyTinyInfoFrom(field,arrOfVals);
5036       int pos=addNewEntryIfNecessary(m);
5037       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5038     }
5039 }
5040
5041 /*!
5042  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5043  */
5044 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5045 {
5046   if(_nb_of_tuples_to_be_allocated>=0)
5047     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 !");
5048   DataArray *arr(getOrCreateAndGetArray());
5049   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5050   _nb_of_tuples_to_be_allocated=-3;
5051 }
5052
5053 /*!
5054  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5055  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5056  * larger by the size of \a field. Returns an id of the first not filled
5057  * tuple of \a this->_arr.
5058  *  \param [in] field - the field to copy the info on components and the name from.
5059  *  \return int - the id of first not initialized tuple of \a this->_arr.
5060  *  \throw If the name of \a field is empty.
5061  *  \throw If the data array of \a field is not set.
5062  *  \throw If \a this->_arr is already allocated but has different number of components
5063  *         than \a field.
5064  */
5065 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5066 {
5067   if(!field)
5068     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5069   std::string name(field->getName());
5070   setName(name.c_str());
5071   setDtUnit(field->getTimeUnit());
5072   if(name.empty())
5073     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5074   if(!arr)
5075     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5076   if(!arr->isAllocated())
5077     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5078   _dt=field->getTime(_iteration,_order);
5079   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5080   if(!getOrCreateAndGetArray()->isAllocated())
5081     {
5082       allocNotFromFile(arr->getNumberOfTuples());
5083       return 0;
5084     }
5085   else
5086     {
5087       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5088       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5089       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5090       _nb_of_tuples_to_be_allocated=-3;
5091       return oldNbOfTuples;
5092     }
5093 }
5094
5095 /*!
5096  * Returns number of components in \a this field
5097  *  \return int - the number of components.
5098  */
5099 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5100 {
5101   return getOrCreateAndGetArray()->getNumberOfComponents();
5102 }
5103
5104 /*!
5105  * Change info on components in \a this.
5106  * \throw If size of \a infos is not equal to the number of components already in \a this.
5107  */
5108 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5109 {
5110   DataArray *arr=getOrCreateAndGetArray();
5111   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5112 }
5113
5114 /*!
5115  * Returns info on components of \a this field.
5116  *  \return const std::vector<std::string>& - a sequence of strings each being an
5117  *          information on _i_-th component.
5118  */
5119 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5120 {
5121   const DataArray *arr=getOrCreateAndGetArray();
5122   return arr->getInfoOnComponents();
5123 }
5124
5125 /*!
5126  * Returns a mutable info on components of \a this field.
5127  *  \return std::vector<std::string>& - a sequence of strings each being an
5128  *          information on _i_-th component.
5129  */
5130 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5131 {
5132   DataArray *arr=getOrCreateAndGetArray();
5133   return arr->getInfoOnComponents();
5134 }
5135
5136 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5137 {
5138   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5139     {
5140       const MEDFileFieldPerMesh *fpm(*it);
5141       if(!fpm)
5142         continue;
5143       if(fpm->presenceOfMultiDiscPerGeoType())
5144         return true;
5145     }
5146   return false;
5147 }
5148
5149 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5150 {
5151   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5152     if((*it).isNotNull())
5153       if((*it)->presenceOfStructureElements())
5154         return true;
5155   return false;
5156 }
5157
5158 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5159 {
5160   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5161     if((*it).isNotNull())
5162       if(!(*it)->onlyStructureElements())
5163         return false;
5164   return true;
5165 }
5166
5167 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5168 {
5169   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5170     if((*it).isNotNull())
5171       (*it)->killStructureElements();
5172 }
5173
5174 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5175 {
5176   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5177     if((*it).isNotNull())
5178       (*it)->keepOnlyStructureElements();
5179 }
5180
5181 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5182 {
5183   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5184     if((*it).isNotNull())
5185       (*it)->keepOnlyOnSE(seName);
5186 }
5187
5188 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5189 {
5190   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5191     if((*it).isNotNull())
5192       (*it)->getMeshSENames(ps);
5193 }
5194
5195 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5196 {
5197   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 !";
5198   if(_field_per_mesh.empty())
5199     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5200   if(_field_per_mesh.size()>1)
5201     throw INTERP_KERNEL::Exception(MSG0);
5202   if(_field_per_mesh[0].isNull())
5203     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5204   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5205   std::set<TypeOfField> types;
5206   pm->fillTypesOfFieldAvailable(types);
5207   if(types.size()!=1)
5208     throw INTERP_KERNEL::Exception(MSG0);
5209   TypeOfField type(*types.begin());
5210   int meshDimRelToMax(0);
5211   if(type==ON_NODES)
5212     meshDimRelToMax=0;
5213   else
5214     {
5215       int myDim(std::numeric_limits<int>::max());
5216       bool isUnique(pm->isUniqueLevel(myDim));
5217       if(!isUnique)
5218         throw INTERP_KERNEL::Exception(MSG0);
5219       meshDimRelToMax=myDim-mesh->getMeshDimension();
5220       if(meshDimRelToMax>0)
5221         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5222     }
5223   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5224 }
5225
5226 /*!
5227  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5228  *  \param [in] type - a spatial discretization of the new field.
5229  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5230  *  \param [in] mName - a name of the supporting mesh.
5231  *  \param [in] renumPol - specifies how to permute values of the result field according to
5232  *          the optional numbers of cells and nodes, if any. The valid values are
5233  *          - 0 - do not permute.
5234  *          - 1 - permute cells.
5235  *          - 2 - permute nodes.
5236  *          - 3 - permute cells and nodes.
5237  *
5238  *  \param [in] glob - the global data storing profiles and localization.
5239  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5240  *          caller is to delete this field using decrRef() as it is no more needed. 
5241  *  \throw If the MED file is not readable.
5242  *  \throw If there is no mesh named \a mName in the MED file.
5243  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5244  *  \throw If no field of \a this is lying on the mesh \a mName.
5245  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5246  */
5247 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5248 {
5249   MCAuto<MEDFileMesh> mm;
5250   if(mName.empty())
5251     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5252   else
5253     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5254   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5255 }
5256
5257 /*!
5258  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5259  *  \param [in] type - a spatial discretization of the new field.
5260  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5261  *  \param [in] renumPol - specifies how to permute values of the result field according to
5262  *          the optional numbers of cells and nodes, if any. The valid values are
5263  *          - 0 - do not permute.
5264  *          - 1 - permute cells.
5265  *          - 2 - permute nodes.
5266  *          - 3 - permute cells and nodes.
5267  *
5268  *  \param [in] glob - the global data storing profiles and localization.
5269  *  \param [in] mesh - the supporting mesh.
5270  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5271  *          caller is to delete this field using decrRef() as it is no more needed. 
5272  *  \throw If the MED file is not readable.
5273  *  \throw If no field of \a this is lying on \a mesh.
5274  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5275  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5276  */
5277 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5278 {
5279   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5280   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5281   if(meshDimRelToMax==1)
5282     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5283   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5284 }
5285
5286 /*!
5287  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5288  * given mesh. 
5289  *  \param [in] type - a spatial discretization of the new field.
5290  *  \param [in] mName - a name of the supporting mesh.
5291  *  \param [in] renumPol - specifies how to permute values of the result field according to
5292  *          the optional numbers of cells and nodes, if any. The valid values are
5293  *          - 0 - do not permute.
5294  *          - 1 - permute cells.
5295  *          - 2 - permute nodes.
5296  *          - 3 - permute cells and nodes.
5297  *
5298  *  \param [in] glob - the global data storing profiles and localization.
5299  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5300  *          caller is to delete this field using decrRef() as it is no more needed. 
5301  *  \throw If the MED file is not readable.
5302  *  \throw If there is no mesh named \a mName in the MED file.
5303  *  \throw If there are no mesh entities in the mesh.
5304  *  \throw If no field values of the given \a type are available.
5305  */
5306 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5307 {
5308   MCAuto<MEDFileMesh> mm;
5309   if(mName.empty())
5310     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5311   else
5312     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5313   int absDim=getDimension();
5314   int meshDimRelToMax=absDim-mm->getMeshDimension();
5315   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5316 }
5317
5318 /*!
5319  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5320  *  \param [in] type - a spatial discretization of the new field.
5321  *  \param [in] renumPol - specifies how to permute values of the result field according to
5322  *          the optional numbers of cells and nodes, if any. The valid values are
5323  *          - 0 - do not permute.
5324  *          - 1 - permute cells.
5325  *          - 2 - permute nodes.
5326  *          - 3 - permute cells and nodes.
5327  *
5328  *  \param [in] glob - the global data storing profiles and localization.
5329  *  \param [in] mesh - the supporting mesh.
5330  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5331  *         field according to \a renumPol.
5332  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5333  *         field according to \a renumPol.
5334  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5335  *          caller is to delete this field using decrRef() as it is no more needed. 
5336  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5337  *  \throw If no field of \a this is lying on \a mesh.
5338  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5339  */
5340 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
5341 {
5342   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5343   int meshId=getMeshIdFromMeshName(mesh->getName());
5344   bool isPfl=false;
5345   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5346   switch(renumPol)
5347   {
5348     case 0:
5349       {
5350         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5351         return ret.retn();
5352       }
5353     case 3:
5354     case 1:
5355       {
5356         if(isPfl)
5357           throw INTERP_KERNEL::Exception(msg1);
5358         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5359         if(cellRenum)
5360           {
5361             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5362               {
5363                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5364                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5365                 throw INTERP_KERNEL::Exception(oss.str());
5366               }
5367             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5368             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5369             std::vector<DataArray *> arrOut2(1,arrOut);
5370             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5371             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5372             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5373           }
5374         if(renumPol==1)
5375           return ret.retn();
5376       }
5377     case 2:
5378       {
5379         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5380         if(isPfl)
5381           throw INTERP_KERNEL::Exception(msg1);
5382         if(nodeRenum)
5383           {
5384             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5385               {
5386                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5387                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5388                 throw INTERP_KERNEL::Exception(oss.str());
5389               }
5390             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5391             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5392               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5393             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5394           }
5395         return ret.retn();
5396       }
5397     default:
5398       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5399   }
5400 }
5401
5402 /*!
5403  * Returns values and a profile of the field of a given type lying on a given support.
5404  *  \param [in] type - a spatial discretization of the field.
5405  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5406  *  \param [in] mesh - the supporting mesh.
5407  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5408  *          field of interest lies on. If the field lies on all entities of the given
5409  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5410  *          using decrRef() as it is no more needed.  
5411  *  \param [in] glob - the global data storing profiles and localization.
5412  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5413  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5414  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5415  *  \throw If no field of \a this is lying on \a mesh.
5416  *  \throw If no field values of the given \a type are available.
5417  */
5418 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5419 {
5420   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5421   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5422   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5423   ret->setName(nasc.getName().c_str());
5424   return ret.retn();
5425 }
5426
5427 //= MEDFileField1TSWithoutSDA
5428
5429 /*!
5430  * Throws if a given value is not a valid (non-extended) relative dimension.
5431  *  \param [in] meshDimRelToMax - the relative dimension value.
5432  *  \throw If \a meshDimRelToMax > 0.
5433  */
5434 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5435 {
5436   if(meshDimRelToMax>0)
5437     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5438 }
5439
5440 /*!
5441  * Checks if elements of a given mesh are in the order suitable for writing 
5442  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5443  * vector describing types of elements and their number.
5444  *  \param [in] mesh - the mesh to check.
5445  *  \return std::vector<int> - a vector holding for each element type (1) item of
5446  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5447  *          These values are in full-interlace mode.
5448  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5449  */
5450 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5451 {
5452   if(!mesh)
5453     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5454   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5455   int nbOfTypes=geoTypes.size();
5456   std::vector<int> code(3*nbOfTypes);
5457   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5458   arr1->alloc(nbOfTypes,1);
5459   int *arrPtr=arr1->getPointer();
5460   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5461   for(int i=0;i<nbOfTypes;i++,it++)
5462     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5463   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5464   const int *arrPtr2=arr2->getConstPointer();
5465   int i=0;
5466   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5467     {
5468       int pos=arrPtr2[i];
5469       int nbCells=mesh->getNumberOfCellsWithType(*it);
5470       code[3*pos]=(int)(*it);
5471       code[3*pos+1]=nbCells;
5472       code[3*pos+2]=-1;//no profiles
5473     }
5474   std::vector<const DataArrayInt *> idsPerType;//no profiles
5475   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5476   if(da)
5477     {
5478       da->decrRef();
5479       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5480     }
5481   return code;
5482 }
5483
5484 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5485 {
5486   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5487 }
5488
5489 /*!
5490  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5491  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5492  * item of every of returned sequences refers to the _i_-th part of \a this field.
5493  * Thus all sequences returned by this method are of the same length equal to number
5494  * of different types of supporting entities.<br>
5495  * A field part can include sub-parts with several different spatial discretizations,
5496  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5497  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5498  * of a nested sequence corresponds to a type of spatial discretization.<br>
5499  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5500  * The overhead is due to selecting values into new instances of DataArrayDouble.
5501  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5502  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5503  *          not checked if \a mname == \c NULL).
5504  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5505  *          a field part is returned. 
5506  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5507  *          A field part can include sub-parts with several different spatial discretizations,
5508  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5509  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5510  *          This sequence is of the same length as \a types. 
5511  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5512  *          discretization. A profile name can be empty.
5513  *          Length of this and of nested sequences is the same as that of \a typesF.
5514  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5515  *          discretization. A localization name can be empty.
5516  *          Length of this and of nested sequences is the same as that of \a typesF.
5517  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5518  *          per each type of spatial discretization within one mesh entity type.
5519  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5520  *          Length of this and of nested sequences is the same as that of \a typesF.
5521  *  \throw If no field is lying on \a mname.
5522  */
5523 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
5524 {
5525   int meshId=0;
5526   if(!mname.empty())
5527     meshId=getMeshIdFromMeshName(mname);
5528   else
5529     if(_field_per_mesh.empty())
5530       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5531   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5532   int nbOfRet=ret0.size();
5533   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5534   for(int i=0;i<nbOfRet;i++)
5535     {
5536       const std::vector< std::pair<int,int> >& p=ret0[i];
5537       int nbOfRet1=p.size();
5538       ret[i].resize(nbOfRet1);
5539       for(int j=0;j<nbOfRet1;j++)
5540         {
5541           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5542           ret[i][j]=tmp;
5543         }
5544     }
5545   return ret;
5546 }
5547
5548 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5549 {
5550   return TYPE_STR;
5551 }
5552
5553 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5554 {
5555   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5556   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5557   ret->deepCpyLeavesFrom(*this);
5558   const DataArrayDouble *arr(_arr);
5559   if(arr)
5560     {
5561       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5562       ret->setArray(arr2);
5563     }
5564   return ret.retn();
5565 }
5566
5567 /*!
5568  * Returns a pointer to the underground DataArrayDouble instance and a
5569  * sequence describing parameters of a support of each part of \a this field. The
5570  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5571  * direct access to the field values. This method is intended for the field lying on one
5572  * mesh only.
5573  *  \param [in,out] entries - the sequence describing parameters of a support of each
5574  *         part of \a this field. Each item of this sequence consists of two parts. The
5575  *         first part describes a type of mesh entity and an id of discretization of a
5576  *         current field part. The second part describes a range of values [begin,end)
5577  *         within the returned array relating to the current field part.
5578  *  \return DataArrayDouble * - the pointer to the field values array.
5579  *  \throw If the number of underlying meshes is not equal to 1.
5580  *  \throw If no field values are available.
5581  *  \sa getUndergroundDataArray()
5582  */
5583 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5584 {
5585   if(_field_per_mesh.size()!=1)
5586     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5587   if(_field_per_mesh[0]==0)
5588     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5589   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5590   return getUndergroundDataArrayTemplate();
5591 }
5592
5593 /*!
5594  * Returns a pointer to the underground DataArrayDouble instance and a
5595  * sequence describing parameters of a support of each part of \a this field. The
5596  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5597  * direct access to the field values. This method is intended for the field lying on one
5598  * mesh only.
5599  *  \param [in,out] entries - the sequence describing parameters of a support of each
5600  *         part of \a this field. Each item of this sequence consists of two parts. The
5601  *         first part describes a type of mesh entity and an id of discretization of a
5602  *         current field part. The second part describes a range of values [begin,end)
5603  *         within the returned array relating to the current field part.
5604  *  \return DataArrayDouble * - the pointer to the field values array.
5605  *  \throw If the number of underlying meshes is not equal to 1.
5606  *  \throw If no field values are available.
5607  *  \sa getUndergroundDataArray()
5608  */
5609 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5610 {
5611   return getUndergroundDataArrayDoubleExt(entries);
5612 }
5613
5614 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5615 {
5616   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5617   arr->setInfoAndChangeNbOfCompo(infos);
5618 }
5619
5620 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5621 {
5622 }
5623
5624 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5625 {
5626   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5627   ret->deepCpyLeavesFrom(*this);
5628   return ret.retn();
5629 }
5630
5631 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5632 {
5633   MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5634   if(_arr.isNotNull())
5635     ret->_arr=_arr->deepCopy();
5636   return ret.retn();
5637 }
5638
5639 //= MEDFileIntField1TSWithoutSDA
5640
5641 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5642 {
5643   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5644 }
5645
5646 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5647 {
5648 }
5649
5650 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5651                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5652 {
5653   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5654   arr->setInfoAndChangeNbOfCompo(infos);
5655 }
5656
5657 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5658 {
5659   return TYPE_STR;
5660 }
5661
5662 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5663 {
5664   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5665   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5666   ret->deepCpyLeavesFrom(*this);
5667   const DataArrayInt *arr(_arr);
5668   if(arr)
5669     {
5670       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5671       ret->setArray(arr2);
5672     }
5673   return ret.retn();
5674 }
5675
5676 /*!
5677  * Returns a pointer to the underground DataArrayInt instance and a
5678  * sequence describing parameters of a support of each part of \a this field. The
5679  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5680  * direct access to the field values. This method is intended for the field lying on one
5681  * mesh only.
5682  *  \param [in,out] entries - the sequence describing parameters of a support of each
5683  *         part of \a this field. Each item of this sequence consists of two parts. The
5684  *         first part describes a type of mesh entity and an id of discretization of a
5685  *         current field part. The second part describes a range of values [begin,end)
5686  *         within the returned array relating to the current field part.
5687  *  \return DataArrayInt * - the pointer to the field values array.
5688  *  \throw If the number of underlying meshes is not equal to 1.
5689  *  \throw If no field values are available.
5690  *  \sa getUndergroundDataArray()
5691  */
5692 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5693 {
5694   return getUndergroundDataArrayIntExt(entries);
5695 }
5696
5697 /*!
5698  * Returns a pointer to the underground DataArrayInt instance and a
5699  * sequence describing parameters of a support of each part of \a this field. The
5700  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5701  * direct access to the field values. This method is intended for the field lying on one
5702  * mesh only.
5703  *  \param [in,out] entries - the sequence describing parameters of a support of each
5704  *         part of \a this field. Each item of this sequence consists of two parts. The
5705  *         first part describes a type of mesh entity and an id of discretization of a
5706  *         current field part. The second part describes a range of values [begin,end)
5707  *         within the returned array relating to the current field part.
5708  *  \return DataArrayInt * - the pointer to the field values array.
5709  *  \throw If the number of underlying meshes is not equal to 1.
5710  *  \throw If no field values are available.
5711  *  \sa getUndergroundDataArray()
5712  */
5713 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5714 {
5715   if(_field_per_mesh.size()!=1)
5716     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5717   if(_field_per_mesh[0]==0)
5718     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5719   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5720   return getUndergroundDataArrayTemplate();
5721 }
5722
5723 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5724 {
5725   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5726   ret->deepCpyLeavesFrom(*this);
5727   return ret.retn();
5728 }
5729
5730 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5731 {
5732   MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5733   if(_arr.isNotNull())
5734     ret->_arr=_arr->deepCopy();
5735   return ret.retn();
5736 }
5737
5738 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5739 {
5740 }
5741
5742 //= MEDFileAnyTypeField1TS
5743
5744 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5745 {
5746   med_field_type typcha;
5747   //
5748   std::vector<std::string> infos;
5749   std::string dtunit,fieldName;
5750   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5751   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5752   switch(typcha)
5753   {
5754     case MED_FLOAT64:
5755       {
5756         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5757         break;
5758       }
5759     case MED_INT32:
5760       {
5761         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5762         break;
5763       }
5764     default:
5765       {
5766         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] !";
5767         throw INTERP_KERNEL::Exception(oss.str());
5768       }
5769   }
5770   ret->setDtUnit(dtunit.c_str());
5771   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5772   //
5773   med_int numdt,numit;
5774   med_float dt;
5775   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5776   ret->setTime(numdt,numit,dt);
5777   ret->_csit=1;
5778   if(loadAll)
5779     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5780   else
5781     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5782   return ret.retn();
5783 }
5784
5785 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5786 try:MEDFileFieldGlobsReal(fid)
5787 {
5788   _content=BuildContentFrom(fid,loadAll,ms);
5789   loadGlobals(fid);
5790 }
5791 catch(INTERP_KERNEL::Exception& e)
5792 {
5793     throw e;
5794 }
5795
5796 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5797 {
5798   med_field_type typcha;
5799   std::vector<std::string> infos;
5800   std::string dtunit;
5801   int iii=-1;
5802   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5803   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5804   switch(typcha)
5805   {
5806     case MED_FLOAT64:
5807       {
5808         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5809         break;
5810       }
5811     case MED_INT32:
5812       {
5813         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5814         break;
5815       }
5816     default:
5817       {
5818         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] !";
5819         throw INTERP_KERNEL::Exception(oss.str());
5820       }
5821   }
5822   ret->setDtUnit(dtunit.c_str());
5823   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5824   //
5825   if(nbSteps<1)
5826     {
5827       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5828       throw INTERP_KERNEL::Exception(oss.str());
5829     }
5830   //
5831   med_int numdt,numit;
5832   med_float dt;
5833   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5834   ret->setTime(numdt,numit,dt);
5835   ret->_csit=1;
5836   if(loadAll)
5837     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5838   else
5839     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5840   return ret.retn();
5841 }
5842
5843 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5844 try:MEDFileFieldGlobsReal(fid)
5845 {
5846   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5847   loadGlobals(fid);
5848 }
5849 catch(INTERP_KERNEL::Exception& e)
5850 {
5851     throw e;
5852 }
5853
5854 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5855 {
5856   if(!c)
5857     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5858   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5859     {
5860       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5861       ret->_content=c; c->incrRef();
5862       return ret.retn();
5863     }
5864   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5865     {
5866       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5867       ret->_content=c; c->incrRef();
5868       return ret.retn();
5869     }
5870   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5871 }
5872
5873 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5874 {
5875   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5876   ret->setFileName(FileNameFromFID(fid));
5877   return ret;
5878 }
5879
5880 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5881 {
5882   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5883   return New(fid,loadAll);
5884 }
5885
5886 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5887 {
5888   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5889   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5890   ret->loadGlobals(fid);
5891   return ret.retn();
5892 }
5893
5894 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5895 {
5896   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5897   return New(fid,fieldName,loadAll);
5898 }
5899
5900 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5901 {
5902   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5903   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5904   ret->loadGlobals(fid);
5905   return ret.retn();
5906 }
5907
5908 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5909 {
5910   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5911   return New(fid,fieldName,iteration,order,loadAll);
5912 }
5913
5914 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5915 {
5916   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5917   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5918   ret->loadGlobals(fid);
5919   return ret.retn();
5920 }
5921
5922 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5923 {
5924   med_field_type typcha;
5925   std::vector<std::string> infos;
5926   std::string dtunit;
5927   int iii(-1);
5928   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5929   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5930   switch(typcha)
5931   {
5932     case MED_FLOAT64:
5933       {
5934         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5935         break;
5936       }
5937     case MED_INT32:
5938       {
5939         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5940         break;
5941       }
5942     default:
5943       {
5944         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] !";
5945         throw INTERP_KERNEL::Exception(oss.str());
5946       }
5947   }
5948   ret->setDtUnit(dtunit.c_str());
5949   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5950   //
5951   bool found=false;
5952   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5953   for(int i=0;i<nbOfStep2 && !found;i++)
5954     {
5955       med_int numdt,numit;
5956       med_float dt;
5957       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5958       if(numdt==iteration && numit==order)
5959         {
5960           found=true;
5961           ret->_csit=i+1;
5962         }
5963       else
5964         dtits[i]=std::pair<int,int>(numdt,numit);
5965     }
5966   if(!found)
5967     {
5968       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5969       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5970         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5971       throw INTERP_KERNEL::Exception(oss.str());
5972     }
5973   if(loadAll)
5974     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5975   else
5976     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5977   return ret.retn();
5978 }
5979
5980 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5981 try:MEDFileFieldGlobsReal(fid)
5982 {
5983   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5984   loadGlobals(fid);
5985 }
5986 catch(INTERP_KERNEL::Exception& e)
5987 {
5988     throw e;
5989 }
5990
5991 /*!
5992  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5993  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5994  *
5995  * \warning this is a shallow copy constructor
5996  */
5997 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5998 {
5999   if(!shallowCopyOfContent)
6000     {
6001       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6002       otherPtr->incrRef();
6003       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6004     }
6005   else
6006     {
6007       _content=other.shallowCpy();
6008     }
6009 }
6010
6011 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)
6012 {
6013   if(checkFieldId)
6014     {
6015       int nbFields=MEDnField(fid);
6016       if(fieldIdCFormat>=nbFields)
6017         {
6018           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6019           throw INTERP_KERNEL::Exception(oss.str());
6020         }
6021     }
6022   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6023   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6024   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6025   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
6026   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6027   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6028   med_bool localMesh;
6029   int nbOfStep;
6030   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6031   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6032   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6033   infos.clear(); infos.resize(ncomp);
6034   for(int j=0;j<ncomp;j++)
6035     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6036   return nbOfStep;
6037 }
6038
6039 /*!
6040  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6041  * 
6042  * \param [out]
6043  * \return in case of success the number of time steps available for the field with name \a fieldName.
6044  */
6045 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6046 {
6047   int nbFields=MEDnField(fid);
6048   bool found=false;
6049   std::vector<std::string> fns(nbFields);
6050   int nbOfStep2(-1);
6051   for(int i=0;i<nbFields && !found;i++)
6052     {
6053       std::string tmp;
6054       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6055       fns[i]=tmp;
6056       found=(tmp==fieldName);
6057       if(found)
6058         posCFormat=i;
6059     }
6060   if(!found)
6061     {
6062       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6063       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6064         oss << "\"" << *it << "\" ";
6065       throw INTERP_KERNEL::Exception(oss.str());
6066     }
6067   return nbOfStep2;
6068 }
6069
6070 /*!
6071  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6072  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6073  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6074  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6075  * to keep a valid instance.
6076  * 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.
6077  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6078  * 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.
6079  *
6080  * \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.
6081  * \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.
6082  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
6083  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6084  * \param [in] newLocName is the new localization name.
6085  * \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.
6086  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6087  */
6088 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6089 {
6090   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6091   std::string oldPflName=disc->getProfile();
6092   std::vector<std::string> vv=getPflsReallyUsedMulti();
6093   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6094   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6095     {
6096       disc->setProfile(newPflName);
6097       DataArrayInt *pfl=getProfile(oldPflName.c_str());
6098       pfl->setName(newPflName);
6099     }
6100   else
6101     {
6102       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6103       throw INTERP_KERNEL::Exception(oss.str());
6104     }
6105 }
6106
6107 /*!
6108  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6109  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6110  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6111  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6112  * to keep a valid instance.
6113  * 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.
6114  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6115  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6116  * 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.
6117  *
6118  * \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.
6119  * \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.
6120  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
6121  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6122  * \param [in] newLocName is the new localization name.
6123  * \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.
6124  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6125  */
6126 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6127 {
6128   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6129   std::string oldLocName=disc->getLocalization();
6130   std::vector<std::string> vv=getLocsReallyUsedMulti();
6131   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6132   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6133     {
6134       disc->setLocalization(newLocName);
6135       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6136       loc.setName(newLocName);
6137     }
6138   else
6139     {
6140       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6141       throw INTERP_KERNEL::Exception(oss.str());
6142     }
6143 }
6144
6145 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6146 {
6147   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6148   if(!ret)
6149     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6150   return ret;
6151 }
6152
6153 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6154 {
6155   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6156   if(!ret)
6157     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6158   return ret;
6159 }
6160
6161 /*!
6162  * This method alloc the arrays and load potentially huge arrays contained in this field.
6163  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6164  * This method can be also called to refresh or reinit values from a file.
6165  * 
6166  * \throw If the fileName is not set or points to a non readable MED file.
6167  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6168  */
6169 void MEDFileAnyTypeField1TS::loadArrays()
6170 {
6171   if(getFileName().empty())
6172     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6173   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6174   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6175 }
6176
6177 /*!
6178  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6179  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6180  * this method does not throw if \a this does not come from file read.
6181  * 
6182  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6183  */
6184 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6185 {
6186   if(!getFileName().empty())
6187     {
6188       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6189       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6190     }
6191 }
6192
6193 /*!
6194  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6195  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6196  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6197  * 
6198  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6199  */
6200 void MEDFileAnyTypeField1TS::unloadArrays()
6201 {
6202   contentNotNullBase()->unloadArrays();
6203 }
6204
6205 /*!
6206  * 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.
6207  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6208  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6209  * 
6210  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6211  */
6212 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6213 {
6214   if(!getFileName().empty())
6215     contentNotNullBase()->unloadArrays();
6216 }
6217
6218 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6219 {
6220   int nbComp(getNumberOfComponents());
6221   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6222   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6223   for(int i=0;i<nbComp;i++)
6224     {
6225       std::string info=getInfo()[i];
6226       std::string c,u;
6227       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6228       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6229       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6230     }
6231   if(getName().empty())
6232     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6233   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6234   writeGlobals(fid,*this);
6235   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6236 }
6237
6238 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6239 {
6240   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6241 }
6242
6243 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6244 {
6245   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6246   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6247   return ret;
6248 }
6249
6250 /*!
6251  * Returns a string describing \a this field. This string is outputted 
6252  * by \c print Python command.
6253  */
6254 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6255 {
6256   std::ostringstream oss;
6257   contentNotNullBase()->simpleRepr(0,oss,-1);
6258   simpleReprGlobs(oss);
6259   return oss.str();
6260 }
6261
6262 /*!
6263  * This method returns all profiles whose name is non empty used.
6264  * \b WARNING If profile is used several times it will be reported \b only \b once.
6265  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6266  */
6267 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6268 {
6269   return contentNotNullBase()->getPflsReallyUsed2();
6270 }
6271
6272 /*!
6273  * This method returns all localizations whose name is non empty used.
6274  * \b WARNING If localization is used several times it will be reported \b only \b once.
6275  */
6276 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6277 {
6278   return contentNotNullBase()->getLocsReallyUsed2();
6279 }
6280
6281 /*!
6282  * This method returns all profiles whose name is non empty used.
6283  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6284  */
6285 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6286 {
6287   return contentNotNullBase()->getPflsReallyUsedMulti2();
6288 }
6289
6290 /*!
6291  * This method returns all localizations whose name is non empty used.
6292  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6293  */
6294 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6295 {
6296   return contentNotNullBase()->getLocsReallyUsedMulti2();
6297 }
6298
6299 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6300 {
6301   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6302 }
6303
6304 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6305 {
6306   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6307 }
6308
6309 int MEDFileAnyTypeField1TS::getDimension() const
6310 {
6311   return contentNotNullBase()->getDimension();
6312 }
6313
6314 int MEDFileAnyTypeField1TS::getIteration() const
6315 {
6316   return contentNotNullBase()->getIteration();
6317 }
6318
6319 int MEDFileAnyTypeField1TS::getOrder() const
6320 {
6321   return contentNotNullBase()->getOrder();
6322 }
6323
6324 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6325 {
6326   return contentNotNullBase()->getTime(iteration,order);
6327 }
6328
6329 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6330 {
6331   contentNotNullBase()->setTime(iteration,order,val);
6332 }
6333
6334 std::string MEDFileAnyTypeField1TS::getName() const
6335 {
6336   return contentNotNullBase()->getName();
6337 }
6338
6339 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6340 {
6341   contentNotNullBase()->setName(name);
6342 }
6343
6344 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6345 {
6346   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6347 }
6348
6349 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6350 {
6351   return contentNotNullBase()->getDtUnit();
6352 }
6353
6354 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6355 {
6356   contentNotNullBase()->setDtUnit(dtUnit);
6357 }
6358
6359 std::string MEDFileAnyTypeField1TS::getMeshName() const
6360 {
6361   return contentNotNullBase()->getMeshName();
6362 }
6363
6364 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6365 {
6366   contentNotNullBase()->setMeshName(newMeshName);
6367 }
6368
6369 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6370 {
6371   return contentNotNullBase()->changeMeshNames(modifTab);
6372 }
6373
6374 int MEDFileAnyTypeField1TS::getMeshIteration() const
6375 {
6376   return contentNotNullBase()->getMeshIteration();
6377 }
6378
6379 int MEDFileAnyTypeField1TS::getMeshOrder() const
6380 {
6381   return contentNotNullBase()->getMeshOrder();
6382 }
6383
6384 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6385 {
6386   return contentNotNullBase()->getNumberOfComponents();
6387 }
6388
6389 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6390 {
6391   return contentNotNullBase()->isDealingTS(iteration,order);
6392 }
6393
6394 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6395 {
6396   return contentNotNullBase()->getDtIt();
6397 }
6398
6399 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6400 {
6401   contentNotNullBase()->fillIteration(p);
6402 }
6403
6404 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6405 {
6406   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6407 }
6408
6409 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6410 {
6411   contentNotNullBase()->setInfo(infos);
6412 }
6413
6414 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6415 {
6416   return contentNotNullBase()->getInfo();
6417 }
6418 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6419 {
6420   return contentNotNullBase()->getInfo();
6421 }
6422
6423 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6424 {
6425   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6426 }
6427
6428 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6429 {
6430   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6431 }
6432
6433 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6434 {
6435   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6436 }
6437
6438 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6439 {
6440   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6441 }
6442
6443 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6444 {
6445   return contentNotNullBase()->convertMedBallIntoClassic();
6446 }
6447
6448 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6449 {
6450   return contentNotNullBase()->makeReduction(ct,tof,pfl);
6451 }
6452
6453 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6454 {
6455   return contentNotNullBase()->getTypesOfFieldAvailable();
6456 }
6457
6458 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,
6459                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6460 {
6461   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6462 }
6463
6464 /*!
6465  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6466  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6467  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6468  */
6469 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6470 {
6471   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6472   if(!content)
6473     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6474   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6475   std::size_t sz(contentsSplit.size());
6476   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6477   for(std::size_t i=0;i<sz;i++)
6478     {
6479       ret[i]=shallowCpy();
6480       ret[i]->_content=contentsSplit[i];
6481     }
6482   return ret;
6483 }
6484
6485 /*!
6486  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6487  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6488  */
6489 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6490 {
6491   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6492   if(!content)
6493     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6494   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6495   std::size_t sz(contentsSplit.size());
6496   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6497   for(std::size_t i=0;i<sz;i++)
6498     {
6499       ret[i]=shallowCpy();
6500       ret[i]->_content=contentsSplit[i];
6501     }
6502   return ret;
6503 }
6504
6505 /*!
6506  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6507  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6508  */
6509 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6510 {
6511   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6512   if(!content)
6513     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6514   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6515   std::size_t sz(contentsSplit.size());
6516   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6517   for(std::size_t i=0;i<sz;i++)
6518     {
6519       ret[i]=shallowCpy();
6520       ret[i]->_content=contentsSplit[i];
6521     }
6522   return ret;
6523 }
6524
6525 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6526 {
6527   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6528   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6529     ret->_content=_content->deepCopy();
6530   ret->deepCpyGlobs(*this);
6531   return ret.retn();
6532 }
6533
6534 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6535 {
6536   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6537 }
6538
6539 //= MEDFileField1TS
6540
6541 /*!
6542  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6543  * the first field that has been read from a specified MED file.
6544  *  \param [in] fileName - the name of the MED file to read.
6545  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6546  *          is to delete this field using decrRef() as it is no more needed.
6547  *  \throw If reading the file fails.
6548  */
6549 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6550 {
6551   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6552   return New(fid,loadAll);
6553 }
6554
6555 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6556 {
6557   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6558   ret->contentNotNull();
6559   return ret.retn();
6560 }
6561
6562 /*!
6563  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6564  * a given field that has been read from a specified MED file.
6565  *  \param [in] fileName - the name of the MED file to read.
6566  *  \param [in] fieldName - the name of the field to read.
6567  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6568  *          is to delete this field using decrRef() as it is no more needed.
6569  *  \throw If reading the file fails.
6570  *  \throw If there is no field named \a fieldName in the file.
6571  */
6572 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6573 {
6574   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6575   return New(fid,fieldName,loadAll);
6576 }
6577
6578 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6579 {
6580   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6581   ret->contentNotNull();
6582   return ret.retn();
6583 }
6584
6585 /*!
6586  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6587  * a given field that has been read from a specified MED file.
6588  *  \param [in] fileName - the name of the MED file to read.
6589  *  \param [in] fieldName - the name of the field to read.
6590  *  \param [in] iteration - the iteration number of a required time step.
6591  *  \param [in] order - the iteration order number of required time step.
6592  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6593  *          is to delete this field using decrRef() as it is no more needed.
6594  *  \throw If reading the file fails.
6595  *  \throw If there is no field named \a fieldName in the file.
6596  *  \throw If the required time step is missing from the file.
6597  */
6598 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6599 {
6600   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6601   return New(fid,fieldName,iteration,order,loadAll);
6602 }
6603
6604 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6605 {
6606   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6607   ret->contentNotNull();
6608   return ret.retn();
6609 }
6610
6611 /*!
6612  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6613  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6614  *
6615  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6616  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6617  * \warning this is a shallow copy constructor
6618  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6619  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6620  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6621  *          is to delete this field using decrRef() as it is no more needed.
6622  */
6623 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6624 {
6625   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6626   ret->contentNotNull();
6627   return ret.retn();
6628 }
6629
6630 /*!
6631  * Returns a new empty instance of MEDFileField1TS.
6632  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6633  *          is to delete this field using decrRef() as it is no more needed.
6634  */
6635 MEDFileField1TS *MEDFileField1TS::New()
6636 {
6637   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6638   ret->contentNotNull();
6639   return ret.retn();
6640 }
6641
6642 /*!
6643  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6644  * following the given input policy.
6645  *
6646  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6647  *                            By default (true) the globals are deeply copied.
6648  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6649  */
6650 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6651 {
6652   MCAuto<MEDFileIntField1TS> ret;
6653   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6654   if(content)
6655     {
6656       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6657       if(!contc)
6658         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6659       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6660       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6661     }
6662   else
6663     ret=MEDFileIntField1TS::New();
6664   if(isDeepCpyGlobs)
6665     ret->deepCpyGlobs(*this);
6666   else
6667     ret->shallowCpyGlobs(*this);
6668   return ret.retn();
6669 }
6670
6671 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6672 {
6673   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6674   if(!pt)
6675     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6676   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6677   if(!ret)
6678     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 !");
6679   return ret;
6680 }
6681
6682 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6683 {
6684   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6685   if(!pt)
6686     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6687   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6688   if(!ret)
6689     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 !");
6690   return ret;
6691 }
6692
6693 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6694 {
6695   if(!f)
6696     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6697   if(arr.isNull())
6698     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6699   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6700   if(!arrOutC)
6701     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6702   f->setArray(arrOutC);
6703 }
6704
6705 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6706 {
6707   if(arr.isNull())
6708     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6709   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6710   if(!arrOutC)
6711     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6712   arrOutC->incrRef();
6713   return arrOutC;
6714 }
6715
6716 /*!
6717  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6718  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6719  *
6720  * \return A new object that the caller is responsible to deallocate.
6721  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6722  */
6723 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6724 {
6725   if(!mm)
6726     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6727   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6728   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6729   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6730     {
6731       if((*it0)!=ON_NODES)
6732         {
6733           std::vector<int> levs;
6734           getNonEmptyLevels(mm->getName(),levs);
6735           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6736             {
6737               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6738               if(it2!=extractDef.end())
6739                 {
6740                   MCAuto<DataArrayInt> t((*it2).second);
6741                   if(t.isNull())
6742                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6743                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6744                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6745                   ret->setFieldNoProfileSBT(fOut);
6746                 }
6747             }
6748         }
6749       else
6750         {
6751           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6752           if(it2==extractDef.end())
6753             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6754           MCAuto<DataArrayInt> t((*it2).second);
6755           if(t.isNull())
6756             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6757           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6758           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6759           DataArrayDouble *arr(f->getArray());
6760           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6761           fOut->setArray(newArr);
6762           ret->setFieldNoProfileSBT(fOut);
6763         }
6764     }
6765   return ret.retn();
6766 }
6767
6768 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6769 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6770 {
6771 }
6772 catch(INTERP_KERNEL::Exception& e)
6773 { throw e; }
6774
6775 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6776 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6777 {
6778 }
6779 catch(INTERP_KERNEL::Exception& e)
6780 { throw e; }
6781
6782 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6783 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6784 {
6785 }
6786 catch(INTERP_KERNEL::Exception& e)
6787 { throw e; }
6788
6789 /*!
6790  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6791  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6792  *
6793  * \warning this is a shallow copy constructor
6794  */
6795 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6796 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6797 {
6798 }
6799 catch(INTERP_KERNEL::Exception& e)
6800 { throw e; }
6801
6802 MEDFileField1TS::MEDFileField1TS()
6803 {
6804   _content=new MEDFileField1TSWithoutSDA;
6805 }
6806
6807 /*!
6808  * 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
6809  * method should be called (getFieldOnMeshAtLevel for example).
6810  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6811  *
6812  * \param [in] mesh - the mesh the field is lying on
6813  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6814  *          caller is to delete this field using decrRef() as it is no more needed. 
6815  */
6816 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6817 {
6818   MCAuto<DataArray> arrOut;
6819   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6820   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6821   return ret.retn();
6822 }
6823
6824 /*!
6825  * Returns a new MEDCouplingFieldDouble of a given type lying on
6826  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6827  * has not been constructed via file reading, an exception is thrown.
6828  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6829  *  \param [in] type - a spatial discretization of interest.
6830  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6831  *  \param [in] renumPol - specifies how to permute values of the result field according to
6832  *          the optional numbers of cells and nodes, if any. The valid values are
6833  *          - 0 - do not permute.
6834  *          - 1 - permute cells.
6835  *          - 2 - permute nodes.
6836  *          - 3 - permute cells and nodes.
6837  *
6838  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6839  *          caller is to delete this field using decrRef() as it is no more needed. 
6840  *  \throw If \a this field has not been constructed via file reading.
6841  *  \throw If the MED file is not readable.
6842  *  \throw If there is no mesh in the MED file.
6843  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6844  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6845  *  \sa getFieldOnMeshAtLevel()
6846  */
6847 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6848 {
6849   if(getFileName().empty())
6850     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6851   MCAuto<DataArray> arrOut;
6852   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6853   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6854   return ret.retn();
6855 }
6856
6857 /*!
6858  * Returns a new MEDCouplingFieldDouble of a given type lying on
6859  * the top level cells of the first mesh in MED file. If \a this field 
6860  * has not been constructed via file reading, an exception is thrown.
6861  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6862  *  \param [in] type - a spatial discretization of interest.
6863  *  \param [in] renumPol - specifies how to permute values of the result field according to
6864  *          the optional numbers of cells and nodes, if any. The valid values are
6865  *          - 0 - do not permute.
6866  *          - 1 - permute cells.
6867  *          - 2 - permute nodes.
6868  *          - 3 - permute cells and nodes.
6869  *
6870  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6871  *          caller is to delete this field using decrRef() as it is no more needed. 
6872  *  \throw If \a this field has not been constructed via file reading.
6873  *  \throw If the MED file is not readable.
6874  *  \throw If there is no mesh in the MED file.
6875  *  \throw If no field values of the given \a type.
6876  *  \throw If no field values lying on the top level support.
6877  *  \sa getFieldAtLevel()
6878  */
6879 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6880 {
6881   if(getFileName().empty())
6882     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6883   MCAuto<DataArray> arrOut;
6884   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6885   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6886   return ret.retn();
6887 }
6888
6889 /*!
6890  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6891  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6892  *  \param [in] type - a spatial discretization of the new field.
6893  *  \param [in] mesh - the supporting mesh.
6894  *  \param [in] renumPol - specifies how to permute values of the result field according to
6895  *          the optional numbers of cells and nodes, if any. The valid values are
6896  *          - 0 - do not permute.
6897  *          - 1 - permute cells.
6898  *          - 2 - permute nodes.
6899  *          - 3 - permute cells and nodes.
6900  *
6901  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6902  *          caller is to delete this field using decrRef() as it is no more needed. 
6903  *  \throw If no field of \a this is lying on \a mesh.
6904  *  \throw If the mesh is empty.
6905  *  \throw If no field values of the given \a type are available.
6906  *  \sa getFieldAtLevel()
6907  *  \sa getFieldOnMeshAtLevel() 
6908  */
6909 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6910 {
6911   MCAuto<DataArray> arrOut;
6912   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6913   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6914   return ret.retn();
6915 }
6916
6917 /*!
6918  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6919  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6920  *  \param [in] type - a spatial discretization of interest.
6921  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6922  *  \param [in] mesh - the supporting mesh.
6923  *  \param [in] renumPol - specifies how to permute values of the result field according to
6924  *          the optional numbers of cells and nodes, if any. The valid values are
6925  *          - 0 - do not permute.
6926  *          - 1 - permute cells.
6927  *          - 2 - permute nodes.
6928  *          - 3 - permute cells and nodes.
6929  *
6930  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6931  *          caller is to delete this field using decrRef() as it is no more needed. 
6932  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6933  *  \throw If no field of \a this is lying on \a mesh.
6934  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6935  *  \sa getFieldAtLevel()
6936  *  \sa getFieldOnMeshAtLevel() 
6937  */
6938 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6939 {
6940   MCAuto<DataArray> arrOut;
6941   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6942   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6943   return ret.retn();
6944 }
6945
6946 /*!
6947  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6948  * This method is called "Old" because in MED3 norm a field has only one meshName
6949  * attached, so this method is for readers of MED2 files. If \a this field 
6950  * has not been constructed via file reading, an exception is thrown.
6951  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6952  *  \param [in] type - a spatial discretization of interest.
6953  *  \param [in] mName - a name of the supporting mesh.
6954  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6955  *  \param [in] renumPol - specifies how to permute values of the result field according to
6956  *          the optional numbers of cells and nodes, if any. The valid values are
6957  *          - 0 - do not permute.
6958  *          - 1 - permute cells.
6959  *          - 2 - permute nodes.
6960  *          - 3 - permute cells and nodes.
6961  *
6962  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6963  *          caller is to delete this field using decrRef() as it is no more needed. 
6964  *  \throw If the MED file is not readable.
6965  *  \throw If there is no mesh named \a mName in the MED file.
6966  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6967  *  \throw If \a this field has not been constructed via file reading.
6968  *  \throw If no field of \a this is lying on the mesh named \a mName.
6969  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6970  *  \sa getFieldAtLevel()
6971  */
6972 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6973 {
6974   if(getFileName().empty())
6975     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6976   MCAuto<DataArray> arrOut;
6977   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6978   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6979   return ret.retn();
6980 }
6981
6982 /*!
6983  * Returns values and a profile of the field of a given type lying on a given support.
6984  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6985  *  \param [in] type - a spatial discretization of the field.
6986  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6987  *  \param [in] mesh - the supporting mesh.
6988  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6989  *          field of interest lies on. If the field lies on all entities of the given
6990  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6991  *          using decrRef() as it is no more needed.  
6992  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6993  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6994  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6995  *  \throw If no field of \a this is lying on \a mesh.
6996  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6997  */
6998 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6999 {
7000   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7001   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7002 }
7003
7004 /*!
7005  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7006  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7007  * "Sort By Type"), if not, an exception is thrown. 
7008  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7009  *  \param [in] field - the field to add to \a this.
7010  *  \throw If the name of \a field is empty.
7011  *  \throw If the data array of \a field is not set.
7012  *  \throw If the data array is already allocated but has different number of components
7013  *         than \a field.
7014  *  \throw If the underlying mesh of \a field has no name.
7015  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7016  */
7017 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7018 {
7019   setFileName("");
7020   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7021 }
7022
7023 /*!
7024  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7025  * can be an aggregation of several MEDCouplingFieldDouble instances.
7026  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7027  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7028  * and \a profile.
7029  *
7030  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7031  * A new profile is added only if no equal profile is missing.
7032  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7033  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7034  *  \param [in] mesh - the supporting mesh of \a field.
7035  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7036  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7037  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7038  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7039  *  \throw If the data array of \a field is not set.
7040  *  \throw If the data array of \a this is already allocated but has different number of
7041  *         components than \a field.
7042  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7043  *  \sa setFieldNoProfileSBT()
7044  */
7045 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7046 {
7047   setFileName("");
7048   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7049 }
7050
7051 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7052 {
7053   return new MEDFileField1TS(*this);
7054 }
7055
7056 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7057 {
7058   return contentNotNull()->getUndergroundDataArrayTemplate();
7059 }
7060
7061 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7062 {
7063   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7064 }
7065
7066 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7067                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7068 {
7069   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7070 }
7071
7072 //= MEDFileIntField1TS
7073
7074 MEDFileIntField1TS *MEDFileIntField1TS::New()
7075 {
7076   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7077   ret->contentNotNull();
7078   return ret.retn();
7079 }
7080
7081 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7082 {
7083   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7084   return MEDFileIntField1TS::New(fid,loadAll);
7085 }
7086
7087 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7088 {
7089   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7090   ret->contentNotNull();
7091   return ret.retn();
7092 }
7093
7094 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7095 {
7096   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7097   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7098 }
7099
7100 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7101 {
7102   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7103   ret->contentNotNull();
7104   return ret.retn();
7105 }
7106
7107 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7108 {
7109   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7110   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7111 }
7112
7113 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7114 {
7115   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7116   ret->contentNotNull();
7117   return ret.retn();
7118 }
7119
7120 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7121 {
7122   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7123   ret->contentNotNull();
7124   return ret.retn();
7125 }
7126
7127 MEDFileIntField1TS::MEDFileIntField1TS()
7128 {
7129   _content=new MEDFileIntField1TSWithoutSDA;
7130 }
7131
7132 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7133 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7134 {
7135 }
7136 catch(INTERP_KERNEL::Exception& e)
7137 { throw e; }
7138
7139 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7140 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7141 {
7142 }
7143 catch(INTERP_KERNEL::Exception& e)
7144 { throw e; }
7145
7146 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7147 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7148 {
7149 }
7150 catch(INTERP_KERNEL::Exception& e)
7151 { throw e; }
7152
7153 /*!
7154  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7155  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7156  *
7157  * \warning this is a shallow copy constructor
7158  */
7159 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7160 {
7161 }
7162
7163 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7164 {
7165   return new MEDFileIntField1TS(*this);
7166 }
7167
7168 /*!
7169  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7170  * following the given input policy.
7171  *
7172  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7173  *                            By default (true) the globals are deeply copied.
7174  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7175  */
7176 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7177 {
7178   MCAuto<MEDFileField1TS> ret;
7179   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7180   if(content)
7181     {
7182       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7183       if(!contc)
7184         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7185       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7186       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7187     }
7188   else
7189     ret=MEDFileField1TS::New();
7190   if(isDeepCpyGlobs)
7191     ret->deepCpyGlobs(*this);
7192   else
7193     ret->shallowCpyGlobs(*this);
7194   return ret.retn();
7195 }
7196
7197 /*!
7198  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7199  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7200  * "Sort By Type"), if not, an exception is thrown. 
7201  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7202  *  \param [in] field - the field to add to \a this.
7203  *  \throw If the name of \a field is empty.
7204  *  \throw If the data array of \a field is not set.
7205  *  \throw If the data array is already allocated but has different number of components
7206  *         than \a field.
7207  *  \throw If the underlying mesh of \a field has no name.
7208  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7209  */
7210 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7211 {
7212   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7213   setFileName("");
7214   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7215 }
7216
7217 /*!
7218  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7219  * can be an aggregation of several MEDCouplingFieldDouble instances.
7220  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7221  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7222  * and \a profile.
7223  *
7224  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7225  * A new profile is added only if no equal profile is missing.
7226  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7227  *  \param [in] field - the field to add to \a this.
7228  *  \param [in] mesh - the supporting mesh of \a field.
7229  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7230  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7231  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7232  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7233  *  \throw If the data array of \a field is not set.
7234  *  \throw If the data array of \a this is already allocated but has different number of
7235  *         components than \a field.
7236  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7237  *  \sa setFieldNoProfileSBT()
7238  */
7239 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7240 {
7241   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7242   setFileName("");
7243   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7244 }
7245
7246 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7247 {
7248   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7249   if(!pt)
7250     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7251   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7252   if(!ret)
7253     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 !");
7254   return ret;
7255 }
7256
7257 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7258 {
7259   if(getFileName().empty())
7260     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7261   MCAuto<DataArray> arrOut;
7262   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7263   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7264   return ret2.retn();
7265 }
7266
7267 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7268 {
7269   if(arr.isNull())
7270     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7271   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7272   if(!arrC)
7273     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7274   arrC->incrRef();
7275   return arrC;
7276 }
7277
7278 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7279 {
7280   int t1,t2;
7281   double t0(f->getTime(t1,t2));
7282   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7283   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7284   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7285   ret->setTime(t0,t1,t2); ret->setArray(arr2);
7286   return ret.retn();
7287 }
7288
7289 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7290 {
7291   if(!f)
7292     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7293   int t1,t2;
7294   double t0(f->getTime(t1,t2));
7295   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7296   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7297   ret->setTime(t0,t1,t2);
7298   return ret;
7299 }
7300
7301 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7302 {
7303   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7304 }
7305
7306 /*!
7307  * 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
7308  * method should be called (getFieldOnMeshAtLevel for example).
7309  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7310  *
7311  * \param [in] mesh - the mesh the field is lying on
7312  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7313  *          caller is to delete this field using decrRef() as it is no more needed. 
7314  */
7315 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7316 {
7317   MCAuto<DataArray> arrOut;
7318   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7319   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7320   return ret2.retn();
7321 }
7322
7323 /*!
7324  * Returns a new MEDCouplingFieldInt of a given type lying on
7325  * the top level cells of the first mesh in MED file. If \a this field 
7326  * has not been constructed via file reading, an exception is thrown.
7327  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7328  *  \param [in] type - a spatial discretization of interest.
7329  *  \param [in] renumPol - specifies how to permute values of the result field according to
7330  *          the optional numbers of cells and nodes, if any. The valid values are
7331  *          - 0 - do not permute.
7332  *          - 1 - permute cells.
7333  *          - 2 - permute nodes.
7334  *          - 3 - permute cells and nodes.
7335  *
7336  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7337  *          caller is to delete this field using decrRef() as it is no more needed. 
7338  *  \throw If \a this field has not been constructed via file reading.
7339  *  \throw If the MED file is not readable.
7340  *  \throw If there is no mesh in the MED file.
7341  *  \throw If no field values of the given \a type.
7342  *  \throw If no field values lying on the top level support.
7343  *  \sa getFieldAtLevel()
7344  */
7345 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7346 {
7347   if(getFileName().empty())
7348     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7349   MCAuto<DataArray> arrOut;
7350   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7351   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7352   return ret2.retn();
7353 }
7354
7355 /*!
7356  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7357  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7358  *  \param [in] type - a spatial discretization of the new field.
7359  *  \param [in] mesh - the supporting mesh.
7360  *  \param [in] renumPol - specifies how to permute values of the result field according to
7361  *          the optional numbers of cells and nodes, if any. The valid values are
7362  *          - 0 - do not permute.
7363  *          - 1 - permute cells.
7364  *          - 2 - permute nodes.
7365  *          - 3 - permute cells and nodes.
7366  *
7367  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7368  *          caller is to delete this field using decrRef() as it is no more needed. 
7369  *  \throw If no field of \a this is lying on \a mesh.
7370  *  \throw If the mesh is empty.
7371  *  \throw If no field values of the given \a type are available.
7372  *  \sa getFieldAtLevel()
7373  *  \sa getFieldOnMeshAtLevel() 
7374  */
7375 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7376 {
7377   MCAuto<DataArray> arrOut;
7378   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7379   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7380   return ret2.retn();
7381 }
7382
7383 /*!
7384  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7385  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7386  *  \param [in] type - a spatial discretization of interest.
7387  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7388  *  \param [in] mesh - the supporting mesh.
7389  *  \param [in] renumPol - specifies how to permute values of the result field according to
7390  *          the optional numbers of cells and nodes, if any. The valid values are
7391  *          - 0 - do not permute.
7392  *          - 1 - permute cells.
7393  *          - 2 - permute nodes.
7394  *          - 3 - permute cells and nodes.
7395  *
7396  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7397  *          caller is to delete this field using decrRef() as it is no more needed. 
7398  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7399  *  \throw If no field of \a this is lying on \a mesh.
7400  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7401  *  \sa getFieldAtLevel()
7402  *  \sa getFieldOnMeshAtLevel() 
7403  */
7404 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7405 {
7406   MCAuto<DataArray> arrOut;
7407   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7408   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7409   return ret2.retn();
7410 }
7411
7412 /*!
7413  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7414  * This method is called "Old" because in MED3 norm a field has only one meshName
7415  * attached, so this method is for readers of MED2 files. If \a this field 
7416  * has not been constructed via file reading, an exception is thrown.
7417  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7418  *  \param [in] type - a spatial discretization of interest.
7419  *  \param [in] mName - a name of the supporting mesh.
7420  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7421  *  \param [in] renumPol - specifies how to permute values of the result field according to
7422  *          the optional numbers of cells and nodes, if any. The valid values are
7423  *          - 0 - do not permute.
7424  *          - 1 - permute cells.
7425  *          - 2 - permute nodes.
7426  *          - 3 - permute cells and nodes.
7427  *
7428  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7429  *          caller is to delete this field using decrRef() as it is no more needed. 
7430  *  \throw If the MED file is not readable.
7431  *  \throw If there is no mesh named \a mName in the MED file.
7432  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7433  *  \throw If \a this field has not been constructed via file reading.
7434  *  \throw If no field of \a this is lying on the mesh named \a mName.
7435  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7436  *  \sa getFieldAtLevel()
7437  */
7438 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7439 {
7440   if(getFileName().empty())
7441     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7442   MCAuto<DataArray> arrOut;
7443   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7444   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7445   return ret2.retn();
7446 }
7447
7448 /*!
7449  * Returns values and a profile of the field of a given type lying on a given support.
7450  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7451  *  \param [in] type - a spatial discretization of the field.
7452  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7453  *  \param [in] mesh - the supporting mesh.
7454  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7455  *          field of interest lies on. If the field lies on all entities of the given
7456  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7457  *          using decrRef() as it is no more needed.  
7458  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7459  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7460  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7461  *  \throw If no field of \a this is lying on \a mesh.
7462  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7463  */
7464 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7465 {
7466   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7467   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7468 }
7469
7470 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7471 {
7472   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7473   if(!pt)
7474     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7475   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7476   if(!ret)
7477     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 !");
7478   return ret;
7479 }
7480
7481 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7482 {
7483   return contentNotNull()->getUndergroundDataArrayTemplate();
7484 }
7485
7486 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7487
7488 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7489 {
7490 }
7491
7492 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7493 {
7494 }
7495
7496 /*!
7497  * \param [in] fieldId field id in C mode
7498  */
7499 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7500 {
7501   med_field_type typcha;
7502   std::string dtunitOut;
7503   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7504   setDtUnit(dtunitOut.c_str());
7505   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7506 }
7507
7508 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 MEDFileEntities *entities)
7509 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7510 {
7511   setDtUnit(dtunit.c_str());
7512   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7513 }
7514 catch(INTERP_KERNEL::Exception& e)
7515 {
7516     throw e;
7517 }
7518
7519 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7520 {
7521   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7522   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7523     ret+=(*it).capacity();
7524   return ret;
7525 }
7526
7527 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7528 {
7529   std::vector<const BigMemoryObject *> ret;
7530   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7531     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7532   return ret;
7533 }
7534
7535 /*!
7536  * 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
7537  * NULL.
7538  */
7539 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7540 {
7541   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7542   ret->setInfo(_infos);
7543   int sz=(int)_time_steps.size();
7544   for(const int *id=startIds;id!=endIds;id++)
7545     {
7546       if(*id>=0 && *id<sz)
7547         {
7548           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7549           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7550           if(tse)
7551             {
7552               tse->incrRef();
7553               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7554             }
7555           ret->pushBackTimeStep(tse2);
7556         }
7557       else
7558         {
7559           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7560           oss << " ! Should be in [0," << sz << ") !";
7561           throw INTERP_KERNEL::Exception(oss.str());
7562         }
7563     }
7564   if(ret->getNumberOfTS()>0)
7565     ret->synchronizeNameScope();
7566   ret->copyNameScope(*this);
7567   return ret.retn();
7568 }
7569
7570 /*!
7571  * 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
7572  * NULL.
7573  */
7574 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7575 {
7576   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7577   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7578   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7579   ret->setInfo(_infos);
7580   int sz=(int)_time_steps.size();
7581   int j=bg;
7582   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7583     {
7584       if(j>=0 && j<sz)
7585         {
7586           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7587           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7588           if(tse)
7589             {
7590               tse->incrRef();
7591               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7592             }
7593           ret->pushBackTimeStep(tse2);
7594         }
7595       else
7596         {
7597           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7598           oss << " ! Should be in [0," << sz << ") !";
7599           throw INTERP_KERNEL::Exception(oss.str());
7600         }
7601     }
7602   if(ret->getNumberOfTS()>0)
7603     ret->synchronizeNameScope();
7604   ret->copyNameScope(*this);
7605   return ret.retn();
7606 }
7607
7608 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7609 {
7610   int id=0;
7611   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7612   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7613     {
7614       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7615       if(!cur)
7616         continue;
7617       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7618       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7619         ids->pushBackSilent(id);
7620     }
7621   return buildFromTimeStepIds(ids->begin(),ids->end());
7622 }
7623
7624 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7625 {
7626   int id=0;
7627   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7628   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7629     {
7630       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7631       if(!cur)
7632         continue;
7633       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7634       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7635         ids->pushBackSilent(id);
7636     }
7637   return buildFromTimeStepIds(ids->begin(),ids->end());
7638 }
7639
7640 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7641 {
7642   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7643     if((*it).isNotNull())
7644       if((*it)->presenceOfStructureElements())
7645         return true;
7646   return false;
7647 }
7648
7649 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7650 {
7651   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7652     if((*it).isNotNull())
7653       if(!(*it)->onlyStructureElements())
7654         return false;
7655   return true;
7656 }
7657
7658 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7659 {
7660   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7661   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7662     if((*it).isNotNull())
7663       {
7664         if((*it)->presenceOfStructureElements())
7665           {
7666             if(!(*it)->onlyStructureElements())
7667               {
7668                 (*it)->killStructureElements();
7669                 ret.push_back(*it);
7670               }
7671           }
7672         else
7673           {
7674             ret.push_back(*it);
7675           }
7676       }
7677   _time_steps=ret;
7678 }
7679
7680 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7681 {
7682   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7683   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7684     if((*it).isNotNull())
7685       {
7686         if((*it)->presenceOfStructureElements())
7687           {
7688             if(!(*it)->onlyStructureElements())
7689               (*it)->keepOnlyStructureElements();
7690             ret.push_back(*it);
7691           }
7692       }
7693   _time_steps=ret;
7694 }
7695
7696 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7697 {
7698   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7699   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7700     if((*it).isNotNull())
7701       (*it)->keepOnlyOnSE(seName);
7702 }
7703
7704 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7705 {
7706   std::vector< std::pair<std::string,std::string> > ps2;
7707   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7708     if((*it).isNotNull())
7709       {
7710         (*it)->getMeshSENames(ps2);
7711         break;
7712       }
7713   if(ps2.empty())
7714     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7715   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7716     if((*it).isNotNull())
7717       {
7718         std::vector< std::pair<std::string,std::string> > ps3;
7719         (*it)->getMeshSENames(ps3);
7720         if(ps2!=ps3)
7721           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7722       }
7723   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7724     {
7725       std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7726       if(it2==ps.end())
7727         ps.push_back(*it);
7728     }
7729 }
7730
7731 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7732 {
7733   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7734     {
7735       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7736       if(!cur)
7737         continue;
7738       if(cur->presenceOfMultiDiscPerGeoType())
7739         return true;
7740     }
7741   return false;
7742 }
7743
7744 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7745 {
7746   return _infos;
7747 }
7748
7749 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7750 {
7751   _infos=info;
7752 }
7753
7754 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7755 {
7756   int ret=0;
7757   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7758     {
7759       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7760       if(pt->isDealingTS(iteration,order))
7761         return ret;
7762     }
7763   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7764   std::vector< std::pair<int,int> > vp=getIterations();
7765   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7766     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7767   throw INTERP_KERNEL::Exception(oss.str());
7768 }
7769
7770 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7771 {
7772   return *_time_steps[getTimeStepPos(iteration,order)];
7773 }
7774
7775 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7776 {
7777   return *_time_steps[getTimeStepPos(iteration,order)];
7778 }
7779
7780 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7781 {
7782   if(_time_steps.empty())
7783     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7784   return _time_steps[0]->getMeshName();
7785 }
7786
7787 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7788 {
7789   std::string oldName(getMeshName());
7790   std::vector< std::pair<std::string,std::string> > v(1);
7791   v[0].first=oldName; v[0].second=newMeshName;
7792   changeMeshNames(v);
7793 }
7794
7795 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7796 {
7797   bool ret=false;
7798   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7799     {
7800       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7801       if(cur)
7802         ret=cur->changeMeshNames(modifTab) || ret;
7803     }
7804   return ret;
7805 }
7806
7807 /*!
7808  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7809  */
7810 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7811 {
7812   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7813 }
7814
7815 /*!
7816  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7817  */
7818 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7819 {
7820   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7821 }
7822
7823 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7824                                                                        MEDFileFieldGlobsReal& glob)
7825 {
7826   bool ret=false;
7827   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7828     {
7829       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7830       if(f1ts)
7831         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7832     }
7833   return ret;
7834 }
7835
7836 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7837 {
7838   std::string startLine(bkOffset,' ');
7839   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7840   if(fmtsId>=0)
7841     oss << " (" << fmtsId << ")";
7842   oss << " has the following name: \"" << _name << "\"." << std::endl;
7843   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7844   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7845     {
7846       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7847     }
7848   int i=0;
7849   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7850     {
7851       std::string chapter(17,'0'+i);
7852       oss << startLine << chapter << std::endl;
7853       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7854       if(cur)
7855         cur->simpleRepr(bkOffset+2,oss,i);
7856       else
7857         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7858       oss << startLine << chapter << std::endl;
7859     }
7860 }
7861
7862 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7863 {
7864   std::size_t sz=_time_steps.size();
7865   std::vector< std::pair<int,int> > ret(sz);
7866   ret1.resize(sz);
7867   for(std::size_t i=0;i<sz;i++)
7868     {
7869       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7870       if(f1ts)
7871         {
7872           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7873         }
7874       else
7875         {
7876           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7877           throw INTERP_KERNEL::Exception(oss.str());
7878         }
7879     }
7880   return ret;
7881 }
7882
7883 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7884 {
7885   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7886   if(!tse2)
7887     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7888   checkCoherencyOfType(tse2);
7889   if(_time_steps.empty())
7890     {
7891       setName(tse2->getName().c_str());
7892       setInfo(tse2->getInfo());
7893     }
7894   checkThatComponentsMatch(tse2->getInfo());
7895   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7896     setDtUnit(tse->getDtUnit());
7897   _time_steps.push_back(tse);
7898 }
7899
7900 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7901 {
7902   std::size_t nbOfCompo=_infos.size();
7903   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7904     {
7905       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7906       if(cur)
7907         {
7908           if((cur->getInfo()).size()!=nbOfCompo)
7909             {
7910               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7911               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7912               throw INTERP_KERNEL::Exception(oss.str());
7913             }
7914           cur->copyNameScope(*this);
7915         }
7916     }
7917 }
7918
7919 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7920 {
7921   _time_steps.resize(nbPdt);
7922   for(int i=0;i<nbPdt;i++)
7923     {
7924       std::vector< std::pair<int,int> > ts;
7925       med_int numdt=0,numo=0;
7926       med_float dt=0.0;
7927       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7928       switch(fieldTyp)
7929       {
7930         case MED_FLOAT64:
7931           {
7932             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7933             break;
7934           }
7935         case MED_INT32:
7936           {
7937             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7938             break;
7939           }
7940         default:
7941           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7942       }
7943       if(loadAll)
7944         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7945       else
7946         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7947       synchronizeNameScope();
7948     }
7949 }
7950
7951 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7952 {
7953   if(_time_steps.empty())
7954     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7955   checkThatNbOfCompoOfTSMatchThis();
7956   std::vector<std::string> infos(getInfo());
7957   int nbComp=infos.size();
7958   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7959   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7960   for(int i=0;i<nbComp;i++)
7961     {
7962       std::string info=infos[i];
7963       std::string c,u;
7964       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7965       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7966       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7967     }
7968   if(_name.empty())
7969     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7970   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7971   int nbOfTS=_time_steps.size();
7972   for(int i=0;i<nbOfTS;i++)
7973     _time_steps[i]->writeLL(fid,opts,*this);
7974 }
7975
7976 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7977 {
7978   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7979     {
7980       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7981       if(elt)
7982         elt->loadBigArraysRecursively(fid,nasc);
7983     }
7984 }
7985
7986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7987 {
7988   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7989     {
7990       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7991       if(elt)
7992         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7993     }
7994 }
7995
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7997 {
7998   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7999     {
8000       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8001       if(elt)
8002         elt->unloadArrays();
8003     }
8004 }
8005
8006 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8007 {
8008   return _time_steps.size();
8009 }
8010
8011 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8012 {
8013   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
8014   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8015     {
8016       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8017       if(tmp)
8018         newTS.push_back(*it);
8019     }
8020   _time_steps=newTS;
8021 }
8022
8023 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8024 {
8025   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8026   int maxId=(int)_time_steps.size();
8027   int ii=0;
8028   std::set<int> idsToDel;
8029   for(const int *id=startIds;id!=endIds;id++,ii++)
8030     {
8031       if(*id>=0 && *id<maxId)
8032         {
8033           idsToDel.insert(*id);
8034         }
8035       else
8036         {
8037           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8038           throw INTERP_KERNEL::Exception(oss.str());
8039         }
8040     }
8041   for(int iii=0;iii<maxId;iii++)
8042     if(idsToDel.find(iii)==idsToDel.end())
8043       newTS.push_back(_time_steps[iii]);
8044   _time_steps=newTS;
8045 }
8046
8047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8048 {
8049   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8050   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8051   if(nbOfEntriesToKill==0)
8052     return ;
8053   std::size_t sz=_time_steps.size();
8054   std::vector<bool> b(sz,true);
8055   int j=bg;
8056   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8057     b[j]=false;
8058   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8059   for(std::size_t i=0;i<sz;i++)
8060     if(b[i])
8061       newTS.push_back(_time_steps[i]);
8062   _time_steps=newTS;
8063 }
8064
8065 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8066 {
8067   int ret=0;
8068   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
8069   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8070     {
8071       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8072       if(tmp)
8073         {
8074           int it2,ord;
8075           tmp->getTime(it2,ord);
8076           if(it2==iteration && order==ord)
8077             return ret;
8078           else
8079             oss << "(" << it2 << ","  << ord << "), ";
8080         }
8081     }
8082   throw INTERP_KERNEL::Exception(oss.str());
8083 }
8084
8085 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8086 {
8087   int ret=0;
8088   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8089   oss.precision(15);
8090   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8091     {
8092       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8093       if(tmp)
8094         {
8095           int it2,ord;
8096           double ti=tmp->getTime(it2,ord);
8097           if(fabs(time-ti)<eps)
8098             return ret;
8099           else
8100             oss << ti << ", ";
8101         }
8102     }
8103   throw INTERP_KERNEL::Exception(oss.str());
8104 }
8105
8106 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8107 {
8108   int lgth=_time_steps.size();
8109   std::vector< std::pair<int,int> > ret(lgth);
8110   for(int i=0;i<lgth;i++)
8111     _time_steps[i]->fillIteration(ret[i]);
8112   return ret;
8113 }
8114
8115 /*!
8116  * 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'
8117  * This method returns two things.
8118  * - The absolute dimension of 'this' in first parameter. 
8119  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8120  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
8121  *
8122  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8123  * Only these 3 discretizations will be taken into account here.
8124  *
8125  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8126  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8127  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8128  *
8129  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8130  * 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'.
8131  * 
8132  * Let's consider the typical following case :
8133  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8134  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8135  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8136  *   TETRA4 and SEG2
8137  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8138  *
8139  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8140  * 
8141  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8142  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8143  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8144  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8145  */
8146 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8147 {
8148   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8149 }
8150
8151 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8152 {
8153   if(pos<0 || pos>=(int)_time_steps.size())
8154     {
8155       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8156       throw INTERP_KERNEL::Exception(oss.str());
8157     }
8158   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8159   if(item==0)
8160     {
8161       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8162       oss << "\nTry to use following method eraseEmptyTS !";
8163       throw INTERP_KERNEL::Exception(oss.str());
8164     }
8165   return item;
8166 }
8167
8168 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8169 {
8170   if(pos<0 || pos>=(int)_time_steps.size())
8171     {
8172       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8173       throw INTERP_KERNEL::Exception(oss.str());
8174     }
8175   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8176   if(item==0)
8177     {
8178       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8179       oss << "\nTry to use following method eraseEmptyTS !";
8180       throw INTERP_KERNEL::Exception(oss.str());
8181     }
8182   return item;
8183 }
8184
8185 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8186 {
8187   std::vector<std::string> ret;
8188   std::set<std::string> ret2;
8189   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8190     {
8191       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8192       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8193         if(ret2.find(*it2)==ret2.end())
8194           {
8195             ret.push_back(*it2);
8196             ret2.insert(*it2);
8197           }
8198     }
8199   return ret;
8200 }
8201
8202 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8203 {
8204   std::vector<std::string> ret;
8205   std::set<std::string> ret2;
8206   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8207     {
8208       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8209       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8210         if(ret2.find(*it2)==ret2.end())
8211           {
8212             ret.push_back(*it2);
8213             ret2.insert(*it2);
8214           }
8215     }
8216   return ret;
8217 }
8218
8219 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8220 {
8221   std::vector<std::string> ret;
8222   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8223     {
8224       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8225       ret.insert(ret.end(),tmp.begin(),tmp.end());
8226     }
8227   return ret;
8228 }
8229
8230 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8231 {
8232   std::vector<std::string> ret;
8233   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8234     {
8235       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8236       ret.insert(ret.end(),tmp.begin(),tmp.end());
8237     }
8238   return ret;
8239 }
8240
8241 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8242 {
8243   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8244     (*it)->changePflsRefsNamesGen2(mapOfModif);
8245 }
8246
8247 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8248 {
8249   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8250     (*it)->changeLocsRefsNamesGen2(mapOfModif);
8251 }
8252
8253 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8254 {
8255   int lgth=_time_steps.size();
8256   std::vector< std::vector<TypeOfField> > ret(lgth);
8257   for(int i=0;i<lgth;i++)
8258     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8259   return ret;
8260 }
8261
8262 /*!
8263  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8264  */
8265 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
8266 {
8267   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8268 }
8269
8270 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8271 {
8272   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8273   std::size_t i=0;
8274   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8275     {
8276       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8277         ret->_time_steps[i]=(*it)->deepCopy();
8278     }
8279   return ret.retn();
8280 }
8281
8282 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8283 {
8284   std::size_t sz(_infos.size()),sz2(_time_steps.size());
8285   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8286   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8287   for(std::size_t i=0;i<sz;i++)
8288     {
8289       ret[i]=shallowCpy();
8290       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8291     }
8292   for(std::size_t i=0;i<sz2;i++)
8293     {
8294       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8295       if(ret1.size()!=sz)
8296         {
8297           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8298           throw INTERP_KERNEL::Exception(oss.str());
8299         }
8300       ts[i]=ret1;
8301     }
8302   for(std::size_t i=0;i<sz;i++)
8303     for(std::size_t j=0;j<sz2;j++)
8304       ret[i]->_time_steps[j]=ts[j][i];
8305   return ret;
8306 }
8307
8308 /*!
8309  * This method splits into discretization each time steps in \a this.
8310  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8311  */
8312 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8313 {
8314   std::size_t sz(_time_steps.size());
8315   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8316   for(std::size_t i=0;i<sz;i++)
8317     {
8318       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8319       if(!timeStep)
8320         {
8321           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
8322           throw INTERP_KERNEL::Exception(oss.str());
8323         }
8324       items[i]=timeStep->splitDiscretizations();  
8325     }
8326   //
8327   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8328   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8329   std::vector< TypeOfField > types;
8330   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8331     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8332       {
8333         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8334         if(ts.size()!=1)
8335           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8336         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8337         if(it2==types.end())
8338           types.push_back(ts[0]);
8339       }
8340   ret.resize(types.size()); ret2.resize(types.size());
8341   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8342     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8343       {
8344         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8345         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8346         ret2[pos].push_back(*it1);
8347       }
8348   for(std::size_t i=0;i<types.size();i++)
8349     {
8350       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8351       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8352         elt->pushBackTimeStep(*it1);//also updates infos in elt
8353       ret[i]=elt;
8354       elt->MEDFileFieldNameScope::operator=(*this);
8355     }
8356   return ret;
8357 }
8358
8359 /*!
8360  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8361  */
8362 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8363 {
8364   std::size_t sz(_time_steps.size());
8365   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8366   std::size_t szOut(std::numeric_limits<std::size_t>::max());
8367   for(std::size_t i=0;i<sz;i++)
8368     {
8369       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8370       if(!timeStep)
8371         {
8372           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8373           throw INTERP_KERNEL::Exception(oss.str());
8374         }
8375       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8376       if(szOut==std::numeric_limits<std::size_t>::max())
8377         szOut=items[i].size();
8378       else
8379         if(items[i].size()!=szOut)
8380           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8381     }
8382   if(szOut==std::numeric_limits<std::size_t>::max())
8383     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8384   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8385   for(std::size_t i=0;i<szOut;i++)
8386     {
8387       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8388       for(std::size_t j=0;j<sz;j++)
8389         elt->pushBackTimeStep(items[j][i]);
8390       ret[i]=elt;
8391       elt->MEDFileFieldNameScope::operator=(*this);
8392     }
8393   return ret;
8394 }
8395
8396 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8397 {
8398   _name=field->getName();
8399   if(_name.empty())
8400     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8401   if(!arr)
8402     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8403   _infos=arr->getInfoOnComponents();
8404 }
8405
8406 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8407 {
8408   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8409   if(_name!=field->getName())
8410     {
8411       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8412       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8413       throw INTERP_KERNEL::Exception(oss.str());
8414     }
8415   if(!arr)
8416     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8417   checkThatComponentsMatch(arr->getInfoOnComponents());
8418 }
8419
8420 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8421 {
8422   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8423   if(getInfo().size()!=compos.size())
8424     {
8425       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8426       oss << " number of components of element to append (" << compos.size() << ") !";
8427       throw INTERP_KERNEL::Exception(oss.str());
8428     }
8429   if(_infos!=compos)
8430     {
8431       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8432       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8433       oss << " But compo in input fields are : ";
8434       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8435       oss << " !";
8436       throw INTERP_KERNEL::Exception(oss.str());
8437     }
8438 }
8439
8440 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8441 {
8442   std::size_t sz=_infos.size();
8443   int j=0;
8444   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8445     {
8446       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8447       if(elt)
8448         if(elt->getInfo().size()!=sz)
8449           {
8450             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8451             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8452             throw INTERP_KERNEL::Exception(oss.str());
8453           }
8454     }
8455 }
8456
8457 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8458 {
8459   if(!field)
8460     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8461   if(!_time_steps.empty())
8462     checkCoherencyOfTinyInfo(field,arr);
8463   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8464   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8465   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8466   copyTinyInfoFrom(field,arr);
8467   _time_steps.push_back(obj);
8468 }
8469
8470 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8471 {
8472   if(!field)
8473     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8474   if(!_time_steps.empty())
8475     checkCoherencyOfTinyInfo(field,arr);
8476   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8477   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8478   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8479   copyTinyInfoFrom(field,arr);
8480   _time_steps.push_back(obj);
8481 }
8482
8483 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8484 {
8485   int sz=(int)_time_steps.size();
8486   if(i<0 || i>=sz)
8487     {
8488       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8489       throw INTERP_KERNEL::Exception(oss.str());
8490     }
8491   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8492   if(tsPtr)
8493     {
8494       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8495         {
8496           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8497           throw INTERP_KERNEL::Exception(oss.str());
8498         }
8499     }
8500   _time_steps[i]=ts;
8501 }
8502
8503 //= MEDFileFieldMultiTSWithoutSDA
8504
8505 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 MEDFileEntities *entities)
8506 {
8507   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8508 }
8509
8510 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8511 {
8512 }
8513
8514 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8515 {
8516 }
8517
8518 /*!
8519  * \param [in] fieldId field id in C mode
8520  */
8521 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8522 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8523 {
8524 }
8525 catch(INTERP_KERNEL::Exception& e)
8526 { throw e; }
8527
8528 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 MEDFileEntities *entities)
8529 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8530 {
8531 }
8532 catch(INTERP_KERNEL::Exception& e)
8533 { throw e; }
8534
8535 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8536 {
8537   return new MEDFileField1TSWithoutSDA;
8538 }
8539
8540 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8541 {
8542   if(!f1ts)
8543     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8544   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8545   if(!f1tsC)
8546     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8547 }
8548
8549 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8550 {
8551   return MEDFileField1TSWithoutSDA::TYPE_STR;
8552 }
8553
8554 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8555 {
8556   return new MEDFileFieldMultiTSWithoutSDA(*this);
8557 }
8558
8559 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8560 {
8561   return new MEDFileFieldMultiTSWithoutSDA;
8562 }
8563
8564 /*!
8565  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8566  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8567  */
8568 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
8569 {
8570   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8571   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8572   if(!myF1TSC)
8573     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8574   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8575 }
8576
8577 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8578 {
8579   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8580   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8581   int i=0;
8582   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8583     {
8584       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8585       if(eltToConv)
8586         {
8587           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8588           if(!eltToConvC)
8589             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8590           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8591           ret->setIteration(i,elt);
8592         }
8593     }
8594   return ret.retn();
8595 }
8596
8597 //= MEDFileAnyTypeFieldMultiTS
8598
8599 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8600 {
8601 }
8602
8603 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8604 try:MEDFileFieldGlobsReal(fid)
8605 {
8606   _content=BuildContentFrom(fid,loadAll,ms);
8607   loadGlobals(fid);
8608 }
8609 catch(INTERP_KERNEL::Exception& e)
8610 {
8611     throw e;
8612 }
8613
8614 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8615 {
8616   med_field_type typcha;
8617   std::vector<std::string> infos;
8618   std::string dtunit;
8619   int i(-1);
8620   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8621   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8622   switch(typcha)
8623   {
8624     case MED_FLOAT64:
8625       {
8626         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8627         break;
8628       }
8629     case MED_INT32:
8630       {
8631         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8632         break;
8633       }
8634     default:
8635       {
8636         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] !";
8637         throw INTERP_KERNEL::Exception(oss.str());
8638       }
8639   }
8640   ret->setDtUnit(dtunit.c_str());
8641   return ret.retn();
8642 }
8643
8644 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8645 {
8646   med_field_type typcha;
8647   //
8648   std::vector<std::string> infos;
8649   std::string dtunit,fieldName;
8650   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8651   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8652   switch(typcha)
8653   {
8654     case MED_FLOAT64:
8655       {
8656         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8657         break;
8658       }
8659     case MED_INT32:
8660       {
8661         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8662         break;
8663       }
8664     default:
8665       {
8666         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] !";
8667         throw INTERP_KERNEL::Exception(oss.str());
8668       }
8669   }
8670   ret->setDtUnit(dtunit.c_str());
8671   return ret.retn();
8672 }
8673
8674 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8675 {
8676   if(!c)
8677     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8678   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8679     {
8680       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8681       ret->_content=c;  c->incrRef();
8682       return ret.retn();
8683     }
8684   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8685     {
8686       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8687       ret->_content=c;  c->incrRef();
8688       return ret.retn();
8689     }
8690   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8691 }
8692
8693 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8694 {
8695   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8696   std::string fileName(FileNameFromFID(fid));
8697   ret->setFileName(fileName);
8698   return ret;
8699 }
8700
8701 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8702 try:MEDFileFieldGlobsReal(fid)
8703 {
8704   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8705   loadGlobals(fid);
8706 }
8707 catch(INTERP_KERNEL::Exception& e)
8708 {
8709     throw e;
8710 }
8711
8712 //= MEDFileIntFieldMultiTSWithoutSDA
8713
8714 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 MEDFileEntities *entities)
8715 {
8716   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8717 }
8718
8719 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8720 {
8721 }
8722
8723 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8724 {
8725 }
8726
8727 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 MEDFileEntities *entities)
8728 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8729 {
8730 }
8731 catch(INTERP_KERNEL::Exception& e)
8732 { throw e; }
8733
8734 /*!
8735  * \param [in] fieldId field id in C mode
8736  */
8737 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8738 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8739 {
8740 }
8741 catch(INTERP_KERNEL::Exception& e)
8742 { throw e; }
8743
8744 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8745 {
8746   return new MEDFileIntField1TSWithoutSDA;
8747 }
8748
8749 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8750 {
8751   if(!f1ts)
8752     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8753   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8754   if(!f1tsC)
8755     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8756 }
8757
8758 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8759 {
8760   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8761 }
8762
8763 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8764 {
8765   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8766 }
8767
8768 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8769 {
8770   return new MEDFileIntFieldMultiTSWithoutSDA;
8771 }
8772
8773 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8774 {
8775   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8776   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8777   int i=0;
8778   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8779     {
8780       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8781       if(eltToConv)
8782         {
8783           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8784           if(!eltToConvC)
8785             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8786           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8787           ret->setIteration(i,elt);
8788         }
8789     }
8790   return ret.retn();
8791 }
8792
8793 //= MEDFileAnyTypeFieldMultiTS
8794
8795 /*!
8796  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8797  * that has been read from a specified MED file.
8798  *  \param [in] fileName - the name of the MED file to read.
8799  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8800  *          is to delete this field using decrRef() as it is no more needed.
8801  *  \throw If reading the file fails.
8802  */
8803 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8804 {
8805   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8806   return New(fid,loadAll);
8807 }
8808
8809 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8810 {
8811   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8812   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8813   ret->loadGlobals(fid);
8814   return ret.retn();
8815 }
8816
8817 /*!
8818  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8819  * that has been read from a specified MED file.
8820  *  \param [in] fileName - the name of the MED file to read.
8821  *  \param [in] fieldName - the name of the field to read.
8822  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8823  *          is to delete this field using decrRef() as it is no more needed.
8824  *  \throw If reading the file fails.
8825  *  \throw If there is no field named \a fieldName in the file.
8826  */
8827 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8828 {
8829   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8830   return New(fid,fieldName,loadAll);
8831 }
8832
8833 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8834 {
8835   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8836   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8837   ret->loadGlobals(fid);
8838   return ret.retn();
8839 }
8840
8841 /*!
8842  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8843  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8844  *
8845  * \warning this is a shallow copy constructor
8846  */
8847 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8848 {
8849   if(!shallowCopyOfContent)
8850     {
8851       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8852       otherPtr->incrRef();
8853       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8854     }
8855   else
8856     {
8857       _content=other.shallowCpy();
8858     }
8859 }
8860
8861 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8862 {
8863   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8864   if(!ret)
8865     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8866   return ret;
8867 }
8868
8869 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8870 {
8871   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8872   if(!ret)
8873     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8874   return ret;
8875 }
8876
8877 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8878 {
8879   return contentNotNullBase()->getPflsReallyUsed2();
8880 }
8881
8882 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8883 {
8884   return contentNotNullBase()->getLocsReallyUsed2();
8885 }
8886
8887 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8888 {
8889   return contentNotNullBase()->getPflsReallyUsedMulti2();
8890 }
8891
8892 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8893 {
8894   return contentNotNullBase()->getLocsReallyUsedMulti2();
8895 }
8896
8897 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8898 {
8899   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8900 }
8901
8902 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8903 {
8904   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8905 }
8906
8907 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8908 {
8909   return contentNotNullBase()->getNumberOfTS();
8910 }
8911
8912 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8913 {
8914   contentNotNullBase()->eraseEmptyTS();
8915 }
8916
8917 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8918 {
8919   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8920 }
8921
8922 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8923 {
8924   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8925 }
8926
8927 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8928 {
8929   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8930   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8931   ret->_content=c;
8932   return ret.retn();
8933 }
8934
8935 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8936 {
8937   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8938   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8939   ret->_content=c;
8940   return ret.retn();
8941 }
8942
8943 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8944 {
8945   return contentNotNullBase()->getIterations();
8946 }
8947
8948 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8949 {
8950   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8951     pushBackTimeStep(*it);
8952 }
8953
8954 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8955 {
8956   if(!fmts)
8957     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8958   int nbOfTS(fmts->getNumberOfTS());
8959   for(int i=0;i<nbOfTS;i++)
8960     {
8961       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8962       pushBackTimeStep(elt);
8963     }
8964 }
8965
8966 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8967 {
8968   if(!f1ts)
8969     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8970   checkCoherencyOfType(f1ts);
8971   f1ts->incrRef();
8972   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8973   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8974   c->incrRef();
8975   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8976   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8977     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8978   _content->pushBackTimeStep(cSafe);
8979   appendGlobs(*f1ts,1e-12);
8980 }
8981
8982 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8983 {
8984   contentNotNullBase()->synchronizeNameScope();
8985 }
8986
8987 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8988 {
8989   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8990 }
8991
8992 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8993 {
8994   return contentNotNullBase()->getPosGivenTime(time,eps);
8995 }
8996
8997 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8998 {
8999   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9000 }
9001
9002 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9003 {
9004   return contentNotNullBase()->getTypesOfFieldAvailable();
9005 }
9006
9007 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
9008 {
9009   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9010 }
9011
9012 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9013 {
9014   return contentNotNullBase()->getName();
9015 }
9016
9017 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9018 {
9019   contentNotNullBase()->setName(name);
9020 }
9021
9022 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9023 {
9024   return contentNotNullBase()->getDtUnit();
9025 }
9026
9027 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9028 {
9029   contentNotNullBase()->setDtUnit(dtUnit);
9030 }
9031
9032 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9033 {
9034   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9035 }
9036
9037 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9038 {
9039   return contentNotNullBase()->getTimeSteps(ret1);
9040 }
9041
9042 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9043 {
9044   return contentNotNullBase()->getMeshName();
9045 }
9046
9047 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9048 {
9049   contentNotNullBase()->setMeshName(newMeshName);
9050 }
9051
9052 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9053 {
9054   return contentNotNullBase()->changeMeshNames(modifTab);
9055 }
9056
9057 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9058 {
9059   return contentNotNullBase()->getInfo();
9060 }
9061
9062 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9063 {
9064   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9065 }
9066
9067 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9068 {
9069   return contentNotNullBase()->setInfo(info);
9070 }
9071
9072 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9073 {
9074   const std::vector<std::string> ret=getInfo();
9075   return (int)ret.size();
9076 }
9077
9078 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9079 {
9080   writeGlobals(fid,*this);
9081   contentNotNullBase()->writeLL(fid,*this);
9082 }
9083
9084 /*!
9085  * This method alloc the arrays and load potentially huge arrays contained in this field.
9086  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9087  * This method can be also called to refresh or reinit values from a file.
9088  * 
9089  * \throw If the fileName is not set or points to a non readable MED file.
9090  */
9091 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9092 {
9093   if(getFileName().empty())
9094     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9095   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9096   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9097 }
9098
9099 /*!
9100  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9101  * But once data loaded once, this method does nothing.
9102  * 
9103  * \throw If the fileName is not set or points to a non readable MED file.
9104  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9105  */
9106 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9107 {
9108   if(!getFileName().empty())
9109     {
9110       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9111       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9112     }
9113 }
9114
9115 /*!
9116  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9117  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9118  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9119  * 
9120  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9121  */
9122 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9123 {
9124   contentNotNullBase()->unloadArrays();
9125 }
9126
9127 /*!
9128  * 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.
9129  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9130  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9131  * 
9132  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9133  */
9134 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9135 {
9136   if(!getFileName().empty())
9137     contentNotNullBase()->unloadArrays();
9138 }
9139
9140 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9141 {
9142   std::ostringstream oss;
9143   contentNotNullBase()->simpleRepr(0,oss,-1);
9144   simpleReprGlobs(oss);
9145   return oss.str();
9146 }
9147
9148 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9149 {
9150   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9151 }
9152
9153 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9154 {
9155   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9156   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9157   return ret;
9158 }
9159
9160 /*!
9161  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9162  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9163  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9164  */
9165 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9166 {
9167   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9168   if(!content)
9169     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9170   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9171   std::size_t sz(contentsSplit.size());
9172   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9173   for(std::size_t i=0;i<sz;i++)
9174     {
9175       ret[i]=shallowCpy();
9176       ret[i]->_content=contentsSplit[i];
9177     }
9178   return ret;
9179 }
9180
9181 /*!
9182  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9183  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9184  */
9185 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9186 {
9187   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9188   if(!content)
9189     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9190   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9191   std::size_t sz(contentsSplit.size());
9192   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9193   for(std::size_t i=0;i<sz;i++)
9194     {
9195       ret[i]=shallowCpy();
9196       ret[i]->_content=contentsSplit[i];
9197     }
9198   return ret;
9199 }
9200
9201 /*!
9202  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9203  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9204  */
9205 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9206 {
9207   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9208   if(!content)
9209     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9210   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9211   std::size_t sz(contentsSplit.size());
9212   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9213   for(std::size_t i=0;i<sz;i++)
9214     {
9215       ret[i]=shallowCpy();
9216       ret[i]->_content=contentsSplit[i];
9217     }
9218   return ret;
9219 }
9220
9221 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9222 {
9223   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9224   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9225     ret->_content=_content->deepCopy();
9226   ret->deepCpyGlobs(*this);
9227   return ret.retn();
9228 }
9229
9230 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9231 {
9232   return _content;
9233 }
9234
9235 /*!
9236  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9237  *  \param [in] iteration - the iteration number of a required time step.
9238  *  \param [in] order - the iteration order number of required time step.
9239  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9240  *          delete this field using decrRef() as it is no more needed.
9241  *  \throw If there is no required time step in \a this field.
9242  */
9243 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9244 {
9245   int pos=getPosOfTimeStep(iteration,order);
9246   return getTimeStepAtPos(pos);
9247 }
9248
9249 /*!
9250  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9251  *  \param [in] time - the time of the time step of interest.
9252  *  \param [in] eps - a precision used to compare time values.
9253  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9254  *          delete this field using decrRef() as it is no more needed.
9255  *  \throw If there is no required time step in \a this field.
9256  */
9257 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9258 {
9259   int pos=getPosGivenTime(time,eps);
9260   return getTimeStepAtPos(pos);
9261 }
9262
9263 /*!
9264  * 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.
9265  * The float64 value of time attached to the pair of integers are not considered here.
9266  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9267  *
9268  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9269  * \throw If there is a null pointer in \a vectFMTS.
9270  */
9271 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9272 {
9273   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9274   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9275   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9276   while(!lstFMTS.empty())
9277     {
9278       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9279       MEDFileAnyTypeFieldMultiTS *curIt(*it);
9280       if(!curIt)
9281         throw INTERP_KERNEL::Exception(msg);
9282       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9283       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9284       elt.push_back(curIt); it=lstFMTS.erase(it);
9285       while(it!=lstFMTS.end())
9286         {
9287           curIt=*it;
9288           if(!curIt)
9289             throw INTERP_KERNEL::Exception(msg);
9290           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9291           if(refIts==curIts)
9292             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9293           else
9294             it++;
9295         }
9296       ret.push_back(elt);
9297     }
9298   return ret;
9299 }
9300
9301 /*!
9302  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9303  * All returned instances in a subvector can be safely loaded, rendered along time
9304  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9305  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9306  * 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).
9307  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9308  * 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.
9309  *
9310  * \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().
9311  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9312  * \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.
9313  * \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.
9314  *
9315  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9316  * \throw If an element in \a vectFMTS change of spatial discretization along time.
9317  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9318  * \thorw If some elements in \a vectFMTS do not have the same times steps.
9319  * \throw If mesh is null.
9320  * \throw If an element in \a vectFMTS is null.
9321  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9322  */
9323 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9324 {
9325   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9326   if(!mesh)
9327     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9328   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9329   if(vectFMTS.empty())
9330     return ret;
9331   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9332   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9333   if(!frstElt)
9334     throw INTERP_KERNEL::Exception(msg);
9335   std::size_t i=0;
9336   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9337   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9338   for(;it!=vectFMTS.end();it++,i++)
9339     {
9340       if(!(*it))
9341         throw INTERP_KERNEL::Exception(msg);
9342       TypeOfField tof0,tof1;
9343       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9344         {
9345           if(tof1!=ON_NODES)
9346             vectFMTSNotNodes.push_back(*it);
9347           else
9348             vectFMTSNodes.push_back(*it);
9349         }
9350       else
9351         vectFMTSNotNodes.push_back(*it);
9352     }
9353   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9354   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9355   ret=retCell;
9356   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9357     {
9358       i=0;
9359       bool isFetched(false);
9360       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9361         {
9362           if((*it0).empty())
9363             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9364           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9365             { ret[i].push_back(*it2); isFetched=true; }
9366         }
9367       if(!isFetched)
9368         {
9369           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9370           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9371           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9372         }
9373     }
9374   fsc=cmps;
9375   return ret;
9376 }
9377
9378 /*!
9379  * 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.
9380  * \param [out] cmps - same size than the returned vector.
9381  */
9382 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9383 {
9384   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9385   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9386   while(!lstFMTS.empty())
9387     {
9388       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9389       MEDFileAnyTypeFieldMultiTS *ref(*it);
9390       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9391       elt.push_back(ref); it=lstFMTS.erase(it);
9392       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9393       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9394       while(it!=lstFMTS.end())
9395         {
9396           MEDFileAnyTypeFieldMultiTS *curIt(*it);
9397           if(cmp->isEqual(curIt))
9398             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9399           else
9400             it++;
9401         }
9402       ret.push_back(elt); cmps.push_back(cmp);
9403     }
9404   return ret;
9405 }
9406
9407 /*!
9408  * 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.
9409  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9410  *
9411  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9412  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9413  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9414  * \thorw If \a f0 and \a f1 do not have the same times steps.
9415  * \throw If mesh is null.
9416  * \throw If \a f0 or \a f1 is null.
9417  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9418  */
9419 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9420 {
9421   if(!mesh)
9422     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9423   if(!f0 || !f1)
9424     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9425   if(f0->getMeshName()!=mesh->getName())
9426     {
9427       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9428       throw INTERP_KERNEL::Exception(oss.str());
9429     }
9430   if(f1->getMeshName()!=mesh->getName())
9431     {
9432       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9433       throw INTERP_KERNEL::Exception(oss.str());
9434     }
9435   int nts=f0->getNumberOfTS();
9436   if(nts!=f1->getNumberOfTS())
9437     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9438   if(nts==0)
9439     return nts;
9440   for(int i=0;i<nts;i++)
9441     {
9442       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9443       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9444       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9445       if(tofs0.size()!=1 || tofs1.size()!=1)
9446         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9447       if(i!=0)
9448         {
9449           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9450             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9451         }
9452       else
9453         { tof0=tofs0[0]; tof1=tofs1[0]; }
9454       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9455         {
9456           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() << ") !";
9457           throw INTERP_KERNEL::Exception(oss.str());
9458         }
9459       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9460         {
9461           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() << ") !";
9462           throw INTERP_KERNEL::Exception(oss.str());
9463         }
9464       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9465         {
9466           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() << ") !";
9467           throw INTERP_KERNEL::Exception(oss.str());
9468         }
9469     }
9470   return nts;
9471 }
9472
9473 /*!
9474  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9475  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9476  *
9477  * \return A new object that the caller is responsible to deallocate.
9478  */
9479 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9480 {
9481   if(!mm)
9482     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9483   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9484   int nbTS(getNumberOfTS());
9485   for(int i=0;i<nbTS;i++)
9486     {
9487       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9488       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9489       fmtsOut->pushBackTimeStep(f1tsOut);
9490     }
9491   return fmtsOut.retn();
9492 }
9493
9494 template<class T>
9495 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9496 {
9497   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9498   if(f1tss.empty())
9499     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9500   std::size_t sz(f1tss.size()),i(0);
9501   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9502   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9503     {
9504       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9505       if(!elt)
9506         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9507       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9508     }
9509   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9510   if(!retc)
9511     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9512   retc->aggregate(f1tsw,dts);
9513   ret->setDtUnit(f1tss[0]->getDtUnit());
9514   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9515 }
9516
9517 template<class T>
9518 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9519 {
9520   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9521   if(fmtss.empty())
9522     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9523   std::size_t sz(fmtss.size());
9524   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9525     {
9526       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9527       if(!elt)
9528         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9529     }
9530   int nbTS(fmtss[0]->getNumberOfTS());
9531   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9532     if((*it)->getNumberOfTS()!=nbTS)
9533       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9534   for(int iterTS=0;iterTS<nbTS;iterTS++)
9535     {
9536       std::size_t i(0);
9537       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9538       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9539       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9540         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9541       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9542       ret->pushBackTimeStep(f1ts);
9543       ret->setDtUnit(f1ts->getDtUnit());
9544     }
9545   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9546 }
9547
9548 /*!
9549  * \a dts and \a ftmss are expected to have same size.
9550  */
9551 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9552 {
9553   if(fmtss.empty())
9554     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9555   std::size_t sz(fmtss.size());
9556   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9557   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9558   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9559     {
9560       if(!(*it))
9561         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9562       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9563       if(elt1)
9564         {
9565           fmtss1.push_back(elt1);
9566           continue;
9567         }
9568       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9569       if(elt2)
9570         {
9571           fmtss2.push_back(elt2);
9572           continue;
9573         }
9574       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9575     }
9576   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9577     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9578   if(fmtss1.size()==sz)
9579     return AggregateHelperFMTS<double>(fmtss1,dts);
9580   if(fmtss2.size()!=sz)
9581     return AggregateHelperFMTS<int>(fmtss2,dts);
9582   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9583 }
9584
9585 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9586 {
9587   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9588 }
9589
9590 //= MEDFileFieldMultiTS
9591
9592 /*!
9593  * Returns a new empty instance of MEDFileFieldMultiTS.
9594  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9595  *          is to delete this field using decrRef() as it is no more needed.
9596  */
9597 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9598 {
9599   return new MEDFileFieldMultiTS;
9600 }
9601
9602 /*!
9603  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9604  * that has been read from a specified MED file.
9605  *  \param [in] fileName - the name of the MED file to read.
9606  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9607  *          is to delete this field using decrRef() as it is no more needed.
9608  *  \throw If reading the file fails.
9609  */
9610 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9611 {
9612   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9613   return New(fid,loadAll);
9614 }
9615
9616 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9617 {
9618   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9619   ret->contentNotNull();//to check that content type matches with \a this type.
9620   return ret.retn();
9621 }
9622
9623 /*!
9624  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9625  * that has been read from a specified MED file.
9626  *  \param [in] fileName - the name of the MED file to read.
9627  *  \param [in] fieldName - the name of the field to read.
9628  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9629  *          is to delete this field using decrRef() as it is no more needed.
9630  *  \throw If reading the file fails.
9631  *  \throw If there is no field named \a fieldName in the file.
9632  */
9633 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9634 {
9635   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9636   return New(fid,fieldName,loadAll);
9637 }
9638
9639 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9640 {
9641   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9642   ret->contentNotNull();//to check that content type matches with \a this type.
9643   return ret.retn();
9644 }
9645
9646 /*!
9647  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9648  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9649  *
9650  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9651  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9652  * \warning this is a shallow copy constructor
9653  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9654  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9655  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9656  *          is to delete this field using decrRef() as it is no more needed.
9657  */
9658 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9659 {
9660   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9661 }
9662
9663 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9664 {
9665   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9666   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9667   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9668   ret->contentNotNull();//to check that content type matches with \a this type.
9669   return ret.retn();
9670 }
9671
9672 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9673 {
9674   return new MEDFileFieldMultiTS(*this);
9675 }
9676
9677 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9678 {
9679   if(!f1ts)
9680     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9681   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9682   if(!f1tsC)
9683     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9684 }
9685
9686 /*!
9687  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9688  * following the given input policy.
9689  *
9690  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9691  *                            By default (true) the globals are deeply copied.
9692  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9693  */
9694 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9695 {
9696   MCAuto<MEDFileIntFieldMultiTS> ret;
9697   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9698   if(content)
9699     {
9700       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9701       if(!contc)
9702         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9703       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9704       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9705     }
9706   else
9707     ret=MEDFileIntFieldMultiTS::New();
9708   if(isDeepCpyGlobs)
9709     ret->deepCpyGlobs(*this);
9710   else
9711     ret->shallowCpyGlobs(*this);
9712   return ret.retn();
9713 }
9714
9715 /*!
9716  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9717  *  \param [in] pos - a time step id.
9718  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9719  *          delete this field using decrRef() as it is no more needed.
9720  *  \throw If \a pos is not a valid time step id.
9721  */
9722 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9723 {
9724   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9725   if(!item)
9726     {
9727       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9728       throw INTERP_KERNEL::Exception(oss.str());
9729     }
9730   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9731   if(itemC)
9732     {
9733       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9734       ret->shallowCpyGlobs(*this);
9735       return ret.retn();
9736     }
9737   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9738   throw INTERP_KERNEL::Exception(oss.str());
9739 }
9740
9741 /*!
9742  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9743  * mesh entities of a given dimension of the first mesh in MED file.
9744  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9745  *  \param [in] type - a spatial discretization of interest.
9746  *  \param [in] iteration - the iteration number of a required time step.
9747  *  \param [in] order - the iteration order number of required time step.
9748  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9749  *  \param [in] renumPol - specifies how to permute values of the result field according to
9750  *          the optional numbers of cells and nodes, if any. The valid values are
9751  *          - 0 - do not permute.
9752  *          - 1 - permute cells.
9753  *          - 2 - permute nodes.
9754  *          - 3 - permute cells and nodes.
9755  *
9756  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9757  *          caller is to delete this field using decrRef() as it is no more needed. 
9758  *  \throw If the MED file is not readable.
9759  *  \throw If there is no mesh in the MED file.
9760  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9761  *  \throw If no field values of the required parameters are available.
9762  */
9763 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9764 {
9765   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9766   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9767   if(!myF1TSC)
9768     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9769   MCAuto<DataArray> arrOut;
9770   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9771   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9772   return ret.retn();
9773 }
9774
9775 /*!
9776  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9777  * the top level cells of the first mesh in MED file.
9778  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9779  *  \param [in] type - a spatial discretization of interest.
9780  *  \param [in] iteration - the iteration number of a required time step.
9781  *  \param [in] order - the iteration order number of required time step.
9782  *  \param [in] renumPol - specifies how to permute values of the result field according to
9783  *          the optional numbers of cells and nodes, if any. The valid values are
9784  *          - 0 - do not permute.
9785  *          - 1 - permute cells.
9786  *          - 2 - permute nodes.
9787  *          - 3 - permute cells and nodes.
9788  *
9789  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9790  *          caller is to delete this field using decrRef() as it is no more needed. 
9791  *  \throw If the MED file is not readable.
9792  *  \throw If there is no mesh in the MED file.
9793  *  \throw If no field values of the required parameters are available.
9794  */
9795 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9796 {
9797   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9798   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9799   if(!myF1TSC)
9800     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9801   MCAuto<DataArray> arrOut;
9802   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9803   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9804   return ret.retn();
9805 }
9806
9807 /*!
9808  * 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
9809  * method should be called (getFieldOnMeshAtLevel for example).
9810  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9811  *
9812  * \param [in] iteration - the iteration number of a required time step.
9813  * \param [in] order - the iteration order number of required time step.
9814  * \param [in] mesh - the mesh the field is lying on
9815  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9816  *          caller is to delete this field using decrRef() as it is no more needed. 
9817  */
9818 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9819 {
9820   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9821   MCAuto<DataArray> arrOut;
9822   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9823   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9824   return ret.retn();
9825 }
9826
9827 /*!
9828  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9829  * a given support.
9830  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9831  *  \param [in] type - a spatial discretization of interest.
9832  *  \param [in] iteration - the iteration number of a required time step.
9833  *  \param [in] order - the iteration order number of required time step.
9834  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9835  *  \param [in] mesh - the supporting mesh.
9836  *  \param [in] renumPol - specifies how to permute values of the result field according to
9837  *          the optional numbers of cells and nodes, if any. The valid values are
9838  *          - 0 - do not permute.
9839  *          - 1 - permute cells.
9840  *          - 2 - permute nodes.
9841  *          - 3 - permute cells and nodes.
9842  *
9843  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9844  *          caller is to delete this field using decrRef() as it is no more needed. 
9845  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9846  *  \throw If no field of \a this is lying on \a mesh.
9847  *  \throw If no field values of the required parameters are available.
9848  */
9849 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9850 {
9851   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9852   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9853   if(!myF1TSC)
9854     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9855   MCAuto<DataArray> arrOut;
9856   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9857   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9858   return ret.retn();
9859 }
9860
9861 /*!
9862  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9863  * given support. 
9864  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9865  *  \param [in] type - a spatial discretization of the new field.
9866  *  \param [in] iteration - the iteration number of a required time step.
9867  *  \param [in] order - the iteration order number of required time step.
9868  *  \param [in] mesh - the supporting mesh.
9869  *  \param [in] renumPol - specifies how to permute values of the result field according to
9870  *          the optional numbers of cells and nodes, if any. The valid values are
9871  *          - 0 - do not permute.
9872  *          - 1 - permute cells.
9873  *          - 2 - permute nodes.
9874  *          - 3 - permute cells and nodes.
9875  *
9876  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9877  *          caller is to delete this field using decrRef() as it is no more needed. 
9878  *  \throw If no field of \a this is lying on \a mesh.
9879  *  \throw If no field values of the required parameters are available.
9880  */
9881 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9882 {
9883   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9884   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9885   if(!myF1TSC)
9886     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9887   MCAuto<DataArray> arrOut;
9888   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9889   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9890   return ret.retn();
9891 }
9892
9893 /*!
9894  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9895  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9896  * This method is useful for MED2 file format when field on different mesh was autorized.
9897  */
9898 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9899 {
9900   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9901   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9902   if(!myF1TSC)
9903     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9904   MCAuto<DataArray> arrOut;
9905   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9906   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9907   return ret.retn();
9908 }
9909
9910 /*!
9911  * Returns values and a profile of the field of a given type, of a given time step,
9912  * lying on a given support.
9913  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9914  *  \param [in] type - a spatial discretization of the field.
9915  *  \param [in] iteration - the iteration number of a required time step.
9916  *  \param [in] order - the iteration order number of required time step.
9917  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9918  *  \param [in] mesh - the supporting mesh.
9919  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9920  *          field of interest lies on. If the field lies on all entities of the given
9921  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9922  *          using decrRef() as it is no more needed.  
9923  *  \param [in] glob - the global data storing profiles and localization.
9924  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9925  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9926  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9927  *  \throw If no field of \a this is lying on \a mesh.
9928  *  \throw If no field values of the required parameters are available.
9929  */
9930 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9931 {
9932   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9933   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9934   if(!myF1TSC)
9935     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9936   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9937   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9938 }
9939
9940 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9941 {
9942   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9943   if(!pt)
9944     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9945   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9946   if(!ret)
9947     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 !");
9948   return ret;
9949 }
9950
9951 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9952 {
9953   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9954   if(!pt)
9955     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9956   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9957   if(!ret)
9958     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 !");
9959   return ret;
9960 }
9961
9962 /*!
9963  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9964  * the given field is checked if its elements are sorted suitable for writing to MED file
9965  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9966  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9967  *  \param [in] field - the field to add to \a this.
9968  *  \throw If the name of \a field is empty.
9969  *  \throw If the data array of \a field is not set.
9970  *  \throw If existing time steps have different name or number of components than \a field.
9971  *  \throw If the underlying mesh of \a field has no name.
9972  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9973  */
9974 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9975 {
9976   const DataArrayDouble *arr=0;
9977   if(field)
9978     arr=field->getArray();
9979   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9980 }
9981
9982 /*!
9983  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9984  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9985  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9986  * and \a profile.
9987  *
9988  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9989  * A new profile is added only if no equal profile is missing.
9990  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9991  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9992  *  \param [in] mesh - the supporting mesh of \a field.
9993  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9994  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9995  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9996  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9997  *  \throw If the data array of \a field is not set.
9998  *  \throw If the data array of \a this is already allocated but has different number of
9999  *         components than \a field.
10000  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10001  *  \sa setFieldNoProfileSBT()
10002  */
10003 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10004 {
10005   const DataArrayDouble *arr=0;
10006   if(field)
10007     arr=field->getArray();
10008   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10009 }
10010
10011 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10012 {
10013   _content=new MEDFileFieldMultiTSWithoutSDA;
10014 }
10015
10016 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10017 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10018 {
10019 }
10020 catch(INTERP_KERNEL::Exception& e)
10021 { throw e; }
10022
10023 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10024 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10025 {
10026 }
10027 catch(INTERP_KERNEL::Exception& e)
10028 { throw e; }
10029
10030 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10031 {
10032 }
10033
10034 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
10035 {
10036   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10037 }
10038
10039 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10040 {
10041   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10042 }
10043
10044 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10045 {
10046   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10047 }
10048
10049 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10050 {
10051   return MEDFileFieldMultiTS::New();
10052 }
10053
10054 //= MEDFileAnyTypeFieldMultiTSIterator
10055
10056 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10057 {
10058   if(fmts)
10059     {
10060       fmts->incrRef();
10061       _nb_iter=fmts->getNumberOfTS();
10062     }
10063 }
10064
10065 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
10066 {
10067 }
10068
10069 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10070 {
10071   if(_iter_id<_nb_iter)
10072     {
10073       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10074       if(fmts)
10075         return fmts->getTimeStepAtPos(_iter_id++);
10076       else
10077         return 0;
10078     }
10079   else
10080     return 0;
10081 }
10082
10083 //= MEDFileIntFieldMultiTS
10084
10085 /*!
10086  * Returns a new empty instance of MEDFileFieldMultiTS.
10087  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10088  *          is to delete this field using decrRef() as it is no more needed.
10089  */
10090 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10091 {
10092   return new MEDFileIntFieldMultiTS;
10093 }
10094
10095 /*!
10096  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10097  * that has been read from a specified MED file.
10098  *  \param [in] fileName - the name of the MED file to read.
10099  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10100  *          is to delete this field using decrRef() as it is no more needed.
10101  *  \throw If reading the file fails.
10102  */
10103 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10104 {
10105   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10106   return New(fid,loadAll);
10107 }
10108
10109 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10110 {
10111   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10112   ret->contentNotNull();//to check that content type matches with \a this type.
10113   return ret.retn();
10114 }
10115
10116 /*!
10117  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10118  * that has been read from a specified MED file.
10119  *  \param [in] fileName - the name of the MED file to read.
10120  *  \param [in] fieldName - the name of the field to read.
10121  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10122  *          is to delete this field using decrRef() as it is no more needed.
10123  *  \throw If reading the file fails.
10124  *  \throw If there is no field named \a fieldName in the file.
10125  */
10126 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10127 {
10128   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10129   return New(fid,fieldName,loadAll);
10130 }
10131
10132 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10133 {
10134   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10135   ret->contentNotNull();//to check that content type matches with \a this type.
10136   return ret.retn();
10137 }
10138
10139 /*!
10140  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10141  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10142  *
10143  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10144  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10145  * \warning this is a shallow copy constructor
10146  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10147  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10148  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10149  *          is to delete this field using decrRef() as it is no more needed.
10150  */
10151 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10152 {
10153   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10154 }
10155
10156 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10157 {
10158   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10159   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10160   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10161   ret->contentNotNull();//to check that content type matches with \a this type.
10162   return ret.retn();
10163 }
10164
10165 /*!
10166  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10167  * following the given input policy.
10168  *
10169  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10170  *                            By default (true) the globals are deeply copied.
10171  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10172  */
10173 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10174 {
10175   MCAuto<MEDFileFieldMultiTS> ret;
10176   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10177   if(content)
10178     {
10179       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10180       if(!contc)
10181         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10182       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10183       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10184     }
10185   else
10186     ret=MEDFileFieldMultiTS::New();
10187   if(isDeepCpyGlobs)
10188     ret->deepCpyGlobs(*this);
10189   else
10190     ret->shallowCpyGlobs(*this);
10191   return ret.retn();
10192 }
10193
10194 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10195 {
10196   return new MEDFileIntFieldMultiTS(*this);
10197 }
10198
10199 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10200 {
10201   if(!f1ts)
10202     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10203   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10204   if(!f1tsC)
10205     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10206 }
10207
10208 /*!
10209  * 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
10210  * method should be called (getFieldOnMeshAtLevel for example).
10211  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10212  *
10213  * \param [in] iteration - the iteration number of a required time step.
10214  * \param [in] order - the iteration order number of required time step.
10215  * \param [in] mesh - the mesh the field is lying on
10216  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10217  *          caller is to delete this field using decrRef() as it is no more needed. 
10218  */
10219 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10220 {
10221   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10222   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10223   if(!myF1TSC)
10224     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10225   MCAuto<DataArray> arrOut;
10226   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10227   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10228   return ret2.retn();
10229 }
10230
10231 /*!
10232  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10233  * mesh entities of a given dimension of the first mesh in MED file.
10234  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10235  *  \param [in] type - a spatial discretization of interest.
10236  *  \param [in] iteration - the iteration number of a required time step.
10237  *  \param [in] order - the iteration order number of required time step.
10238  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10239  *  \param [in] renumPol - specifies how to permute values of the result field according to
10240  *          the optional numbers of cells and nodes, if any. The valid values are
10241  *          - 0 - do not permute.
10242  *          - 1 - permute cells.
10243  *          - 2 - permute nodes.
10244  *          - 3 - permute cells and nodes.
10245  *
10246  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10247  *          caller is to delete this field using decrRef() as it is no more needed. 
10248  *  \throw If the MED file is not readable.
10249  *  \throw If there is no mesh in the MED file.
10250  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10251  *  \throw If no field values of the required parameters are available.
10252  */
10253 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10254 {
10255   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10256   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10257   if(!myF1TSC)
10258     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10259   MCAuto<DataArray> arr;
10260   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10261   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10262   return ret2.retn();
10263 }
10264
10265 /*!
10266  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10267  * the top level cells of the first mesh in MED file.
10268  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10269  *  \param [in] type - a spatial discretization of interest.
10270  *  \param [in] iteration - the iteration number of a required time step.
10271  *  \param [in] order - the iteration order number of required time step.
10272  *  \param [in] renumPol - specifies how to permute values of the result field according to
10273  *          the optional numbers of cells and nodes, if any. The valid values are
10274  *          - 0 - do not permute.
10275  *          - 1 - permute cells.
10276  *          - 2 - permute nodes.
10277  *          - 3 - permute cells and nodes.
10278  *
10279  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10280  *          caller is to delete this field using decrRef() as it is no more needed. 
10281  *  \throw If the MED file is not readable.
10282  *  \throw If there is no mesh in the MED file.
10283  *  \throw If no field values of the required parameters are available.
10284  */
10285 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10286 {
10287   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10288   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10289   if(!myF1TSC)
10290     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10291   MCAuto<DataArray> arr;
10292   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10293   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10294   return ret2.retn();
10295 }
10296
10297 /*!
10298  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10299  * a given support.
10300  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10301  *  \param [in] type - a spatial discretization of interest.
10302  *  \param [in] iteration - the iteration number of a required time step.
10303  *  \param [in] order - the iteration order number of required time step.
10304  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10305  *  \param [in] mesh - the supporting mesh.
10306  *  \param [in] renumPol - specifies how to permute values of the result field according to
10307  *          the optional numbers of cells and nodes, if any. The valid values are
10308  *          - 0 - do not permute.
10309  *          - 1 - permute cells.
10310  *          - 2 - permute nodes.
10311  *          - 3 - permute cells and nodes.
10312  *
10313  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10314  *          caller is to delete this field using decrRef() as it is no more needed. 
10315  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10316  *  \throw If no field of \a this is lying on \a mesh.
10317  *  \throw If no field values of the required parameters are available.
10318  */
10319 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10320 {
10321   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10322   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10323   if(!myF1TSC)
10324     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10325   MCAuto<DataArray> arr;
10326   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10327   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10328   return ret2.retn();
10329 }
10330
10331 /*!
10332  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10333  * given support. 
10334  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10335  *  \param [in] type - a spatial discretization of the new field.
10336  *  \param [in] iteration - the iteration number of a required time step.
10337  *  \param [in] order - the iteration order number of required time step.
10338  *  \param [in] mesh - the supporting mesh.
10339  *  \param [out] arrOut - the DataArrayInt containing values of field.
10340  *  \param [in] renumPol - specifies how to permute values of the result field according to
10341  *          the optional numbers of cells and nodes, if any. The valid values are
10342  *          - 0 - do not permute.
10343  *          - 1 - permute cells.
10344  *          - 2 - permute nodes.
10345  *          - 3 - permute cells and nodes.
10346  *
10347  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10348  *          caller is to delete this field using decrRef() as it is no more needed. 
10349  *  \throw If no field of \a this is lying on \a mesh.
10350  *  \throw If no field values of the required parameters are available.
10351  */
10352 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10353 {
10354   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10355   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10356   if(!myF1TSC)
10357     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10358   MCAuto<DataArray> arr;
10359   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10360   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10361   return ret2.retn();
10362 }
10363
10364 /*!
10365  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10366  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10367  * This method is useful for MED2 file format when field on different mesh was autorized.
10368  */
10369 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10370 {
10371   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10372   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10373   if(!myF1TSC)
10374     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10375   MCAuto<DataArray> arr;
10376   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10377   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10378   return ret2.retn();
10379 }
10380
10381 /*!
10382  * Returns values and a profile of the field of a given type, of a given time step,
10383  * lying on a given support.
10384  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10385  *  \param [in] type - a spatial discretization of the field.
10386  *  \param [in] iteration - the iteration number of a required time step.
10387  *  \param [in] order - the iteration order number of required time step.
10388  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10389  *  \param [in] mesh - the supporting mesh.
10390  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10391  *          field of interest lies on. If the field lies on all entities of the given
10392  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10393  *          using decrRef() as it is no more needed.  
10394  *  \param [in] glob - the global data storing profiles and localization.
10395  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10396  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10397  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10398  *  \throw If no field of \a this is lying on \a mesh.
10399  *  \throw If no field values of the required parameters are available.
10400  */
10401 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10402 {
10403   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10404   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10405   if(!myF1TSC)
10406     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10407   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10408   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10409 }
10410
10411 /*!
10412  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10413  *  \param [in] pos - a time step id.
10414  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10415  *          delete this field using decrRef() as it is no more needed.
10416  *  \throw If \a pos is not a valid time step id.
10417  */
10418 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10419 {
10420   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10421   if(!item)
10422     {
10423       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10424       throw INTERP_KERNEL::Exception(oss.str());
10425     }
10426   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10427   if(itemC)
10428     {
10429       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10430       ret->shallowCpyGlobs(*this);
10431       return ret.retn();
10432     }
10433   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10434   throw INTERP_KERNEL::Exception(oss.str());
10435 }
10436
10437 /*!
10438  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10439  * the given field is checked if its elements are sorted suitable for writing to MED file
10440  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10441  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10442  *  \param [in] field - the field to add to \a this.
10443  *  \throw If the name of \a field is empty.
10444  *  \throw If the data array of \a field is not set.
10445  *  \throw If existing time steps have different name or number of components than \a field.
10446  *  \throw If the underlying mesh of \a field has no name.
10447  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10448  */
10449 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10450 {
10451   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10452   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10453 }
10454
10455 /*!
10456  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10457  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10458  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10459  * and \a profile.
10460  *
10461  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10462  * A new profile is added only if no equal profile is missing.
10463  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10464  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10465  *  \param [in] arrOfVals - the values of the field \a field used.
10466  *  \param [in] mesh - the supporting mesh of \a field.
10467  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10468  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10469  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10470  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10471  *  \throw If the data array of \a field is not set.
10472  *  \throw If the data array of \a this is already allocated but has different number of
10473  *         components than \a field.
10474  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10475  *  \sa setFieldNoProfileSBT()
10476  */
10477 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10478 {
10479   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10480   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10481 }
10482
10483 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10484 {
10485   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10486   if(!pt)
10487     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10488   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10489   if(!ret)
10490     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 !");
10491   return ret;
10492 }
10493
10494 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10495 {
10496   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10497   if(!pt)
10498     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10499   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10500   if(!ret)
10501     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 !");
10502   return ret;
10503 }
10504
10505 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10506 {
10507   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10508 }
10509
10510 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10511 {
10512 }
10513
10514 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10515 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10516 {
10517 }
10518 catch(INTERP_KERNEL::Exception& e)
10519 { throw e; }
10520
10521 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10522 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10523 {
10524 }
10525 catch(INTERP_KERNEL::Exception& e)
10526 { throw e; }
10527
10528 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10529 {
10530   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10531 }
10532
10533 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10534 {
10535   return MEDFileIntFieldMultiTS::New();
10536 }
10537
10538 //= MEDFileFields
10539
10540 MEDFileFields *MEDFileFields::New()
10541 {
10542   return new MEDFileFields;
10543 }
10544
10545 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10546 {
10547   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10548   return New(fid,loadAll);
10549 }
10550
10551 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10552 {
10553   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10554   return NewWithDynGT(fid,se,loadAll);
10555 }
10556
10557 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10558 {
10559   if(!se)
10560     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10561   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10562   return new MEDFileFields(fid,loadAll,0,entities);
10563 }
10564
10565 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10566 {
10567   return new MEDFileFields(fid,loadAll,0,0);
10568 }
10569
10570 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10571 {
10572   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10573   return new MEDFileFields(fid,loadAll,ms,0);
10574 }
10575
10576 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10577 {
10578   MEDFileUtilities::CheckFileForRead(fileName);
10579   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10580   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10581   return new MEDFileFields(fid,loadAll,0,ent);
10582 }
10583
10584 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10585 {
10586   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10587   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10588   return ret;
10589 }
10590
10591 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10592 {
10593   std::vector<const BigMemoryObject *> ret;
10594   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10595     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10596   return ret;
10597 }
10598
10599 MEDFileFields *MEDFileFields::deepCopy() const
10600 {
10601   MCAuto<MEDFileFields> ret(shallowCpy());
10602   std::size_t i(0);
10603   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10604     {
10605       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10606         ret->_fields[i]=(*it)->deepCopy();
10607     }
10608   ret->deepCpyGlobs(*this);
10609   return ret.retn();
10610 }
10611
10612 MEDFileFields *MEDFileFields::shallowCpy() const
10613 {
10614   return new MEDFileFields(*this);
10615 }
10616
10617 /*!
10618  * 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
10619  * 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.
10620  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10621  *
10622  * \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.
10623  * \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.
10624  * 
10625  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10626  */
10627 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10628 {
10629   std::set< std::pair<int,int> > s;
10630   bool firstShot=true;
10631   areThereSomeForgottenTS=false;
10632   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10633     {
10634       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10635         continue;
10636       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10637       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10638       if(firstShot)
10639         { s=s1; firstShot=false; }
10640       else
10641         {
10642           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10643           if(s!=s2)
10644             areThereSomeForgottenTS=true;
10645           s=s2;
10646         }
10647     }
10648   std::vector< std::pair<int,int> > ret;
10649   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10650   return ret;
10651 }
10652
10653 int MEDFileFields::getNumberOfFields() const
10654 {
10655   return _fields.size();
10656 }
10657
10658 std::vector<std::string> MEDFileFields::getFieldsNames() const
10659 {
10660   std::vector<std::string> ret(_fields.size());
10661   int i(0);
10662   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10663     {
10664       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10665       if(f)
10666         {
10667           ret[i]=f->getName();
10668         }
10669       else
10670         {
10671           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10672           throw INTERP_KERNEL::Exception(oss.str());
10673         }
10674     }
10675   return ret;
10676 }
10677
10678 std::vector<std::string> MEDFileFields::getMeshesNames() const
10679 {
10680   std::vector<std::string> ret;
10681   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10682     {
10683       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10684       if(cur)
10685         ret.push_back(cur->getMeshName());
10686     }
10687   return ret;
10688 }
10689
10690 std::string MEDFileFields::simpleRepr() const
10691 {
10692   std::ostringstream oss;
10693   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10694   simpleRepr(0,oss);
10695   return oss.str();
10696 }
10697
10698 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10699 {
10700   int nbOfFields(getNumberOfFields());
10701   std::string startLine(bkOffset,' ');
10702   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10703   int i=0;
10704   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10705     {
10706       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10707       if(cur)
10708         {
10709           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10710         }
10711       else
10712         {
10713           oss << startLine << "  - not defined !" << std::endl;
10714         }
10715     }
10716   i=0;
10717   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10718     {
10719       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10720       std::string chapter(17,'0'+i);
10721       oss << startLine << chapter << std::endl;
10722       if(cur)
10723         {
10724           cur->simpleRepr(bkOffset+2,oss,i);
10725         }
10726       else
10727         {
10728           oss << startLine << "  - not defined !" << std::endl;
10729         }
10730       oss << startLine << chapter << std::endl;
10731     }
10732   simpleReprGlobs(oss);
10733 }
10734
10735 MEDFileFields::MEDFileFields()
10736 {
10737 }
10738
10739 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10740 try:MEDFileFieldGlobsReal(fid)
10741 {
10742   int nbFields(MEDnField(fid));
10743   _fields.resize(nbFields);
10744   med_field_type typcha;
10745   for(int i=0;i<nbFields;i++)
10746     {
10747       std::vector<std::string> infos;
10748       std::string fieldName,dtunit;
10749       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10750       switch(typcha)
10751       {
10752         case MED_FLOAT64:
10753           {
10754             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10755             break;
10756           }
10757         case MED_INT32:
10758           {
10759             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10760             break;
10761           }
10762         default:
10763           {
10764             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] !";
10765             throw INTERP_KERNEL::Exception(oss.str());
10766           }
10767       }
10768     }
10769   loadAllGlobals(fid);
10770 }
10771 catch(INTERP_KERNEL::Exception& e)
10772 {
10773     throw e;
10774 }
10775
10776 void MEDFileFields::writeLL(med_idt fid) const
10777 {
10778   int i=0;
10779   writeGlobals(fid,*this);
10780   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10781     {
10782       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10783       if(!elt)
10784         {
10785           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10786           throw INTERP_KERNEL::Exception(oss.str());
10787         }
10788       elt->writeLL(fid,*this);
10789     }
10790 }
10791
10792 /*!
10793  * This method alloc the arrays and load potentially huge arrays contained in this field.
10794  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10795  * This method can be also called to refresh or reinit values from a file.
10796  * 
10797  * \throw If the fileName is not set or points to a non readable MED file.
10798  */
10799 void MEDFileFields::loadArrays()
10800 {
10801   if(getFileName().empty())
10802     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10803   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10804   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10805     {
10806       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10807       if(elt)
10808         elt->loadBigArraysRecursively(fid,*elt);
10809     }
10810 }
10811
10812 /*!
10813  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10814  * But once data loaded once, this method does nothing.
10815  * 
10816  * \throw If the fileName is not set or points to a non readable MED file.
10817  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10818  */
10819 void MEDFileFields::loadArraysIfNecessary()
10820 {
10821   if(!getFileName().empty())
10822     {
10823       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10824       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10825         {
10826           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10827           if(elt)
10828             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10829         }
10830     }
10831 }
10832
10833 /*!
10834  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10835  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10836  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10837  * 
10838  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10839  */
10840 void MEDFileFields::unloadArrays()
10841 {
10842   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10843     {
10844       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10845       if(elt)
10846         elt->unloadArrays();
10847     }
10848 }
10849
10850 /*!
10851  * 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.
10852  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10853  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10854  * 
10855  * \sa MEDFileFields::loadArraysIfNecessary
10856  */
10857 void MEDFileFields::unloadArraysWithoutDataLoss()
10858 {
10859   if(!getFileName().empty())
10860     unloadArrays();
10861 }
10862
10863 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10864 {
10865   std::vector<std::string> ret;
10866   std::set<std::string> ret2;
10867   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10868     {
10869       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10870       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10871         if(ret2.find(*it2)==ret2.end())
10872           {
10873             ret.push_back(*it2);
10874             ret2.insert(*it2);
10875           }
10876     }
10877   return ret;
10878 }
10879
10880 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10881 {
10882   std::vector<std::string> ret;
10883   std::set<std::string> ret2;
10884   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10885     {
10886       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10887       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10888         if(ret2.find(*it2)==ret2.end())
10889           {
10890             ret.push_back(*it2);
10891             ret2.insert(*it2);
10892           }
10893     }
10894   return ret;
10895 }
10896
10897 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10898 {
10899   std::vector<std::string> ret;
10900   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10901     {
10902       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10903       ret.insert(ret.end(),tmp.begin(),tmp.end());
10904     }
10905   return ret;
10906 }
10907
10908 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10909 {
10910   std::vector<std::string> ret;
10911   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10912     {
10913       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10914       ret.insert(ret.end(),tmp.begin(),tmp.end());
10915     }
10916   return ret;
10917 }
10918
10919 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10920 {
10921   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10922     (*it)->changePflsRefsNamesGen2(mapOfModif);
10923 }
10924
10925 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10926 {
10927   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10928     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10929 }
10930
10931 void MEDFileFields::resize(int newSize)
10932 {
10933   _fields.resize(newSize);
10934 }
10935
10936 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10937 {
10938   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10939     pushField(*it);
10940 }
10941
10942 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10943 {
10944   if(!field)
10945     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10946   _fields.push_back(field->getContent());
10947   appendGlobs(*field,1e-12);
10948 }
10949
10950 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10951 {
10952   if(!field)
10953     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10954   if(i>=(int)_fields.size())
10955     _fields.resize(i+1);
10956   _fields[i]=field->getContent();
10957   appendGlobs(*field,1e-12);
10958 }
10959
10960 void MEDFileFields::destroyFieldAtPos(int i)
10961 {
10962   destroyFieldsAtPos(&i,&i+1);
10963 }
10964
10965 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10966 {
10967   std::vector<bool> b(_fields.size(),true);
10968   for(const int *i=startIds;i!=endIds;i++)
10969     {
10970       if(*i<0 || *i>=(int)_fields.size())
10971         {
10972           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10973           throw INTERP_KERNEL::Exception(oss.str());
10974         }
10975       b[*i]=false;
10976     }
10977   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10978   std::size_t j=0;
10979   for(std::size_t i=0;i<_fields.size();i++)
10980     if(b[i])
10981       fields[j++]=_fields[i];
10982   _fields=fields;
10983 }
10984
10985 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10986 {
10987   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10988   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10989   std::vector<bool> b(_fields.size(),true);
10990   int k=bg;
10991   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10992     {
10993       if(k<0 || k>=(int)_fields.size())
10994         {
10995           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10996           throw INTERP_KERNEL::Exception(oss.str());
10997         }
10998       b[k]=false;
10999     }
11000   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11001   std::size_t j(0);
11002   for(std::size_t i=0;i<_fields.size();i++)
11003     if(b[i])
11004       fields[j++]=_fields[i];
11005   _fields=fields;
11006 }
11007
11008 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11009 {
11010   bool ret(false);
11011   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11012     {
11013       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11014       if(cur)
11015         ret=cur->changeMeshNames(modifTab) || ret;
11016     }
11017   return ret;
11018 }
11019
11020 /*!
11021  * \param [in] meshName the name of the mesh that will be renumbered.
11022  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11023  *             This code corresponds to the distribution of types in the corresponding mesh.
11024  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11025  * \param [in] renumO2N the old to new renumber array.
11026  * \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 
11027  *         field in \a this.
11028  */
11029 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11030 {
11031   bool ret(false);
11032   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11033     {
11034       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11035       if(fmts)
11036         {
11037           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11038         }
11039     }
11040   return ret;
11041 }
11042
11043 /*!
11044  * Return an extraction of \a this using \a extractDef map to specify the extraction.
11045  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11046  *
11047  * \return A new object that the caller is responsible to deallocate.
11048  */
11049 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11050 {
11051   if(!mm)
11052     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11053   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11054   int nbFields(getNumberOfFields());
11055   for(int i=0;i<nbFields;i++)
11056     {
11057       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11058       if(!fmts)
11059         {
11060           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11061           throw INTERP_KERNEL::Exception(oss.str());
11062         }
11063       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11064       fsOut->pushField(fmtsOut);
11065     }
11066   return fsOut.retn();
11067 }
11068
11069 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11070 {
11071   if(i<0 || i>=(int)_fields.size())
11072     {
11073       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11074       throw INTERP_KERNEL::Exception(oss.str());
11075     }
11076   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11077   if(!fmts)
11078     return 0;
11079   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11080   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11081   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11082   if(fmtsC)
11083     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11084   else if(fmtsC2)
11085     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11086   else
11087     {
11088       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11089       throw INTERP_KERNEL::Exception(oss.str());
11090     }
11091   ret->shallowCpyGlobs(*this);
11092   return ret.retn();
11093 }
11094
11095 /*!
11096  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11097  * This method is accessible in python using __getitem__ with a list in input.
11098  * \return a new object that the caller should deal with.
11099  */
11100 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11101 {
11102   MCAuto<MEDFileFields> ret=shallowCpy();
11103   std::size_t sz=std::distance(startIds,endIds);
11104   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11105   int j=0;
11106   for(const int *i=startIds;i!=endIds;i++,j++)
11107     {
11108       if(*i<0 || *i>=(int)_fields.size())
11109         {
11110           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11111           throw INTERP_KERNEL::Exception(oss.str());
11112         }
11113       fields[j]=_fields[*i];
11114     }
11115   ret->_fields=fields;
11116   return ret.retn();
11117 }
11118
11119 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11120 {
11121   return getFieldAtPos(getPosFromFieldName(fieldName));
11122 }
11123
11124 /*!
11125  * This method removes, if any, fields in \a this having no time steps.
11126  * 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.
11127  * 
11128  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11129  */
11130 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11131 {
11132   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11133   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11134     {
11135       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11136       if(elt)
11137         {
11138           if(elt->getNumberOfTS()>0)
11139             newFields.push_back(*it);
11140         }
11141     }
11142   if(_fields.size()==newFields.size())
11143     return false;
11144   _fields=newFields;
11145   return true;
11146 }
11147
11148 /*!
11149  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11150  * This method can be seen as a filter applied on \a this, that returns an object containing
11151  * 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
11152  * shallow copied from \a this.
11153  * 
11154  * \param [in] meshName - the name of the mesh on w
11155  * \return a new object that the caller should deal with.
11156  */
11157 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11158 {
11159   MCAuto<MEDFileFields> ret(MEDFileFields::New());
11160   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11161     {
11162       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11163       if(!cur)
11164         continue;
11165       if(cur->getMeshName()==meshName)
11166         {
11167           cur->incrRef();
11168           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11169           ret->_fields.push_back(cur2);
11170         }
11171     }
11172   ret->shallowCpyOnlyUsedGlobs(*this);
11173   return ret.retn();
11174 }
11175
11176 /*!
11177  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11178  * Input time steps are specified using a pair of integer (iteration, order).
11179  * 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,
11180  * but for each multitimestep only the time steps in \a timeSteps are kept.
11181  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11182  * 
11183  * The returned object points to shallow copy of elements in \a this.
11184  * 
11185  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11186  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11187  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11188  */
11189 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11190 {
11191   MCAuto<MEDFileFields> ret(MEDFileFields::New());
11192   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11193     {
11194       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11195       if(!cur)
11196         continue;
11197       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11198       ret->_fields.push_back(elt);
11199     }
11200   ret->shallowCpyOnlyUsedGlobs(*this);
11201   return ret.retn();
11202 }
11203
11204 /*!
11205  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11206  */
11207 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11208 {
11209   MCAuto<MEDFileFields> ret=MEDFileFields::New();
11210   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11211     {
11212       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11213       if(!cur)
11214         continue;
11215       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11216       if(elt->getNumberOfTS()!=0)
11217         ret->_fields.push_back(elt);
11218     }
11219   ret->shallowCpyOnlyUsedGlobs(*this);
11220   return ret.retn();
11221 }
11222
11223 bool MEDFileFields::presenceOfStructureElements() const
11224 {
11225   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11226     if((*it).isNotNull())
11227       if((*it)->presenceOfStructureElements())
11228         return true;
11229   return false;
11230 }
11231
11232 void MEDFileFields::killStructureElements()
11233 {
11234   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11235   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11236     if((*it).isNotNull())
11237       {
11238         if((*it)->presenceOfStructureElements())
11239           {
11240             if(!(*it)->onlyStructureElements())
11241               {
11242                 (*it)->killStructureElements();
11243                 ret.push_back(*it);
11244               }
11245           }
11246         else
11247           {
11248             ret.push_back(*it);
11249           }
11250       }
11251   _fields=ret;
11252 }
11253
11254 void MEDFileFields::keepOnlyStructureElements()
11255 {
11256   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11257   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11258     if((*it).isNotNull())
11259       {
11260         if((*it)->presenceOfStructureElements())
11261           {
11262             if(!(*it)->onlyStructureElements())
11263               (*it)->keepOnlyStructureElements();
11264             ret.push_back(*it);
11265           }
11266       }
11267   _fields=ret;
11268 }
11269
11270 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11271 {
11272   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11273   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11274     if((*it).isNotNull())
11275       {
11276         if((*it)->getMeshName()!=meshName)
11277           continue;
11278         std::vector< std::pair<std::string,std::string> > ps;
11279         (*it)->getMeshSENames(ps);
11280         std::pair<std::string,std::string> p(meshName,seName);
11281         if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11282           (*it)->keepOnlyOnSE(seName);
11283         ret.push_back(*it);
11284       }
11285   _fields=ret;
11286 }
11287
11288 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11289 {
11290   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11291     if((*it).isNotNull())
11292       (*it)->getMeshSENames(ps);
11293 }
11294
11295 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11296 {
11297   MCAuto<MEDFileFields> ret(deepCopy());
11298   ret->keepOnlyStructureElements();
11299   return ret;
11300 }
11301
11302 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11303 {
11304   MCAuto<MEDFileFields> ret(deepCopy());
11305   ret->keepOnlyOnMeshSE(meshName,seName);
11306   return ret;
11307 }
11308
11309 void MEDFileFields::aggregate(const MEDFileFields& other)
11310 {
11311   int nbFieldsToAdd(other.getNumberOfFields());
11312   std::vector<std::string> fsn(getFieldsNames());
11313   for(int i=0;i<nbFieldsToAdd;i++)
11314     {
11315       MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11316       std::string name(elt->getName());
11317       if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11318         {
11319           std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11320           throw INTERP_KERNEL::Exception(oss.str());
11321         }
11322       pushField(elt);
11323     }
11324 }
11325
11326 MEDFileFieldsIterator *MEDFileFields::iterator()
11327 {
11328   return new MEDFileFieldsIterator(this);
11329 }
11330
11331 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11332 {
11333   std::string tmp(fieldName);
11334   std::vector<std::string> poss;
11335   for(std::size_t i=0;i<_fields.size();i++)
11336     {
11337       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11338       if(f)
11339         {
11340           std::string fname(f->getName());
11341           if(tmp==fname)
11342             return i;
11343           else
11344             poss.push_back(fname);
11345         }
11346     }
11347   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11348   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11349   oss << " !";
11350   throw INTERP_KERNEL::Exception(oss.str());
11351 }
11352
11353 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11354 {
11355   if(fs)
11356     {
11357       fs->incrRef();
11358       _nb_iter=fs->getNumberOfFields();
11359     }
11360 }
11361
11362 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
11363 {
11364 }
11365
11366 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11367 {
11368   if(_iter_id<_nb_iter)
11369     {
11370       MEDFileFields *fs(_fs);
11371       if(fs)
11372         return fs->getFieldAtPos(_iter_id++);
11373       else
11374         return 0;
11375     }
11376   else
11377     return 0;
11378 }