]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Refacto step 2 of MEDFileField classes
[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());
541   TypeOfField type(getType());
542   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
543   int profilesize,nbi;
544   med_geometry_type mgeoti;
545   med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
546   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
547   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
548   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
549   const PartDefinition *pd(_pd);
550   if(!pd)
551     {
552       _nval=zeNVal;
553     }
554   else
555     {
556       if(!_profile.empty())
557         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
558       _nval=pd->getNumberOfElems();
559     }
560   _start=start;
561   _end=start+_nval*nbi;
562   start=_end;
563   if(type==ON_CELLS && !_localization.empty())
564     {
565       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
566         setType(ON_GAUSS_PT);
567       else
568         {
569           setType(ON_GAUSS_NE);
570           _localization.clear();
571         }
572     }
573 }
574
575 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
576 {
577   std::string fieldName(nasc.getName()),meshName(getMeshName());
578   int iteration(getIteration()),order(getOrder());
579   TypeOfField type(getType());
580   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
581   med_geometry_type mgeoti;
582   med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
583   if(_start>_end)
584     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
585   if(_start==_end)
586     return ;
587   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
588   if(_start<0 || _start>=arr->getNumberOfTuples())
589     {
590       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
591       throw INTERP_KERNEL::Exception(oss.str());
592     }
593   if(_end<0 || _end>arr->getNumberOfTuples())
594     {
595       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
596       throw INTERP_KERNEL::Exception(oss.str());
597     }
598   int nbOfCompo(arr->getNumberOfComponents());
599   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
600   if(arrD)
601     {
602       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
603       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
604       return ;
605     }
606   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
607   if(arrI)
608     {
609       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
610       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
611       return ;
612     }
613   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
614 }
615
616 /*!
617  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
618  */
619 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
620 {
621   int delta=_end-_start;
622   _start=newValueOfStart;
623   _end=_start+delta;
624 }
625
626 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
627 {
628   return _father->getIteration();
629 }
630
631 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
632 {
633   return _father->getOrder();
634 }
635
636 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
637 {
638   return _father->getTime();
639 }
640
641 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
642 {
643   return _father->getMeshName();
644 }
645
646 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
647 {
648   const char startLine[]="    ## ";
649   std::string startLine2(bkOffset,' ');
650   startLine2+=startLine;
651   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
652   oss << startLine2 << "Localization #" << id << "." << std::endl;
653   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
654   delete tmp;
655   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
656   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
657   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
658 }
659
660 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
661 {
662   return _type;
663 }
664
665 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
666 {
667   return _father->getGeoType();
668 }
669
670 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
671 {
672   types.insert(_type);
673 }
674
675 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
676 {
677   _type=newType;
678 }
679
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
681 {
682   return _father->getNumberOfComponents();
683 }
684
685 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
686 {
687   return _end-_start;
688 }
689
690 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
691 {
692   return _father->getOrCreateAndGetArray();
693 }
694
695 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
696 {
697   const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
698   return fath->getOrCreateAndGetArray();
699 }
700
701 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
702 {
703   return _father->getInfo();
704 }
705
706 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
707 {
708   return _profile;
709 }
710
711 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
712 {
713   _profile=newPflName;
714 }
715
716 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
717 {
718   return _localization;
719 }
720
721 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
722 {
723   _localization=newLocName;
724 }
725
726 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
727 {
728   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
729     {
730       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
731         {
732           _profile=(*it2).second;
733           return;
734         }
735     }
736 }
737
738 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
739 {
740   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
741     {
742       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
743         {
744           _localization=(*it2).second;
745           return;
746         }
747     }
748 }
749
750 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
751 {
752   if(type!=_type)
753     return ;
754   dads.push_back(std::pair<int,int>(_start,_end));
755   geoTypes.push_back(getGeoType());
756   if(_profile.empty())
757     pfls.push_back(0);
758   else
759     {
760       pfls.push_back(glob->getProfile(_profile.c_str()));
761     }
762   if(_localization.empty())
763     locs.push_back(-1);
764   else
765     {
766       locs.push_back(glob->getLocalizationId(_localization.c_str()));
767     }
768 }
769
770 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
771 {
772   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));
773   startEntryId++;
774 }
775
776 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
777 {
778   TypeOfField type=getType();
779   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
780   med_geometry_type mgeoti;
781   med_entity_type menti=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti);
782   const DataArray *arr=getOrCreateAndGetArray();
783   if(!arr)
784     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
785   if(!arr->isAllocated())
786     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
787   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
788   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
789   const unsigned char *locToWrite=0;
790   if(arrD)
791     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
792   else if(arrI)
793     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
794   else
795     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
796   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
797                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
798                                                    locToWrite));
799 }
800
801 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
802 {
803   type=_type;
804   pfl=_profile;
805   loc=_localization;
806   dad.first=_start; dad.second=_end;
807 }
808
809 /*!
810  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
811  *             This code corresponds to the distribution of types in the corresponding mesh.
812  * \param [out] ptToFill memory zone where the output will be stored.
813  * \return the size of data pushed into output param \a ptToFill
814  */
815 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
816 {
817   _loc_id=offset;
818   std::ostringstream oss;
819   std::size_t nbOfType=codeOfMesh.size()/3;
820   int found=-1;
821   for(std::size_t i=0;i<nbOfType && found==-1;i++)
822     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
823       found=(int)i;
824   if(found==-1)
825     {
826       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
827       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
828       throw INTERP_KERNEL::Exception(oss.str());
829     }
830   int *work=ptToFill;
831   if(_profile.empty())
832     {
833       if(_nval!=codeOfMesh[3*found+1])
834         {
835           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
836           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
837           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
838           throw INTERP_KERNEL::Exception(oss.str());
839         }
840       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
841         *work++=ii;
842     }
843   else
844     {
845       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
846       if(pfl->getNumberOfTuples()!=_nval)
847         {
848           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
849           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
850           oss << _nval;
851           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
852           throw INTERP_KERNEL::Exception(oss.str());
853         }
854       int offset2=codeOfMesh[3*found+2];
855       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
856         {
857           if(*pflId<codeOfMesh[3*found+1])
858             *work++=offset2+*pflId;
859         }
860     }
861   return _nval;
862 }
863
864 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
865 {
866   for(int i=_start;i<_end;i++)
867     *ptToFill++=i;
868   return _end-_start;
869 }
870
871 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
872 {
873   switch(type)
874   {
875     case ON_CELLS:
876       return -2;
877     case ON_GAUSS_NE:
878       return -1;
879     case ON_GAUSS_PT:
880       return locId;
881     default:
882       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
883   }
884 }
885
886 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
887 {
888   int id=0;
889   std::map<std::pair<std::string,TypeOfField>,int> m;
890   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
891   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
892     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
893       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
894   ret.resize(id);
895   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
896     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
897   return ret;
898 }
899
900 /*!
901  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
902  * 
903  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
904  * \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.
905  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
906  * \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)
907  * \param [in,out] glob if necessary by the method, new profiles can be added to it
908  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
909  * \param [out] result All new entries will be appended on it.
910  * \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 !)
911  */
912 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
913                                                        const DataArrayInt *explicitIdsInMesh,
914                                                        const std::vector<int>& newCode,
915                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
916                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
917 {
918   if(entriesOnSameDisc.empty())
919     return false;
920   TypeOfField type=entriesOnSameDisc[0]->getType();
921   int szEntities=0,szTuples=0;
922   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
923     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
924   int nbi=szTuples/szEntities;
925   if(szTuples%szEntities!=0)
926     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
927   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
928   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
929   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
930   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
931   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
932   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
933   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
934   int id=0;
935   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
936     {
937       int startOfEltIdOfChunk=(*it)->_start;
938       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
939       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
940       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
941       //
942       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
943       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
944       //
945       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
946       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
947     }
948   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
949   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
950   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
951   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
952   //
953   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
954   //
955   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
956   arrPart->renumberInPlace(renumTupleIds->begin());
957   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
958   bool ret=false;
959   const int *idIt=diffVals->begin();
960   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
961   int offset2=0;
962   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
963     {
964       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
965       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
966       int nbEntityElts=subIds->getNumberOfTuples();
967       bool ret2;
968       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
969           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
970                                       offset+offset2,
971                                       li,glob,ret2);
972       ret=ret || ret2;
973       result.push_back(eltToAdd);
974       offset2+=nbEntityElts*nbi;
975     }
976   ret=ret || li.empty();
977   return ret;
978 }
979
980 /*!
981  * \param [in] typeF type of field of new chunk
982  * \param [in] geoType the geometric type of the chunk
983  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
984  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
985  * \param [in] nbi number of integration points
986  * \param [in] offset The offset in the **global array of data**.
987  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
988  *                 to the new chunk to create.
989  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
990  * \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
991  *              and corresponding entry erased from \a entriesOnSameDisc.
992  * \return a newly allocated chunk
993  */
994 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
995                                                                                                   bool isPfl, int nbi, int offset,
996                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
997                                                                                                   MEDFileFieldGlobsReal& glob,
998                                                                                                   bool &notInExisting)
999 {
1000   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1001   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1002   for(;it!=entriesOnSameDisc.end();it++)
1003     {
1004       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1005         {
1006           if(!isPfl)
1007             {
1008               if((*it)->_profile.empty())
1009                 break;
1010               else
1011                 if(!(*it)->_profile.empty())
1012                   {
1013                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1014                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1015                       break;
1016                   }
1017             }
1018         }
1019     }
1020   if(it==entriesOnSameDisc.end())
1021     {
1022       notInExisting=true;
1023       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1024       ret->_type=typeF;
1025       ret->_loc_id=(int)geoType;
1026       ret->_nval=nbMeshEntities;
1027       ret->_start=offset;
1028       ret->_end=ret->_start+ret->_nval*nbi;
1029       if(isPfl)
1030         {
1031           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1032           glob.appendProfile(idsOfMeshElt);
1033           ret->_profile=idsOfMeshElt->getName();
1034         }
1035       //tony treatment of localization
1036       return ret;
1037     }
1038   else
1039     {
1040       notInExisting=false;
1041       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1042       ret->_loc_id=(int)geoType;
1043       ret->setNewStart(offset);
1044       entriesOnSameDisc.erase(it);
1045       return ret;
1046     }
1047
1048 }
1049
1050 ////////////////////////////////////
1051
1052 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1053  {
1054  }
1055
1056 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1057 {
1058   _father=father;
1059 }
1060
1061 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1062 {
1063   std::size_t i=0;
1064   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1065     {
1066       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1067         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1068     }
1069 }
1070
1071 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1072 {
1073   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1074 }
1075
1076 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1077 {
1078   std::vector<const BigMemoryObject *> ret;
1079   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1080     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1081   return ret;
1082 }
1083
1084 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 {
1086   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1087   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1088     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1089 }
1090
1091 /*!
1092  * This method is the most general one. No optimization is done here.
1093  * \param [in] multiTypePfl is the end user profile specified in high level API
1094  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1095  * \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.
1096  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1097  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1098  * \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.
1099  */
1100 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)
1101 {
1102   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1103   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1104     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1105 }
1106
1107 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 {
1109   _field_pm_pt_pd.resize(1);
1110   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1111   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1112 }
1113
1114 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 {
1116   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1117   if(!arr || !arr->isAllocated())
1118     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1119   _field_pm_pt_pd.resize(1);
1120   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1121   _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.
1122 }
1123
1124 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 {
1126   TypeOfField type=field->getTypeOfField();
1127   if(type!=ON_GAUSS_PT)
1128     {
1129       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1130       int sz=_field_pm_pt_pd.size();
1131       bool found=false;
1132       for(int j=0;j<sz && !found;j++)
1133         {
1134           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135             {
1136               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1137               found=true;
1138             }
1139         }
1140       if(!found)
1141         {
1142           _field_pm_pt_pd.resize(sz+1);
1143           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144         }
1145       std::vector<int> ret(1,(int)sz);
1146       return ret;
1147     }
1148   else
1149     {
1150       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1151       int sz2=ret2.size();
1152       std::vector<int> ret3(sz2);
1153       int k=0;
1154       for(int i=0;i<sz2;i++)
1155         {
1156           int sz=_field_pm_pt_pd.size();
1157           int locIdToFind=ret2[i];
1158           bool found=false;
1159           for(int j=0;j<sz && !found;j++)
1160             {
1161               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162                 {
1163                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1164                   ret3[k++]=j;
1165                   found=true;
1166                 }
1167             }
1168           if(!found)
1169             {
1170               _field_pm_pt_pd.resize(sz+1);
1171               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1172               ret3[k++]=sz;
1173             }
1174         }
1175       return ret3;
1176     }
1177 }
1178
1179 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 {
1181   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1182   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183   if(!disc2)
1184     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1185   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186   if(!da)
1187     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1188   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1189   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1190   if(retTmp->presenceOfValue(-1))
1191     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1192   std::vector<int> ret(retTmp->begin(),retTmp->end());
1193   return ret;
1194 }
1195
1196 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 {
1198   TypeOfField type=field->getTypeOfField();
1199   if(type!=ON_GAUSS_PT)
1200     {
1201       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1202       int sz=_field_pm_pt_pd.size();
1203       bool found=false;
1204       for(int j=0;j<sz && !found;j++)
1205         {
1206           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207             {
1208               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1209               found=true;
1210             }
1211         }
1212       if(!found)
1213         {
1214           _field_pm_pt_pd.resize(sz+1);
1215           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216         }
1217       std::vector<int> ret(1,0);
1218       return ret;
1219     }
1220   else
1221     {
1222       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1223       int sz2=ret2.size();
1224       std::vector<int> ret3(sz2);
1225       int k=0;
1226       for(int i=0;i<sz2;i++)
1227         {
1228           int sz=_field_pm_pt_pd.size();
1229           int locIdToFind=ret2[i];
1230           bool found=false;
1231           for(int j=0;j<sz && !found;j++)
1232             {
1233               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234                 {
1235                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1236                   ret3[k++]=j;
1237                   found=true;
1238                 }
1239             }
1240           if(!found)
1241             {
1242               _field_pm_pt_pd.resize(sz+1);
1243               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1244               ret3[k++]=sz;
1245             }
1246         }
1247       return ret3;
1248     }
1249 }
1250
1251 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 {
1253   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1254   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255   if(!disc2)
1256     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1257   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258   if(!da)
1259     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1260   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1261   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1262   if(retTmp->presenceOfValue(-1))
1263     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1264   std::vector<int> ret(retTmp->begin(),retTmp->end());
1265   return ret;
1266 }
1267
1268 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1269 {
1270   return _father;
1271 }
1272
1273 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1274 {
1275   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1276   int curDim((int)cm.getDimension());
1277   if(dim!=std::numeric_limits<int>::max())
1278     {
1279       if(dim!=curDim)
1280         return false;
1281     }
1282   else
1283     dim=curDim;
1284   return true;
1285 }
1286
1287 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1288 {
1289   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1290     {
1291       (*it)->fillTypesOfFieldAvailable(types);
1292     }
1293 }
1294
1295 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
1296 {
1297   int sz=_field_pm_pt_pd.size();
1298   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1299   for(int i=0;i<sz;i++)
1300     {
1301       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1302     }
1303 }
1304
1305 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1306 {
1307   return _father->getIteration();
1308 }
1309
1310 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1311 {
1312   return _father->getOrder();
1313 }
1314
1315 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1316 {
1317   return _father->getTime();
1318 }
1319
1320 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1321 {
1322   return _father->getMeshName();
1323 }
1324
1325 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1326 {
1327   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1328     {
1329       globalSz+=(*it)->getNumberOfTuples();
1330     }
1331   nbOfEntries+=(int)_field_pm_pt_pd.size();
1332 }
1333
1334 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1335 {
1336   return _father->getNumberOfComponents();
1337 }
1338
1339 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1340 {
1341   std::size_t nb(0);
1342   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343     {
1344       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1345       if(fmtd)
1346         nb++;
1347     }
1348   return nb>1;
1349 }
1350
1351 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1352 {
1353   return _father->getOrCreateAndGetArray();
1354 }
1355
1356 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1357 {
1358   const MEDFileFieldPerMesh *fath=_father;
1359   return fath->getOrCreateAndGetArray();
1360 }
1361
1362 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1363 {
1364   return _father->getInfo();
1365 }
1366
1367 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1368 {
1369   std::vector<std::string> ret;
1370   std::set<std::string> ret2;
1371   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1372     {
1373       std::string tmp=(*it1)->getProfile();
1374       if(!tmp.empty())
1375         if(ret2.find(tmp)==ret2.end())
1376           {
1377             ret.push_back(tmp);
1378             ret2.insert(tmp);
1379           }
1380     }
1381   return ret;
1382 }
1383
1384 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1385 {
1386   std::vector<std::string> ret;
1387   std::set<std::string> ret2;
1388   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1389     {
1390       std::string tmp=(*it1)->getLocalization();
1391       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1392         if(ret2.find(tmp)==ret2.end())
1393           {
1394             ret.push_back(tmp);
1395             ret2.insert(tmp);
1396           }
1397     }
1398   return ret;
1399 }
1400
1401 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1402 {
1403   std::vector<std::string> ret;
1404   std::set<std::string> ret2;
1405   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1406     {
1407       std::string tmp=(*it1)->getProfile();
1408       if(!tmp.empty())
1409         ret.push_back(tmp);
1410     }
1411   return ret;
1412 }
1413
1414 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1415 {
1416   std::vector<std::string> ret;
1417   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1418     {
1419       std::string tmp=(*it1)->getLocalization();
1420       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1421         ret.push_back(tmp);
1422     }
1423   return ret;
1424 }
1425
1426 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1427 {
1428   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1429     (*it1)->changePflsRefsNamesGen(mapOfModif);
1430 }
1431
1432 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(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)->changeLocsRefsNamesGen(mapOfModif);
1436 }
1437
1438 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1439 {
1440   if(_field_pm_pt_pd.empty())
1441     {
1442       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1443       throw INTERP_KERNEL::Exception(oss.str());
1444     }
1445   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1446     return _field_pm_pt_pd[locId];
1447   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1448   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1449   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1450   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1451 }
1452
1453 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1454 {
1455   if(_field_pm_pt_pd.empty())
1456     {
1457       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1458       throw INTERP_KERNEL::Exception(oss.str());
1459     }
1460   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1461     return _field_pm_pt_pd[locId];
1462   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1463   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1464   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1465   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1466 }
1467
1468 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1469 {
1470   int i=0;
1471   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1472     {
1473       (*it)->fillValues(i,startEntryId,entries);
1474     }
1475 }
1476
1477 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1478 {
1479   _field_pm_pt_pd=leaves;
1480   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1481     (*it)->setFather(this);
1482 }
1483
1484 /*!
1485  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1486  *  \param [out] its - list of pair (start,stop) kept
1487  *  \return bool - false if the type of field \a tof is not contained in \a this.
1488  */
1489 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1490 {
1491   bool ret(false);
1492   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1493   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1494     if((*it)->getType()==tof)
1495       {
1496         newPmPtPd.push_back(*it);
1497         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1498         (*it)->setNewStart(globalNum);
1499         globalNum=(*it)->getEnd();
1500         its.push_back(bgEnd);
1501         ret=true;
1502       }
1503   if(ret)
1504     _field_pm_pt_pd=newPmPtPd;
1505   return ret;
1506 }
1507
1508 /*!
1509  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1510  *  \param [out] its - list of pair (start,stop) kept
1511  *  \return bool - false if the type of field \a tof is not contained in \a this.
1512  */
1513 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1514 {
1515   if(_field_pm_pt_pd.size()<=idOfDisc)
1516     return false;
1517   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1518   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1519   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1520   elt->setNewStart(globalNum);
1521   globalNum=elt->getEnd();
1522   its.push_back(bgEnd);
1523   _field_pm_pt_pd=newPmPtPd;
1524   return true;
1525 }
1526
1527 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1528 {
1529   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1530     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1531 }
1532
1533 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, 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)->loadBigArray(fid,nasc);
1537 }
1538
1539 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1540 {
1541   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542     {
1543       (*it)->copyOptionsFrom(*this);
1544       (*it)->writeLL(fid,nasc);
1545     }
1546 }
1547
1548 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1549 {
1550   switch(ikType)
1551   {
1552     case ON_CELLS:
1553       medfGeoType=typmai3[(int)ikGeoType];
1554       return MED_CELL;
1555     case ON_NODES:
1556       medfGeoType=MED_NONE;
1557       return MED_NODE;
1558     case ON_GAUSS_NE:
1559       medfGeoType=typmai3[(int)ikGeoType];
1560       return MED_NODE_ELEMENT;
1561     case ON_GAUSS_PT:
1562       medfGeoType=typmai3[(int)ikGeoType];
1563       return MED_CELL;
1564     default:
1565       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1566   }
1567   return MED_UNDEF_ENTITY_TYPE;
1568 }
1569
1570 //////////////////////////////////////////////////
1571
1572 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1573 {
1574   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1575 }
1576
1577 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1578 {
1579   return new MEDFileFieldPerMeshPerType(fath,geoType);
1580 }
1581
1582 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1583 {
1584   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1585   ret->setFather(father);
1586   ret->deepCopyElements();
1587   return ret.retn();
1588 }
1589
1590 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
1591 {
1592   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1593     {
1594       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1595       if(meshDim!=(int)cm.getDimension())
1596         return ;
1597     }
1598   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1599     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1600 }
1601
1602 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1603 {
1604   return _geo_type;
1605 }
1606
1607 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1608 {
1609   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1610   int curDim((int)cm.getDimension());
1611   dim=std::max(dim,curDim);
1612 }
1613
1614 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1615 {
1616   const char startLine[]="  ## ";
1617   std::string startLine2(bkOffset,' ');
1618   std::string startLine3(startLine2);
1619   startLine3+=startLine;
1620   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1621     {
1622       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1623       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1624     }
1625   else
1626     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1627   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1628   int i=0;
1629   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1630     {
1631       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1632       if(cur)
1633         cur->simpleRepr(bkOffset,oss,i);
1634       else
1635         {
1636           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1637         }
1638     }
1639 }
1640
1641 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1642 {
1643   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1644   return std::string(cm.getRepr());
1645 }
1646
1647 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1648 {
1649 }
1650
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1652 {
1653   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1654   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1655   med_geometry_type mgeoti;
1656   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1657   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1658   _field_pm_pt_pd.resize(nbProfiles);
1659   for(int i=0;i<nbProfiles;i++)
1660     {
1661       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1662     }
1663   if(type==ON_CELLS)
1664     {
1665       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1666       for(int i=0;i<nbProfiles2;i++)
1667         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1668     }
1669 }
1670
1671 //////////////////////////////////////////////////
1672
1673 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1674 {
1675   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1676 }
1677
1678 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1679 {
1680   return new MEDFileFieldPerMesh(fath,mesh);
1681 }
1682
1683 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1684 {
1685   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1686 }
1687
1688 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1689 {
1690   std::vector<const BigMemoryObject *> ret;
1691   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1692     ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1693   return ret;
1694 }
1695
1696 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1697 {
1698   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1699   ret->_father=father;
1700   std::size_t i=0;
1701   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1702     {
1703       if((const MEDFileFieldPerMeshPerType *)*it)
1704         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1705     }
1706   return ret.retn();
1707 }
1708
1709 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1710 {
1711   std::string startLine(bkOffset,' ');
1712   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1713   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1714   int i=0;
1715   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1716     {
1717       const MEDFileFieldPerMeshPerType *cur=*it;
1718       if(cur)
1719         cur->simpleRepr(bkOffset,oss,i);
1720       else
1721         {
1722           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1723         }
1724     }
1725 }
1726
1727 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1728 {
1729   _mesh_name=mesh->getName();
1730   mesh->getTime(_mesh_iteration,_mesh_order);
1731 }
1732
1733 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1734 {
1735   int nbOfTypes=code.size()/3;
1736   int offset=0;
1737   for(int i=0;i<nbOfTypes;i++)
1738     {
1739       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1740       int nbOfCells=code[3*i+1];
1741       int pos=addNewEntryIfNecessary(type);
1742       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1743       offset+=nbOfCells;
1744     }
1745 }
1746
1747 /*!
1748  * This method is the most general one. No optimization is done here.
1749  * \param [in] multiTypePfl is the end user profile specified in high level API
1750  * \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].
1751  * \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.
1752  * \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.
1753  * \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.
1754  * \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.
1755  */
1756 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)
1757 {
1758   int nbOfTypes(code.size()/3);
1759   for(int i=0;i<nbOfTypes;i++)
1760     {
1761       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1762       int pos=addNewEntryIfNecessary(type);
1763       DataArrayInt *pfl=0;
1764       if(code[3*i+2]!=-1)
1765         pfl=idsPerType[code[3*i+2]];
1766       int nbOfTupes2=code2.size()/3;
1767       int found=0;
1768       for(;found<nbOfTupes2;found++)
1769         if(code[3*i]==code2[3*found])
1770           break;
1771       if(found==nbOfTupes2)
1772         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1773       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1774     }
1775 }
1776
1777 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1778 {
1779   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1780   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1781 }
1782
1783 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1784 {
1785   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1786   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1787 }
1788
1789 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1790 {
1791   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1792     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1793 }
1794
1795 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1796 {
1797   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1798     (*it)->loadBigArraysRecursively(fid,nasc);
1799 }
1800
1801 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1802 {
1803   int nbOfTypes=_field_pm_pt.size();
1804   for(int i=0;i<nbOfTypes;i++)
1805     {
1806       _field_pm_pt[i]->copyOptionsFrom(*this);
1807       _field_pm_pt[i]->writeLL(fid,nasc);
1808     }
1809 }
1810
1811 void MEDFileFieldPerMesh::getDimension(int& dim) const
1812 {
1813   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1814     (*it)->getDimension(dim);
1815 }
1816
1817 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1818 {
1819   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1820     if(!(*it)->isUniqueLevel(dim))
1821       return false;
1822   return true;
1823 }
1824
1825 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1826 {
1827   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1828     (*it)->fillTypesOfFieldAvailable(types);
1829 }
1830
1831 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
1832 {
1833   int sz=_field_pm_pt.size();
1834   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1835   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1836   for(int i=0;i<sz;i++)
1837     {
1838       types[i]=_field_pm_pt[i]->getGeoType();
1839       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1840     }
1841   return ret;
1842 }
1843
1844 double MEDFileFieldPerMesh::getTime() const
1845 {
1846   int tmp1,tmp2;
1847   return _father->getTime(tmp1,tmp2);
1848 }
1849
1850 int MEDFileFieldPerMesh::getIteration() const
1851 {
1852   return _father->getIteration();
1853 }
1854
1855 int MEDFileFieldPerMesh::getOrder() const
1856 {
1857   return _father->getOrder();
1858 }
1859
1860 int MEDFileFieldPerMesh::getNumberOfComponents() const
1861 {
1862   return _father->getNumberOfComponents();
1863 }
1864
1865 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1866 {
1867   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1868     {
1869       const MEDFileFieldPerMeshPerType *fpmt(*it);
1870       if(!fpmt)
1871         continue;
1872       if(fpmt->presenceOfMultiDiscPerGeoType())
1873         return true;
1874     }
1875   return false;
1876 }
1877
1878 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1879 {
1880   if(!_father)
1881     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1882   return _father->getOrCreateAndGetArray();
1883 }
1884
1885 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1886 {
1887   if(!_father)
1888     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1889   return _father->getOrCreateAndGetArray();
1890 }
1891
1892 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1893 {
1894   return _father->getInfo();
1895 }
1896
1897 /*!
1898  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1899  * 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.
1900  * It returns 2 output vectors :
1901  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1902  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1903  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1904  */
1905 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)
1906 {
1907   int notNullPflsSz=0;
1908   int nbOfArrs=geoTypes.size();
1909   for(int i=0;i<nbOfArrs;i++)
1910     if(pfls[i])
1911       notNullPflsSz++;
1912   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1913   int nbOfDiffGeoTypes=geoTypes3.size();
1914   code.resize(3*nbOfDiffGeoTypes);
1915   notNullPfls.resize(notNullPflsSz);
1916   notNullPflsSz=0;
1917   int j=0;
1918   for(int i=0;i<nbOfDiffGeoTypes;i++)
1919     {
1920       int startZone=j;
1921       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1922       std::vector<const DataArrayInt *> notNullTmp;
1923       if(pfls[j])
1924         notNullTmp.push_back(pfls[j]);
1925       j++;
1926       for(;j<nbOfArrs;j++)
1927         if(geoTypes[j]==refType)
1928           {
1929             if(pfls[j])
1930               notNullTmp.push_back(pfls[j]);
1931           }
1932         else
1933           break;
1934       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1935       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1936       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1937       code[3*i]=(int)refType;
1938       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1939       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1940       if(notNullTmp.empty())
1941         code[3*i+2]=-1;
1942       else
1943         {
1944           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1945           code[3*i+2]=notNullPflsSz++;
1946         }
1947     }
1948 }
1949
1950 /*!
1951  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1952  */
1953 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)
1954 {
1955   int sz=dads.size();
1956   int ret=0;
1957   for(int i=0;i<sz;i++)
1958     {
1959       if(locs[i]==-1)
1960         {
1961           if(type!=ON_GAUSS_NE)
1962             ret+=dads[i].second-dads[i].first;
1963           else
1964             {
1965               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1966               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1967             }
1968         }
1969       else
1970         {
1971           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1972           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1973         }
1974     }
1975   return ret;
1976 }
1977
1978 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1979 {
1980   std::vector<std::string> ret;
1981   std::set<std::string> ret2;
1982   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1983     {
1984       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1985       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1986         if(ret2.find(*it2)==ret2.end())
1987           {
1988             ret.push_back(*it2);
1989             ret2.insert(*it2);
1990           }
1991     }
1992   return ret;
1993 }
1994
1995 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1996 {
1997   std::vector<std::string> ret;
1998   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1999     {
2000       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2001       ret.insert(ret.end(),tmp.begin(),tmp.end());
2002     }
2003   return ret;
2004 }
2005
2006 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2007 {
2008   std::vector<std::string> ret;
2009   std::set<std::string> ret2;
2010   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2011     {
2012       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2013       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2014         if(ret2.find(*it2)==ret2.end())
2015           {
2016             ret.push_back(*it2);
2017             ret2.insert(*it2);
2018           }
2019     }
2020   return ret;
2021 }
2022
2023 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2024 {
2025   std::vector<std::string> ret;
2026   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2027     {
2028       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2029       ret.insert(ret.end(),tmp.begin(),tmp.end());
2030     }
2031   return ret;
2032 }
2033
2034 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2035 {
2036   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2037     {
2038       if((*it).first==_mesh_name)
2039         {
2040           _mesh_name=(*it).second;
2041           return true;
2042         }
2043     }
2044   return false;
2045 }
2046
2047 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2048                                                       MEDFileFieldGlobsReal& glob)
2049 {
2050   if(_mesh_name!=meshName)
2051     return false;
2052   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2053   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2054   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2055   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2056   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2057   getUndergroundDataArrayExt(entries);
2058   DataArray *arr0(getOrCreateAndGetArray());//tony
2059   if(!arr0)
2060     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2061   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2062   if(!arr0)
2063     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2064   int sz=0;
2065   if(!arr)
2066     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2067   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2068     {
2069       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2070         {
2071           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2072           sz+=(*it).second.second-(*it).second.first;
2073         }
2074       else
2075         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2076     }
2077   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2078   ////////////////////
2079   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2080   int *workI2=explicitIdsOldInMesh->getPointer();
2081   int sz1=0,sz2=0,sid=1;
2082   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2083   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2084   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2085     {
2086       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2087       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2088       int *workI=explicitIdsOldInArr->getPointer();
2089       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2090         {
2091           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2092           (*itL2)->setLocId(sz2);
2093           (*itL2)->_tmp_work1=(*itL2)->getStart();
2094           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2095         }
2096       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2097     }
2098   explicitIdsOldInMesh->reAlloc(sz2);
2099   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2100   ////////////////////
2101   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2102   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2103   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2104   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2105     {
2106       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2107       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2108       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2109     }
2110   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2111   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2112   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2113     {
2114       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2115       int newStart=elt->getLocId();
2116       elt->setLocId((*it)->getGeoType());
2117       elt->setNewStart(newStart);
2118       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2119       entriesKeptNew.push_back(elt);
2120       entriesKeptNew2.push_back(elt);
2121     }
2122   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2123   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2124   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2125   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2126   bool ret=false;
2127   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2128     {
2129       sid=0;
2130       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2131         {
2132           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2133           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2134           }*/
2135       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2136                                                             glob,arr2,otherEntriesNew) || ret;
2137     }
2138   if(!ret)
2139     return false;
2140   // Assign new dispatching
2141   assignNewLeaves(otherEntriesNew);
2142   arr->deepCopyFrom(*arr2);
2143   return true;
2144 }
2145
2146 /*!
2147  * \param [in,out] globalNum a global numbering counter for the renumbering.
2148  * \param [out] its - list of pair (start,stop) kept
2149  */
2150 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2151 {
2152   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2153   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2154     {
2155       std::vector< std::pair<int,int> > its2;
2156       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2157         {
2158           ret.push_back(*it);
2159           its.insert(its.end(),its2.begin(),its2.end());
2160         }
2161     }
2162   _field_pm_pt=ret;
2163 }
2164
2165 /*!
2166  * \param [in,out] globalNum a global numbering counter for the renumbering.
2167  * \param [out] its - list of pair (start,stop) kept
2168  */
2169 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2170 {
2171   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2172   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2173     {
2174       std::vector< std::pair<int,int> > its2;
2175       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2176         {
2177           ret.push_back(*it);
2178           its.insert(its.end(),its2.begin(),its2.end());
2179         }
2180     }
2181   _field_pm_pt=ret;
2182 }
2183
2184 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2185 {
2186   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2187   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2188     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2189   //
2190   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2191   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2192   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2193   for(;it1!=types.end();it1++,it2++)
2194     {
2195       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2196       elt->setLeaves((*it1).second);
2197       *it2=elt;
2198     }
2199   _field_pm_pt=fieldPmPt;
2200 }
2201
2202 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2203 {
2204   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2205     (*it)->changePflsRefsNamesGen(mapOfModif);
2206 }
2207
2208 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2209 {
2210   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2211     (*it)->changeLocsRefsNamesGen(mapOfModif);
2212 }
2213
2214 /*!
2215  * \param [in] mesh is the whole mesh
2216  */
2217 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2218 {
2219   if(_field_pm_pt.empty())
2220     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2221   //
2222   std::vector< std::pair<int,int> > dads;
2223   std::vector<const DataArrayInt *> pfls;
2224   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2225   std::vector<int> locs,code;
2226   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2227   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2228     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2229   // Sort by types
2230   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2231   if(code.empty())
2232     {
2233       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2234       throw INTERP_KERNEL::Exception(oss.str());
2235     }
2236   //
2237   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2238   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2239   if(type!=ON_NODES)
2240     {
2241       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2242       if(!arr)
2243         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2244       else
2245         {
2246           MCAuto<DataArrayInt> arr2(arr);
2247           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2248         }
2249     }
2250   else
2251     {
2252       if(code.size()!=3)
2253         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2254       int nb=code[1];
2255       if(code[2]==-1)
2256         {
2257           if(nb!=mesh->getNumberOfNodes())
2258             {
2259               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2260               oss << " nodes in mesh !";
2261               throw INTERP_KERNEL::Exception(oss.str());
2262             }
2263           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2264         }
2265       else
2266         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2267     }
2268 }
2269
2270 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2271 {
2272   if(_field_pm_pt.empty())
2273     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2274   //
2275   std::vector<std::pair<int,int> > dads;
2276   std::vector<const DataArrayInt *> pfls;
2277   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2278   std::vector<int> locs,code;
2279   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2280   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2281     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2282   // Sort by types
2283   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2284   if(code.empty())
2285     {
2286       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2287       throw INTERP_KERNEL::Exception(oss.str());
2288     }
2289   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2290   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2291   if(type!=ON_NODES)
2292     {
2293       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2294       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2295     }
2296   else
2297     {
2298       if(code.size()!=3)
2299         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2300       int nb=code[1];
2301       if(code[2]==-1)
2302         {
2303           if(nb!=mesh->getNumberOfNodes())
2304             {
2305               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2306               oss << " nodes in mesh !";
2307               throw INTERP_KERNEL::Exception(oss.str());
2308             }
2309         }
2310       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2311     }
2312   //
2313   return 0;
2314 }
2315
2316 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2317 {
2318   int globalSz=0;
2319   int nbOfEntries=0;
2320   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2321     {
2322       (*it)->getSizes(globalSz,nbOfEntries);
2323     }
2324   entries.resize(nbOfEntries);
2325   nbOfEntries=0;
2326   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2327     {
2328       (*it)->fillValues(nbOfEntries,entries);
2329     }
2330 }
2331
2332 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2333 {
2334   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2335     {
2336       if((*it)->getGeoType()==typ)
2337         return (*it)->getLeafGivenLocId(locId);
2338     }
2339   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2340   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2341   oss << "Possiblities are : ";
2342   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2343     {
2344       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2345       oss << "\"" << cm2.getRepr() << "\", ";
2346     }
2347   throw INTERP_KERNEL::Exception(oss.str());
2348 }
2349
2350 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2351 {
2352   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2353     {
2354       if((*it)->getGeoType()==typ)
2355         return (*it)->getLeafGivenLocId(locId);
2356     }
2357   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2358   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2359   oss << "Possiblities are : ";
2360   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2361     {
2362       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2363       oss << "\"" << cm2.getRepr() << "\", ";
2364     }
2365   throw INTERP_KERNEL::Exception(oss.str());
2366 }
2367
2368 /*!
2369  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2370  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2371  * \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.
2372  * \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.
2373  */
2374 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)
2375 {
2376   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2377   if(pms.empty())
2378     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2379   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2380     {
2381       if(!(*it).second)
2382         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2383       if(!(*it).second->getProfile().empty())
2384         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2385       if(!(*it).second->getLocalization().empty())
2386         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2387     }
2388   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2389   std::size_t i(0);
2390   std::vector< std::pair<int,int> > filteredDTS;
2391   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2392     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2393       if((*it2).first==gt)
2394         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2395   if(pms.size()!=filteredDTS.size())
2396     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2397   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2398   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2399   int zeStart(start),nval(0);
2400   for(;it1!=pms.end();it1++,it2++)
2401     {
2402       if((*it1).first!=(*it2).first)
2403         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2404       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2405       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2406       start+=e1-s1;
2407       nval+=((*it1).second)->getNumberOfVals();
2408     }
2409   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2410   return ret;
2411 }
2412
2413 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerTypeCommon::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)
2414 {
2415   MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
2416   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
2417   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2418     {
2419       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
2420         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
2421     }
2422   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
2423     {
2424       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2425       ret->_field_pm_pt_pd.push_back(agg);
2426     }
2427   return ret;
2428 }
2429
2430 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)
2431 {
2432   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2433   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2434   std::size_t i(0);
2435   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2436     {
2437       const std::vector< MCAuto< MEDFileFieldPerMeshPerType > >& v((*it)->_field_pm_pt);
2438       for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2439         {
2440           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2441           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
2442         }
2443     }
2444   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2445     {
2446       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerTypeCommon::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2447       ret->_field_pm_pt.push_back(agg);
2448     }
2449   return ret;
2450 }
2451
2452 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2453 {
2454   int i=0;
2455   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2456   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2457   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2458     {
2459       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2460       if(type==curType)
2461         return i;
2462       else
2463         {
2464           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2465           if(pos>pos2)
2466             it2=it+1;
2467         }
2468     }
2469   int ret=std::distance(_field_pm_pt.begin(),it2);
2470   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2471   return ret;
2472 }
2473
2474 /*!
2475  * 'dads' and 'locs' input parameters have the same number of elements
2476  * \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
2477  */
2478 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2479                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2480                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2481 {
2482   isPfl=false;
2483   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2484   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2485   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2486   const std::vector<std::string>& infos=getInfo();
2487   da->setInfoOnComponents(infos);
2488   da->setName("");
2489   if(type==ON_GAUSS_PT)
2490     {
2491       int offset=0;
2492       int nbOfArrs=dads.size();
2493       for(int i=0;i<nbOfArrs;i++)
2494         {
2495           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2496           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2497           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2498           MCAuto<DataArrayInt> di=DataArrayInt::New();
2499           di->alloc(nbOfElems,1);
2500           di->iota(offset);
2501           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2502           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2503           offset+=nbOfElems;
2504         }
2505     }
2506   arrOut=da;
2507   return ret.retn();
2508 }
2509
2510 /*!
2511  * 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.
2512  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2513  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2514  * The order of cells in the returned field is those imposed by the profile.
2515  * \param [in] mesh is the global mesh.
2516  */
2517 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2518                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2519                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2520                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2521 {
2522   if(da->isIota(mesh->getNumberOfCells()))
2523     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2524   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2525   m2->setName(mesh->getName().c_str());
2526   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2527   isPfl=true;
2528   return ret.retn();
2529 }
2530
2531 /*!
2532  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2533  */
2534 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2535                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2536                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2537 {
2538   if(da->isIota(mesh->getNumberOfNodes()))
2539     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2540   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2541   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2542   if(meshu)
2543     {
2544       if(meshu->getNodalConnectivity()==0)
2545         {
2546           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2547           int nb=da->getNbOfElems();
2548           const int *ptr=da->getConstPointer();
2549           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2550           meshuc->allocateCells(nb);
2551           for(int i=0;i<nb;i++)
2552             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2553           meshuc->finishInsertingCells();
2554           ret->setMesh(meshuc);
2555           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2556           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2557           disc->checkCoherencyBetween(meshuc,arrOut);
2558           return ret.retn();
2559         }
2560     }
2561   //
2562   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2563   isPfl=true;
2564   DataArrayInt *arr2=0;
2565   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2566   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2567   MCAuto<DataArrayInt> arr3(arr2);
2568   int nnodes=mesh2->getNumberOfNodes();
2569   if(nnodes==(int)da->getNbOfElems())
2570     {
2571       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2572       arrOut->renumberInPlace(da3->getConstPointer());
2573       mesh2->setName(mesh->getName().c_str());
2574       ret->setMesh(mesh2);
2575       return ret.retn();
2576     }
2577   else
2578     {
2579       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 !!!";
2580       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2581       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2582       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2583       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2584       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2585       throw INTERP_KERNEL::Exception(oss.str());
2586     }
2587   return 0;
2588 }
2589
2590 /*!
2591  * This method is the most light method of field retrieving.
2592  */
2593 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2594 {
2595   if(!pflIn)
2596     {
2597       pflOut=DataArrayInt::New();
2598       pflOut->alloc(nbOfElems,1);
2599       pflOut->iota(0);
2600     }
2601   else
2602     {
2603       pflOut=const_cast<DataArrayInt*>(pflIn);
2604       pflOut->incrRef();
2605     }
2606   MCAuto<DataArrayInt> safePfl(pflOut);
2607   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2608   const std::vector<std::string>& infos=getInfo();
2609   int nbOfComp=infos.size();
2610   for(int i=0;i<nbOfComp;i++)
2611     da->setInfoOnComponent(i,infos[i].c_str());
2612   safePfl->incrRef();
2613   return da.retn();
2614 }
2615
2616
2617 /// @cond INTERNAL
2618
2619 class MFFPMIter
2620 {
2621 public:
2622   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2623   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2624   virtual ~MFFPMIter() { }
2625   virtual void begin() = 0;
2626   virtual bool finished() const = 0;
2627   virtual void next() = 0;
2628   virtual int current() const = 0;
2629 };
2630
2631 class MFFPMIterSimple : public MFFPMIter
2632 {
2633 public:
2634   MFFPMIterSimple():_pos(0) { }
2635   void begin() { _pos=0; }
2636   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2637   void next() { _pos++; }
2638   int current() const { return _pos; }
2639 private:
2640   int _pos;
2641 };
2642
2643 class MFFPMIter2 : public MFFPMIter
2644 {
2645 public:
2646   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2647   void begin() { _it=_ids.begin(); }
2648   bool finished() const { return _it==_ids.end(); }
2649   void next() { _it++; }
2650   int current() const { return *_it; }
2651 private:
2652   std::vector<int> _ids;
2653   std::vector<int>::const_iterator _it;
2654 };
2655
2656 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2657 {
2658   if(!entities)
2659     return new MFFPMIterSimple;
2660   else
2661     {
2662       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2663       if(entities2)
2664         {
2665           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2666           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2667           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2668             {
2669               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2670                 tmp.push_back((*it).second);
2671             }
2672           return new MFFPMIter2(tmp);
2673         }
2674       else
2675         throw INTERP_KERNEL::Exception("MFFPMIter::NewCell : not recognized type !");
2676     }
2677 }
2678
2679 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2680 {
2681   if(!entities)
2682     return true;
2683   else
2684     {
2685       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2686       if(entities2)
2687         {
2688           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2689           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2690             if((*it).first==ON_NODES)
2691               return true;
2692           return false;
2693         }
2694       else
2695         throw INTERP_KERNEL::Exception("MFFPMIter::IsPresenceOfNode : not recognized type !");
2696     }
2697 }
2698
2699 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2700 {
2701   std::size_t sz(cts.size());
2702   _ids.resize(sz);
2703   for(std::size_t i=0;i<sz;i++)
2704     {
2705       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2706       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2707         _ids[i]=(int)std::distance(typmai2,loc);
2708       else
2709         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2710     }
2711 }
2712
2713 /// @endcond
2714
2715 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),
2716     _father(fath)
2717 {
2718   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2719   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2720   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2721   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2722   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2723   for(iter0->begin();!iter0->finished();iter0->next())
2724     {
2725       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2726       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2727       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2728       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2729       if(nbProfile>0 || nbProfile2>0)
2730         {
2731           const PartDefinition *pd(0);
2732           if(mmu)
2733             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2734           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2735           if(nbProfile>0)
2736             _mesh_name=name0;
2737           else
2738             _mesh_name=name1;
2739         }
2740     }
2741   if(MFFPMIter::IsPresenceOfNode(entities))
2742     {
2743       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2744       if(nbProfile>0)
2745         {
2746           const PartDefinition *pd(0);
2747           if(mmu)
2748             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2749           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2750           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2751         }
2752     }
2753 }
2754
2755 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2756 {
2757   copyTinyInfoFrom(mesh);
2758 }
2759
2760 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2761 {
2762   if(id>=(int)_pfls.size())
2763     _pfls.resize(id+1);
2764   _pfls[id]=DataArrayInt::New();
2765   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2766   _pfls[id]->setName(pflName);
2767   _pfls[id]->alloc(lgth,1);
2768   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2769   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2770 }
2771
2772 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2773 {
2774   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2775   int sz;
2776   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2777   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2778   if(i>=(int)_pfls.size())
2779     _pfls.resize(i+1);
2780   _pfls[i]=DataArrayInt::New();
2781   _pfls[i]->alloc(sz,1);
2782   _pfls[i]->setName(pflCpp.c_str());
2783   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2784   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2785 }
2786
2787 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2788 {
2789   int nbOfPfls=_pfls.size();
2790   for(int i=0;i<nbOfPfls;i++)
2791     {
2792       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2793       cpy->applyLin(1,1,0);
2794       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2795       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2796       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2797     }
2798   //
2799   int nbOfLocs=_locs.size();
2800   for(int i=0;i<nbOfLocs;i++)
2801     _locs[i]->writeLL(fid);
2802 }
2803
2804 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2805 {
2806   std::vector<std::string> pfls=getPfls();
2807   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2808     {
2809       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2810       if(it2==pfls.end())
2811         {
2812           _pfls.push_back(*it);
2813         }
2814       else
2815         {
2816           int id=std::distance(pfls.begin(),it2);
2817           if(!(*it)->isEqual(*_pfls[id]))
2818             {
2819               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2820               throw INTERP_KERNEL::Exception(oss.str());
2821             }
2822         }
2823     }
2824   std::vector<std::string> locs=getLocs();
2825   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2826     {
2827       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2828       if(it2==locs.end())
2829         {
2830           _locs.push_back(*it);
2831         }
2832       else
2833         {
2834           int id=std::distance(locs.begin(),it2);
2835           if(!(*it)->isEqual(*_locs[id],eps))
2836             {
2837               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2838               throw INTERP_KERNEL::Exception(oss.str());
2839             }
2840         }
2841     }
2842 }
2843
2844 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2845 {
2846   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2847     getProfile((*it).c_str());
2848 }
2849
2850 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2851 {
2852   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2853     getLocalization((*it).c_str());
2854 }
2855
2856 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2857 {
2858   std::vector<std::string> profiles=real.getPflsReallyUsed();
2859   int sz=profiles.size();
2860   _pfls.resize(sz);
2861   for(int i=0;i<sz;i++)
2862     loadProfileInFile(fid,i,profiles[i].c_str());
2863   //
2864   std::vector<std::string> locs=real.getLocsReallyUsed();
2865   sz=locs.size();
2866   _locs.resize(sz);
2867   for(int i=0;i<sz;i++)
2868     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2869 }
2870
2871 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2872 {
2873   int nProfil=MEDnProfile(fid);
2874   for(int i=0;i<nProfil;i++)
2875     loadProfileInFile(fid,i);
2876   int sz=MEDnLocalization(fid);
2877   _locs.resize(sz);
2878   for(int i=0;i<sz;i++)
2879     {
2880       _locs[i]=MEDFileFieldLoc::New(fid,i);
2881     }
2882 }
2883
2884 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2885 {
2886   return new MEDFileFieldGlobs(fid);
2887 }
2888
2889 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2890 {
2891   return new MEDFileFieldGlobs;
2892 }
2893
2894 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2895 {
2896   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2897 }
2898
2899 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2900 {
2901   std::vector<const BigMemoryObject *> ret;
2902   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2903     ret.push_back((const DataArrayInt *)*it);
2904   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2905     ret.push_back((const MEDFileFieldLoc *)*it);
2906   return ret;
2907 }
2908
2909 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2910 {
2911   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2912   std::size_t i=0;
2913   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2914     {
2915       if((const DataArrayInt *)*it)
2916         ret->_pfls[i]=(*it)->deepCopy();
2917     }
2918   i=0;
2919   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2920     {
2921       if((const MEDFileFieldLoc*)*it)
2922         ret->_locs[i]=(*it)->deepCopy();
2923     }
2924   return ret.retn();
2925 }
2926
2927 /*!
2928  * \throw if a profile in \a pfls in not in \a this.
2929  * \throw if a localization in \a locs in not in \a this.
2930  * \sa MEDFileFieldGlobs::deepCpyPart
2931  */
2932 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2933 {
2934   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2935   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2936     {
2937       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2938       if(!pfl)
2939         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2940       pfl->incrRef();
2941       MCAuto<DataArrayInt> pfl2(pfl);
2942       ret->_pfls.push_back(pfl2);
2943     }
2944   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2945     {
2946       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2947       if(!loc)
2948         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2949       loc->incrRef();
2950       MCAuto<MEDFileFieldLoc> loc2(loc);
2951       ret->_locs.push_back(loc2);
2952     }
2953   ret->setFileName(getFileName());
2954   return ret.retn();
2955 }
2956
2957 /*!
2958  * \throw if a profile in \a pfls in not in \a this.
2959  * \throw if a localization in \a locs in not in \a this.
2960  * \sa MEDFileFieldGlobs::shallowCpyPart
2961  */
2962 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2963 {
2964   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2965   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2966     {
2967       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2968       if(!pfl)
2969         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2970       ret->_pfls.push_back(pfl->deepCopy());
2971     }
2972   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2973     {
2974       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2975       if(!loc)
2976         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2977       ret->_locs.push_back(loc->deepCopy());
2978     }
2979   ret->setFileName(getFileName());
2980   return ret.retn();
2981 }
2982
2983 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
2984 {
2985 }
2986
2987 MEDFileFieldGlobs::MEDFileFieldGlobs()
2988 {
2989 }
2990
2991 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2992 {
2993 }
2994
2995 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2996 {
2997   oss << "Profiles :\n";
2998   std::size_t n=_pfls.size();
2999   for(std::size_t i=0;i<n;i++)
3000     {
3001       oss << "  - #" << i << " ";
3002       const DataArrayInt *pfl=_pfls[i];
3003       if(pfl)
3004         oss << "\"" << pfl->getName() << "\"\n";
3005       else
3006         oss << "EMPTY !\n";
3007     }
3008   n=_locs.size();
3009   oss << "Localizations :\n";
3010   for(std::size_t i=0;i<n;i++)
3011     {
3012       oss << "  - #" << i << " ";
3013       const MEDFileFieldLoc *loc=_locs[i];
3014       if(loc)
3015         loc->simpleRepr(oss);
3016       else
3017         oss<< "EMPTY !\n";
3018     }
3019 }
3020
3021 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3022 {
3023   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3024     {
3025       DataArrayInt *elt(*it);
3026       if(elt)
3027         {
3028           std::string name(elt->getName());
3029           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3030             {
3031               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3032                 {
3033                   elt->setName((*it2).second.c_str());
3034                   return;
3035                 }
3036             }
3037         }
3038     }
3039 }
3040
3041 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3042 {
3043   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3044     {
3045       MEDFileFieldLoc *elt(*it);
3046       if(elt)
3047         {
3048           std::string name(elt->getName());
3049           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3050             {
3051               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3052                 {
3053                   elt->setName((*it2).second.c_str());
3054                   return;
3055                 }
3056             }
3057         }
3058     }
3059 }
3060
3061 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3062 {
3063   if(locId<0 || locId>=(int)_locs.size())
3064     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3065   return _locs[locId]->getNbOfGaussPtPerCell();
3066 }
3067
3068 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3069 {
3070   return getLocalizationFromId(getLocalizationId(locName));
3071 }
3072
3073 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3074 {
3075   if(locId<0 || locId>=(int)_locs.size())
3076     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3077   return *_locs[locId];
3078 }
3079
3080 /// @cond INTERNAL
3081 namespace MEDCouplingImpl
3082 {
3083   class LocFinder
3084   {
3085   public:
3086     LocFinder(const std::string& loc):_loc(loc) { }
3087     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3088   private:
3089     const std::string &_loc;
3090   };
3091
3092   class PflFinder
3093   {
3094   public:
3095     PflFinder(const std::string& pfl):_pfl(pfl) { }
3096     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3097   private:
3098     const std::string& _pfl;
3099   };
3100 }
3101 /// @endcond
3102
3103 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3104 {
3105   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3106   if(it==_locs.end())
3107     {
3108       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3109       for(it=_locs.begin();it!=_locs.end();it++)
3110         oss << "\"" << (*it)->getName() << "\", ";
3111       throw INTERP_KERNEL::Exception(oss.str());
3112     }
3113   return std::distance(_locs.begin(),it);
3114 }
3115
3116 /*!
3117  * The returned value is never null.
3118  */
3119 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3120 {
3121   std::string pflNameCpp(pflName);
3122   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3123   if(it==_pfls.end())
3124     {
3125       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3126       for(it=_pfls.begin();it!=_pfls.end();it++)
3127         oss << "\"" << (*it)->getName() << "\", ";
3128       throw INTERP_KERNEL::Exception(oss.str());
3129     }
3130   return *it;
3131 }
3132
3133 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3134 {
3135   if(pflId<0 || pflId>=(int)_pfls.size())
3136     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3137   return _pfls[pflId];
3138 }
3139
3140 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3141 {
3142   if(locId<0 || locId>=(int)_locs.size())
3143     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3144   return *_locs[locId];
3145 }
3146
3147 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3148 {
3149   return getLocalizationFromId(getLocalizationId(locName));
3150 }
3151
3152 /*!
3153  * The returned value is never null.
3154  */
3155 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3156 {
3157   std::string pflNameCpp(pflName);
3158   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3159   if(it==_pfls.end())
3160     {
3161       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3162       for(it=_pfls.begin();it!=_pfls.end();it++)
3163         oss << "\"" << (*it)->getName() << "\", ";
3164       throw INTERP_KERNEL::Exception(oss.str());
3165     }
3166   return *it;
3167 }
3168
3169 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3170 {
3171   if(pflId<0 || pflId>=(int)_pfls.size())
3172     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3173   return _pfls[pflId];
3174 }
3175
3176 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3177 {
3178   std::vector< MCAuto<DataArrayInt> > newPfls;
3179   int i=0;
3180   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3181     {
3182       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3183         newPfls.push_back(*it);
3184     }
3185   _pfls=newPfls;
3186 }
3187
3188 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3189 {
3190   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3191   int i=0;
3192   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3193     {
3194       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3195         newLocs.push_back(*it);
3196     }
3197   _locs=newLocs;
3198 }
3199
3200 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3201 {
3202   int sz=_pfls.size();
3203   std::vector<std::string> ret(sz);
3204   for(int i=0;i<sz;i++)
3205     ret[i]=_pfls[i]->getName();
3206   return ret;
3207 }
3208
3209 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3210 {
3211   int sz=_locs.size();
3212   std::vector<std::string> ret(sz);
3213   for(int i=0;i<sz;i++)
3214     ret[i]=_locs[i]->getName();
3215   return ret;
3216 }
3217
3218 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3219 {
3220   std::vector<std::string> v=getPfls();
3221   std::string s(pflName);
3222   return std::find(v.begin(),v.end(),s)!=v.end();
3223 }
3224
3225 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3226 {
3227   std::vector<std::string> v=getLocs();
3228   std::string s(locName);
3229   return std::find(v.begin(),v.end(),s)!=v.end();
3230 }
3231
3232 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3233 {
3234   std::map<int,std::vector<int> > m;
3235   int i=0;
3236   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3237     {
3238       const DataArrayInt *tmp=(*it);
3239       if(tmp)
3240         {
3241           m[tmp->getHashCode()].push_back(i);
3242         }
3243     }
3244   std::vector< std::vector<int> > ret;
3245   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3246     {
3247       if((*it2).second.size()>1)
3248         {
3249           std::vector<int> ret0;
3250           bool equalityOrNot=false;
3251           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3252             {
3253               std::vector<int>::const_iterator it4=it3; it4++;
3254               for(;it4!=(*it2).second.end();it4++)
3255                 {
3256                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3257                     {
3258                       if(!equalityOrNot)
3259                         ret0.push_back(*it3);
3260                       ret0.push_back(*it4);
3261                       equalityOrNot=true;
3262                     }
3263                 }
3264             }
3265           if(!ret0.empty())
3266             ret.push_back(ret0);
3267         }
3268     }
3269   return ret;
3270 }
3271
3272 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3273 {
3274   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3275 }
3276
3277 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3278 {
3279   std::string name(pfl->getName());
3280   if(name.empty())
3281     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3282   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3283     if(name==(*it)->getName())
3284       {
3285         if(!pfl->isEqual(*(*it)))
3286           {
3287             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3288             throw INTERP_KERNEL::Exception(oss.str());
3289           }
3290       }
3291   pfl->incrRef();
3292   _pfls.push_back(pfl);
3293 }
3294
3295 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)
3296 {
3297   std::string name(locName);
3298   if(name.empty())
3299     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3300   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3301   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3302     if((*it)->isName(locName))
3303       {
3304         if(!(*it)->isEqual(*obj,1e-12))
3305           {
3306             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3307             throw INTERP_KERNEL::Exception(oss.str());
3308           }
3309       }
3310   _locs.push_back(obj);
3311 }
3312
3313 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3314 {
3315   std::vector<std::string> names=getPfls();
3316   return CreateNewNameNotIn("NewPfl_",names);
3317 }
3318
3319 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3320 {
3321   std::vector<std::string> names=getLocs();
3322   return CreateNewNameNotIn("NewLoc_",names);
3323 }
3324
3325 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3326 {
3327   for(std::size_t sz=0;sz<100000;sz++)
3328     {
3329       std::ostringstream tryName;
3330       tryName << prefix << sz;
3331       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3332         return tryName.str();
3333     }
3334   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3335 }
3336
3337 /*!
3338  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3339  *  \param [in] fname - the file name.
3340  */
3341 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3342 {
3343 }
3344
3345 /*!
3346  * Creates an empty MEDFileFieldGlobsReal.
3347  */
3348 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3349 {
3350 }
3351
3352 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3353 {
3354   return 0;
3355 }
3356
3357 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3358 {
3359   std::vector<const BigMemoryObject *> ret;
3360   ret.push_back((const MEDFileFieldGlobs *)_globals);
3361   return ret;
3362 }
3363
3364 /*!
3365  * Returns a string describing profiles and Gauss points held in \a this.
3366  *  \return std::string - the description string.
3367  */
3368 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3369 {
3370   const MEDFileFieldGlobs *glob=_globals;
3371   std::ostringstream oss2; oss2 << glob;
3372   std::string stars(oss2.str().length(),'*');
3373   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3374   if(glob)
3375     glob->simpleRepr(oss);
3376   else
3377     oss << "NO GLOBAL INFORMATION !\n";
3378 }
3379
3380 void MEDFileFieldGlobsReal::resetContent()
3381 {
3382   _globals=MEDFileFieldGlobs::New();
3383 }
3384
3385 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3386 {
3387 }
3388
3389 /*!
3390  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3391  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3392  */
3393 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3394 {
3395   _globals=other._globals;
3396 }
3397
3398 /*!
3399  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3400  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3401  */
3402 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3403 {
3404   const MEDFileFieldGlobs *otherg(other._globals);
3405   if(!otherg)
3406     return ;
3407   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3408 }
3409
3410 /*!
3411  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3412  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3413  */
3414 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3415 {
3416   const MEDFileFieldGlobs *otherg(other._globals);
3417   if(!otherg)
3418     return ;
3419   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3420 }
3421
3422 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3423 {
3424   _globals=other._globals;
3425   if((const MEDFileFieldGlobs *)_globals)
3426     _globals=other._globals->deepCopy();
3427 }
3428
3429 /*!
3430  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3431  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3432  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3433  *         \a this and \a other MEDFileFieldGlobsReal.
3434  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3435  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3436  */
3437 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3438 {
3439   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3440   if(thisGlobals==otherGlobals)
3441     return ;
3442   if(!thisGlobals)
3443     {
3444       _globals=other._globals;
3445       return ;
3446     }
3447   _globals->appendGlobs(*other._globals,eps);
3448 }
3449
3450 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3451 {
3452   checkGlobsPflsPartCoherency();
3453   checkGlobsLocsPartCoherency();
3454 }
3455
3456 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3457 {
3458   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3459 }
3460
3461 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3462 {
3463   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3464 }
3465
3466 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3467 {
3468   contentNotNull()->loadProfileInFile(fid,id,pflName);
3469 }
3470
3471 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3472 {
3473   contentNotNull()->loadProfileInFile(fid,id);
3474 }
3475
3476 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3477 {
3478   contentNotNull()->loadGlobals(fid,*this);
3479 }
3480
3481 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3482 {
3483   contentNotNull()->loadAllGlobals(fid);
3484 }
3485
3486 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3487 {
3488   contentNotNull()->writeGlobals(fid,opt);
3489 }
3490
3491 /*!
3492  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3493  * or getPflsReallyUsedMulti().
3494  *  \return std::vector<std::string> - a sequence of names of all profiles.
3495  */
3496 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3497 {
3498   return contentNotNull()->getPfls();
3499 }
3500
3501 /*!
3502  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3503  * or getLocsReallyUsedMulti().
3504  *  \return std::vector<std::string> - a sequence of names of all localizations.
3505  */
3506 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3507 {
3508   return contentNotNull()->getLocs();
3509 }
3510
3511 /*!
3512  * Checks if the profile with a given name exists.
3513  *  \param [in] pflName - the profile name of interest.
3514  *  \return bool - \c true if the profile named \a pflName exists.
3515  */
3516 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3517 {
3518   return contentNotNull()->existsPfl(pflName);
3519 }
3520
3521 /*!
3522  * Checks if the localization with a given name exists.
3523  *  \param [in] locName - the localization name of interest.
3524  *  \return bool - \c true if the localization named \a locName exists.
3525  */
3526 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3527 {
3528   return contentNotNull()->existsLoc(locName);
3529 }
3530
3531 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3532 {
3533   return contentNotNull()->createNewNameOfPfl();
3534 }
3535
3536 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3537 {
3538   return contentNotNull()->createNewNameOfLoc();
3539 }
3540
3541 /*!
3542  * Sets the name of a MED file.
3543  *  \param [inout] fileName - the file name.
3544  */
3545 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3546 {
3547   contentNotNull()->setFileName(fileName);
3548 }
3549
3550 /*!
3551  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3552  * in the same order.
3553  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3554  *          Each item of this sequence is a vector containing ids of equal profiles.
3555  */
3556 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3557 {
3558   return contentNotNull()->whichAreEqualProfiles();
3559 }
3560
3561 /*!
3562  * Finds equal localizations.
3563  *  \param [in] eps - a precision used to compare real values of the localizations.
3564  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3565  *          Each item of this sequence is a vector containing ids of equal localizations.
3566  */
3567 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3568 {
3569   return contentNotNull()->whichAreEqualLocs(eps);
3570 }
3571
3572 /*!
3573  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3574  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3575  *        this sequence is a pair whose 
3576  *        - the first item is a vector of profile names to replace by the second item,
3577  *        - the second item is a profile name to replace every profile name of the first item.
3578  */
3579 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3580 {
3581   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3582 }
3583
3584 /*!
3585  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3586  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3587  *        this sequence is a pair whose 
3588  *        - the first item is a vector of localization names to replace by the second item,
3589  *        - the second item is a localization name to replace every localization name of the first item.
3590  */
3591 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3592 {
3593   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3594 }
3595
3596 /*!
3597  * Replaces references to some profiles (a reference is a profile name) by references
3598  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3599  * them-selves accordingly. <br>
3600  * This method is a generalization of changePflName().
3601  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3602  *        this sequence is a pair whose 
3603  *        - the first item is a vector of profile names to replace by the second item,
3604  *        - the second item is a profile name to replace every profile of the first item.
3605  * \sa changePflsRefsNamesGen()
3606  * \sa changePflName()
3607  */
3608 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3609 {
3610   changePflsRefsNamesGen(mapOfModif);
3611   changePflsNamesInStruct(mapOfModif);
3612 }
3613
3614 /*!
3615  * Replaces references to some localizations (a reference is a localization name) by references
3616  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3617  * them-selves accordingly. <br>
3618  * This method is a generalization of changeLocName().
3619  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3620  *        this sequence is a pair whose 
3621  *        - the first item is a vector of localization names to replace by the second item,
3622  *        - the second item is a localization name to replace every localization of the first item.
3623  * \sa changeLocsRefsNamesGen()
3624  * \sa changeLocName()
3625  */
3626 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3627 {
3628   changeLocsRefsNamesGen(mapOfModif);
3629   changeLocsNamesInStruct(mapOfModif);
3630 }
3631
3632 /*!
3633  * Renames the profile having a given name and updates references to this profile.
3634  *  \param [in] oldName - the name of the profile to rename.
3635  *  \param [in] newName - a new name of the profile.
3636  * \sa changePflsNames().
3637  */
3638 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3639 {
3640   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3641   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3642   mapOfModif[0]=p;
3643   changePflsNames(mapOfModif);
3644 }
3645
3646 /*!
3647  * Renames the localization having a given name and updates references to this localization.
3648  *  \param [in] oldName - the name of the localization to rename.
3649  *  \param [in] newName - a new name of the localization.
3650  * \sa changeLocsNames().
3651  */
3652 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3653 {
3654   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3655   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3656   mapOfModif[0]=p;
3657   changeLocsNames(mapOfModif);
3658 }
3659
3660 /*!
3661  * Removes duplicated profiles. Returns a map used to update references to removed 
3662  * profiles via changePflsRefsNamesGen().
3663  * Equal profiles are found using whichAreEqualProfiles().
3664  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3665  *          a sequence describing the performed replacements of profiles. Each element of
3666  *          this sequence is a pair whose
3667  *          - the first item is a vector of profile names replaced by the second item,
3668  *          - the second item is a profile name replacing every profile of the first item.
3669  */
3670 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3671 {
3672   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3673   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3674   int i=0;
3675   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3676     {
3677       std::vector< std::string > tmp((*it).size());
3678       int j=0;
3679       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3680         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3681       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3682       ret[i]=p;
3683       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3684       killProfileIds(tmp2);
3685     }
3686   changePflsRefsNamesGen(ret);
3687   return ret;
3688 }
3689
3690 /*!
3691  * Removes duplicated localizations. Returns a map used to update references to removed 
3692  * localizations via changeLocsRefsNamesGen().
3693  * Equal localizations are found using whichAreEqualLocs().
3694  *  \param [in] eps - a precision used to compare real values of the localizations.
3695  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3696  *          a sequence describing the performed replacements of localizations. Each element of
3697  *          this sequence is a pair whose
3698  *          - the first item is a vector of localization names replaced by the second item,
3699  *          - the second item is a localization name replacing every localization of the first item.
3700  */
3701 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3702 {
3703   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3704   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3705   int i=0;
3706   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3707     {
3708       std::vector< std::string > tmp((*it).size());
3709       int j=0;
3710       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3711         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3712       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3713       ret[i]=p;
3714       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3715       killLocalizationIds(tmp2);
3716     }
3717   changeLocsRefsNamesGen(ret);
3718   return ret;
3719 }
3720
3721 /*!
3722  * Returns number of Gauss points per cell in a given localization.
3723  *  \param [in] locId - an id of the localization of interest.
3724  *  \return int - the number of the Gauss points per cell.
3725  */
3726 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3727 {
3728   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3729 }
3730
3731 /*!
3732  * Returns an id of a localization by its name.
3733  *  \param [in] loc - the localization name of interest.
3734  *  \return int - the id of the localization.
3735  *  \throw If there is no a localization named \a loc.
3736  */
3737 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3738 {
3739   return contentNotNull()->getLocalizationId(loc);
3740 }
3741
3742 /*!
3743  * Returns the name of the MED file.
3744  *  \return const std::string&  - the MED file name.
3745  */
3746 std::string MEDFileFieldGlobsReal::getFileName() const
3747 {
3748   return contentNotNull()->getFileName();
3749 }
3750
3751 /*!
3752  * Returns a localization object by its name.
3753  *  \param [in] locName - the name of the localization of interest.
3754  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3755  *  \throw If there is no a localization named \a locName.
3756  */
3757 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3758 {
3759   return contentNotNull()->getLocalization(locName);
3760 }
3761
3762 /*!
3763  * Returns a localization object by its id.
3764  *  \param [in] locId - the id of the localization of interest.
3765  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3766  *  \throw If there is no a localization with id \a locId.
3767  */
3768 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3769 {
3770   return contentNotNull()->getLocalizationFromId(locId);
3771 }
3772
3773 /*!
3774  * Returns a profile array by its name.
3775  *  \param [in] pflName - the name of the profile of interest.
3776  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3777  *  \throw If there is no a profile named \a pflName.
3778  */
3779 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3780 {
3781   return contentNotNull()->getProfile(pflName);
3782 }
3783
3784 /*!
3785  * Returns a profile array by its id.
3786  *  \param [in] pflId - the id of the profile of interest.
3787  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3788  *  \throw If there is no a profile with id \a pflId.
3789  */
3790 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3791 {
3792   return contentNotNull()->getProfileFromId(pflId);
3793 }
3794
3795 /*!
3796  * Returns a localization object, apt for modification, by its id.
3797  *  \param [in] locId - the id of the localization of interest.
3798  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3799  *          having the id \a locId.
3800  *  \throw If there is no a localization with id \a locId.
3801  */
3802 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3803 {
3804   return contentNotNull()->getLocalizationFromId(locId);
3805 }
3806
3807 /*!
3808  * Returns a localization object, apt for modification, by its name.
3809  *  \param [in] locName - the name of the localization of interest.
3810  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3811  *          having the name \a locName.
3812  *  \throw If there is no a localization named \a locName.
3813  */
3814 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3815 {
3816   return contentNotNull()->getLocalization(locName);
3817 }
3818
3819 /*!
3820  * Returns a profile array, apt for modification, by its name.
3821  *  \param [in] pflName - the name of the profile of interest.
3822  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3823  *  \throw If there is no a profile named \a pflName.
3824  */
3825 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3826 {
3827   return contentNotNull()->getProfile(pflName);
3828 }
3829
3830 /*!
3831  * Returns a profile array, apt for modification, by its id.
3832  *  \param [in] pflId - the id of the profile of interest.
3833  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3834  *  \throw If there is no a profile with id \a pflId.
3835  */
3836 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3837 {
3838   return contentNotNull()->getProfileFromId(pflId);
3839 }
3840
3841 /*!
3842  * Removes profiles given by their ids. No data is updated to track this removal.
3843  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3844  */
3845 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3846 {
3847   contentNotNull()->killProfileIds(pflIds);
3848 }
3849
3850 /*!
3851  * Removes localizations given by their ids. No data is updated to track this removal.
3852  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3853  */
3854 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3855 {
3856   contentNotNull()->killLocalizationIds(locIds);
3857 }
3858
3859 /*!
3860  * Stores a profile array.
3861  *  \param [in] pfl - the profile array to store.
3862  *  \throw If the name of \a pfl is empty.
3863  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3864  *         different ids.
3865  */
3866 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3867 {
3868   contentNotNull()->appendProfile(pfl);
3869 }
3870
3871 /*!
3872  * Adds a new localization of Gauss points.
3873  *  \param [in] locName - the name of the new localization.
3874  *  \param [in] geoType - a geometrical type of the reference cell.
3875  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3876  *         must be \c nbOfNodesPerCell * \c dimOfType.
3877  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3878  *         must be  _wg_.size() * \c dimOfType.
3879  *  \param [in] w - the weights of Gauss points.
3880  *  \throw If \a locName is empty.
3881  *  \throw If a localization with the name \a locName already exists but is
3882  *         different form the new one.
3883  */
3884 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)
3885 {
3886   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3887 }
3888
3889 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3890 {
3891   MEDFileFieldGlobs *g(_globals);
3892   if(!g)
3893     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3894   return g;
3895 }
3896
3897 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3898 {
3899   const MEDFileFieldGlobs *g(_globals);
3900   if(!g)
3901     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3902   return g;
3903 }
3904
3905 //= MEDFileFieldNameScope
3906
3907 MEDFileFieldNameScope::MEDFileFieldNameScope()
3908 {
3909 }
3910
3911 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3912 {
3913 }
3914
3915 /*!
3916  * Returns the name of \a this field.
3917  *  \return std::string - a string containing the field name.
3918  */
3919 std::string MEDFileFieldNameScope::getName() const
3920 {
3921   return _name;
3922 }
3923
3924 /*!
3925  * Sets name of \a this field
3926  *  \param [in] name - the new field name.
3927  */
3928 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3929 {
3930   _name=fieldName;
3931 }
3932
3933 std::string MEDFileFieldNameScope::getDtUnit() const
3934 {
3935   return _dt_unit;
3936 }
3937
3938 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3939 {
3940   _dt_unit=dtUnit;
3941 }
3942
3943 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3944 {
3945   _name=other._name;
3946   _dt_unit=other._dt_unit;
3947 }
3948
3949 //= MEDFileAnyTypeField1TSWithoutSDA
3950
3951 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3952 {
3953   _field_per_mesh.resize(other._field_per_mesh.size());
3954   std::size_t i=0;
3955   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3956     {
3957       if((const MEDFileFieldPerMesh *)*it)
3958         _field_per_mesh[i]=(*it)->deepCopy(this);
3959     }
3960 }
3961
3962 /*!
3963  * Prints a string describing \a this field into a stream. This string is outputted 
3964  * by \c print Python command.
3965  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3966  *  \param [in,out] oss - the out stream.
3967  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3968  *          info id printed, else, not.
3969  */
3970 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3971 {
3972   std::string startOfLine(bkOffset,' ');
3973   oss << startOfLine << "Field ";
3974   if(bkOffset==0)
3975     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3976   oss << "on one time Step ";
3977   if(f1tsId>=0)
3978     oss << "(" << f1tsId << ") ";
3979   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3980   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3981   const DataArray *arr=getUndergroundDataArray();
3982   if(arr)
3983     {
3984       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3985       if(f1tsId<0)
3986         {
3987           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3988           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3989             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3990         }
3991       if(arr->isAllocated())
3992         {
3993           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3994         }
3995       else
3996         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3997     }
3998   else
3999     {
4000       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4001     }
4002   oss << startOfLine << "----------------------" << std::endl;
4003   if(!_field_per_mesh.empty())
4004     {
4005       int i=0;
4006       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4007         {
4008           const MEDFileFieldPerMesh *cur=(*it2);
4009           if(cur)
4010             cur->simpleRepr(bkOffset,oss,i);
4011           else
4012             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4013         }
4014     }
4015   else
4016     {
4017       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4018     }
4019   oss << startOfLine << "----------------------" << std::endl;
4020 }
4021
4022 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4023 {
4024   const DataArray *arr(getUndergroundDataArray());
4025   if(!arr)
4026     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4027   int nbOfCompo=arr->getNumberOfComponents();
4028   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4029   for(int i=0;i<nbOfCompo;i++)
4030     {
4031       ret[i]=deepCopy();
4032       std::vector<int> v(1,i);
4033       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4034       ret[i]->setArray(arr2);
4035     }
4036   return ret;
4037 }
4038
4039 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)
4040 {
4041 }
4042
4043 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4044 {
4045 }
4046
4047 /*!
4048  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4049  * empty. Returns -1 if this in on nodes.
4050  *  \return int - the dimension of \a this.
4051  */
4052 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4053 {
4054   int ret=-2;
4055   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4056     (*it)->getDimension(ret);
4057   return ret;
4058 }
4059
4060 /*!
4061  * Returns the mesh name.
4062  *  \return std::string - a string holding the mesh name.
4063  *  \throw If \c _field_per_mesh.empty()
4064  */
4065 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4066 {
4067   if(_field_per_mesh.empty())
4068     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4069   return _field_per_mesh[0]->getMeshName();
4070 }
4071
4072 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4073 {
4074   std::string oldName(getMeshName());
4075   std::vector< std::pair<std::string,std::string> > v(1);
4076   v[0].first=oldName; v[0].second=newMeshName;
4077   changeMeshNames(v);
4078 }
4079
4080 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4081 {
4082   bool ret=false;
4083   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4084     {
4085       MEDFileFieldPerMesh *cur(*it);
4086       if(cur)
4087         ret=cur->changeMeshNames(modifTab) || ret;
4088     }
4089   return ret;
4090 }
4091
4092 /*!
4093  * Returns the number of iteration of the state of underlying mesh.
4094  *  \return int - the iteration number.
4095  *  \throw If \c _field_per_mesh.empty()
4096  */
4097 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4098 {
4099   if(_field_per_mesh.empty())
4100     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4101   return _field_per_mesh[0]->getMeshIteration();
4102 }
4103
4104 /*!
4105  * Returns the order number of iteration of the state of underlying mesh.
4106  *  \return int - the order number.
4107  *  \throw If \c _field_per_mesh.empty()
4108  */
4109 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4110 {
4111   if(_field_per_mesh.empty())
4112     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4113   return _field_per_mesh[0]->getMeshOrder();
4114 }
4115
4116 /*!
4117  * Checks if \a this field is tagged by a given iteration number and a given
4118  * iteration order number.
4119  *  \param [in] iteration - the iteration number of interest.
4120  *  \param [in] order - the iteration order number of interest.
4121  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4122  *          \a this->getOrder() == \a order.
4123  */
4124 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4125 {
4126   return iteration==_iteration && order==_order;
4127 }
4128
4129 /*!
4130  * Returns number of iteration and order number of iteration when
4131  * \a this field has been calculated.
4132  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4133  *          order number.
4134  */
4135 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4136 {
4137   std::pair<int,int> p;
4138   fillIteration(p);
4139   return p;
4140 }
4141
4142 /*!
4143  * Returns number of iteration and order number of iteration when
4144  * \a this field has been calculated.
4145  *  \param [in,out] p - a pair returning the iteration number and the iteration
4146  *          order number.
4147  */
4148 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4149 {
4150   p.first=_iteration;
4151   p.second=_order;
4152 }
4153
4154 /*!
4155  * Returns all types of spatial discretization of \a this field.
4156  *  \param [in,out] types - a sequence of types of \a this field.
4157  */
4158 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4159 {
4160   std::set<TypeOfField> types2;
4161   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4162     {
4163       (*it)->fillTypesOfFieldAvailable(types2);
4164     }
4165   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4166   std::copy(types2.begin(),types2.end(),bi);
4167 }
4168
4169 /*!
4170  * Returns all types of spatial discretization of \a this field.
4171  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4172  *          of \a this field.
4173  */
4174 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4175 {
4176   std::vector<TypeOfField> ret;
4177   fillTypesOfFieldAvailable(ret);
4178   return ret;
4179 }
4180
4181 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4182 {
4183   std::vector<std::string> ret;
4184   std::set<std::string> ret2;
4185   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4186     {
4187       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4188       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4189         if(ret2.find(*it2)==ret2.end())
4190           {
4191             ret.push_back(*it2);
4192             ret2.insert(*it2);
4193           }
4194     }
4195   return ret;
4196 }
4197
4198 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4199 {
4200   std::vector<std::string> ret;
4201   std::set<std::string> ret2;
4202   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4203     {
4204       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4205       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4206         if(ret2.find(*it2)==ret2.end())
4207           {
4208             ret.push_back(*it2);
4209             ret2.insert(*it2);
4210           }
4211     }
4212   return ret;
4213 }
4214
4215 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4216 {
4217   std::vector<std::string> ret;
4218   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4219     {
4220       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4221       ret.insert(ret.end(),tmp.begin(),tmp.end());
4222     }
4223   return ret;
4224 }
4225
4226 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4227 {
4228   std::vector<std::string> ret;
4229   std::set<std::string> ret2;
4230   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4231     {
4232       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4233       ret.insert(ret.end(),tmp.begin(),tmp.end());
4234     }
4235   return ret;
4236 }
4237
4238 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4239 {
4240   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4241     (*it)->changePflsRefsNamesGen(mapOfModif);
4242 }
4243
4244 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4245 {
4246   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4247     (*it)->changeLocsRefsNamesGen(mapOfModif);
4248 }
4249
4250 /*!
4251  * Returns all attributes of parts of \a this field lying on a given mesh.
4252  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4253  * item of every of returned sequences refers to the _i_-th part of \a this field.
4254  * Thus all sequences returned by this method are of the same length equal to number
4255  * of different types of supporting entities.<br>
4256  * A field part can include sub-parts with several different spatial discretizations,
4257  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4258  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4259  * of a nested sequence corresponds to a type of spatial discretization.<br>
4260  * This method allows for iteration over MEDFile DataStructure without any overhead.
4261  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4262  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4263  *          not checked if \a mname == \c NULL).
4264  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4265  *          a field part is returned. 
4266  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4267  *          This sequence is of the same length as \a types. 
4268  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4269  *          discretization. A profile name can be empty.
4270  *          Length of this and of nested sequences is the same as that of \a typesF.
4271  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4272  *          discretization. A localization name can be empty.
4273  *          Length of this and of nested sequences is the same as that of \a typesF.
4274  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4275  *          of ids of tuples within the data array, per each type of spatial
4276  *          discretization within one mesh entity type. 
4277  *          Length of this and of nested sequences is the same as that of \a typesF.
4278  *  \throw If no field is lying on \a mname.
4279  */
4280 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
4281 {
4282   int meshId=0;
4283   if(!mname.empty())
4284     meshId=getMeshIdFromMeshName(mname);
4285   else
4286     if(_field_per_mesh.empty())
4287       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4288   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4289 }
4290
4291 /*!
4292  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4293  * maximal absolute dimension and values returned via the out parameter \a levs are 
4294  * dimensions relative to the maximal absolute dimension. <br>
4295  * This method is designed for MEDFileField1TS instances that have a discretization
4296  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4297  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4298  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4299  * Only these 3 discretizations will be taken into account here. If \a this is
4300  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4301  * This method is useful to make the link between the dimension of the underlying mesh
4302  * and the levels of \a this, because it is possible that the highest dimension of \a this
4303  * field is not equal to the dimension of the underlying mesh.
4304  * 
4305  * Let's consider the following case:
4306  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4307  * TETRA4, HEXA8, TRI3 and SEG2.
4308  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4309  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4310  *
4311  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4312  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4313  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4314  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4315  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4316  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4317  * For example<br>
4318  * to retrieve the highest level of
4319  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4320  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4321  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4322  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4323  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4324  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4325  *          not checked if \a mname == \c NULL).
4326  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4327  *          absolute one. They are in decreasing order. This sequence is cleared before
4328  *          filling it in.
4329  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4330  *  \throw If no field is lying on \a mname.
4331  */
4332 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4333 {
4334   levs.clear();
4335   int meshId=getMeshIdFromMeshName(mname);
4336   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4337   std::vector< std::vector<TypeOfField> > typesF;
4338   std::vector< std::vector<std::string> > pfls, locs;
4339   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4340   if(types.empty())
4341     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4342   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4343   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4344     return -1;
4345   st.erase(INTERP_KERNEL::NORM_ERROR);
4346   std::set<int> ret1;
4347   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4348     {
4349       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4350       ret1.insert((int)cm.getDimension());
4351     }
4352   int ret=*std::max_element(ret1.begin(),ret1.end());
4353   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4354   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4355   return ret;
4356 }
4357
4358 /*!
4359  * \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.
4360  * \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.
4361  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4362  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4363  */
4364 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4365 {
4366   int mid=getMeshIdFromMeshName(mName);
4367   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4368 }
4369
4370 /*!
4371  * \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.
4372  * \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.
4373  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4374  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4375  */
4376 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4377 {
4378   int mid=getMeshIdFromMeshName(mName);
4379   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4380 }
4381
4382 /*!
4383  * \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.
4384  */
4385 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4386 {
4387   if(_field_per_mesh.empty())
4388     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4389   if(mName.empty())
4390     return 0;
4391   std::string mName2(mName);
4392   int ret=0;
4393   std::vector<std::string> msg;
4394   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4395     if(mName2==(*it)->getMeshName())
4396       return ret;
4397     else
4398       msg.push_back((*it)->getMeshName());
4399   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4400   oss << "Possible meshes are : ";
4401   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4402     oss << "\"" << (*it2) << "\" ";
4403   throw INTERP_KERNEL::Exception(oss.str());
4404 }
4405
4406 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4407 {
4408   if(!mesh)
4409     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4410   std::string tmp(mesh->getName());
4411   if(tmp.empty())
4412     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4413   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4414   int i=0;
4415   for(;it!=_field_per_mesh.end();it++,i++)
4416     {
4417       if((*it)->getMeshName()==tmp)
4418         return i;
4419     }
4420   int sz=_field_per_mesh.size();
4421   _field_per_mesh.resize(sz+1);
4422   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4423   return sz;
4424 }
4425
4426 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4427                                                                    MEDFileFieldGlobsReal& glob)
4428 {
4429   bool ret=false;
4430   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4431     {
4432       MEDFileFieldPerMesh *fpm(*it);
4433       if(fpm)
4434         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4435     }
4436   return ret;
4437 }
4438
4439 /*!
4440  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4441  * splitting that leads to single spatial discretization of this.
4442  *
4443  * \sa splitMultiDiscrPerGeoTypes
4444  */
4445 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4446 {
4447   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4448   std::vector< std::vector<TypeOfField> > typesF;
4449   std::vector< std::vector<std::string> > pfls,locs;
4450   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4451   std::set<TypeOfField> allEnt;
4452   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4453     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4454       allEnt.insert(*it2);
4455   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4456   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4457   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4458     {
4459       std::vector< std::pair<int,int> > its;
4460       ret[i]=shallowCpy();
4461       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4462       ret[i]->updateData(newLgth,its);
4463     }
4464   return ret;
4465 }
4466
4467 /*!
4468  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4469  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4470  *
4471  * \sa splitDiscretizations
4472  */
4473 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4474 {
4475   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4476   std::vector< std::vector<TypeOfField> > typesF;
4477   std::vector< std::vector<std::string> > pfls,locs;
4478   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4479   std::set<TypeOfField> allEnt;
4480   std::size_t nbOfMDPGT(0),ii(0);
4481   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4482     {
4483       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4484       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4485         allEnt.insert(*it2);
4486     }
4487   if(allEnt.size()!=1)
4488     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4489   if(nbOfMDPGT==0)
4490     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4491   if(nbOfMDPGT==1)
4492     {
4493       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4494       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4495       return ret0;
4496     }
4497   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4498   for(std::size_t i=0;i<nbOfMDPGT;i++)
4499     {
4500       std::vector< std::pair<int,int> > its;
4501       ret[i]=shallowCpy();
4502       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4503       ret[i]->updateData(newLgth,its);
4504     }
4505   return ret;
4506 }
4507
4508 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4509 {
4510   int globalCounter(0);
4511   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4512     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4513   return globalCounter;
4514 }
4515
4516 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4517 {
4518   int globalCounter(0);
4519   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4520     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4521   return globalCounter;
4522 }
4523
4524 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4525 {
4526   if(_nb_of_tuples_to_be_allocated>=0)
4527     {
4528       _nb_of_tuples_to_be_allocated=newLgth;
4529       const DataArray *oldArr(getUndergroundDataArray());
4530       if(oldArr)
4531         {
4532           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4533           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4534           setArray(newArr);
4535           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4536         }
4537       return ;
4538     }
4539   if(_nb_of_tuples_to_be_allocated==-1)
4540     return ;
4541   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4542     {
4543       const DataArray *oldArr(getUndergroundDataArray());
4544       if(!oldArr || !oldArr->isAllocated())
4545         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4546       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4547       newArr->alloc(newLgth,getNumberOfComponents());
4548       if(oldArr)
4549         newArr->copyStringInfoFrom(*oldArr);
4550       int pos=0;
4551       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4552         {
4553           if((*it).second<(*it).first)
4554             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4555           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4556           pos+=(*it).second-(*it).first;
4557         }
4558       setArray(newArr);
4559       return ;
4560     }
4561   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4562 }
4563
4564 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4565 {
4566   if(_field_per_mesh.empty())
4567     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4568   if(_field_per_mesh.size()>1)
4569     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4570   _field_per_mesh[0]->copyOptionsFrom(opts);
4571   _field_per_mesh[0]->writeLL(fid,nasc);
4572 }
4573
4574 /*!
4575  * 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.
4576  * If false is returned the memory allocation is not required.
4577  */
4578 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4579 {
4580   if(_nb_of_tuples_to_be_allocated>=0)
4581     {
4582       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4583       _nb_of_tuples_to_be_allocated=-2;
4584       return true;
4585     }
4586   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4587     return false;
4588   if(_nb_of_tuples_to_be_allocated==-1)
4589     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4590   if(_nb_of_tuples_to_be_allocated<-3)
4591     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4592   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4593 }
4594
4595 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4596 {
4597   med_int numdt,numit;
4598   med_float dt;
4599   med_int nmesh;
4600   med_bool localMesh;
4601   med_int meshnumdt,meshnumit;
4602   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4603   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4604   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4605   if(_iteration!=numdt || _order!=numit)
4606     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4607   _field_per_mesh.resize(nmesh);
4608   //
4609   MEDFileMesh *mm(0);
4610   if(ms)
4611     {
4612       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4613       mm=ms->getMeshWithName(meshNameCpp);
4614     }
4615   //
4616   for(int i=0;i<nmesh;i++)
4617     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4618   _nb_of_tuples_to_be_allocated=0;
4619   for(int i=0;i<nmesh;i++)
4620     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4621 }
4622
4623 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4624 {
4625   allocIfNecessaryTheArrayToReceiveDataFromFile();
4626   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4627     (*it)->loadBigArraysRecursively(fid,nasc);
4628 }
4629
4630 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4631 {
4632   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4633     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4634       (*it)->loadBigArraysRecursively(fid,nasc);
4635 }
4636
4637 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4638 {
4639   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4640   loadBigArraysRecursively(fid,nasc);
4641 }
4642
4643 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4644 {
4645   DataArray *thisArr(getUndergroundDataArray());
4646   if(thisArr && thisArr->isAllocated())
4647     {
4648       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4649       thisArr->desallocate();
4650     }
4651 }
4652
4653 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4654 {
4655   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4656 }
4657
4658 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4659 {
4660   std::vector<const BigMemoryObject *> ret;
4661   if(getUndergroundDataArray())
4662     ret.push_back(getUndergroundDataArray());
4663   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4664     ret.push_back((const MEDFileFieldPerMesh *)*it);
4665   return ret;
4666 }
4667
4668 /*!
4669  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4670  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4671  * "Sort By Type"), if not, an exception is thrown. 
4672  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4673  *  \param [in] arr - the array of values.
4674  *  \param [in,out] glob - the global data where profiles and localization present in
4675  *          \a field, if any, are added.
4676  *  \throw If the name of \a field is empty.
4677  *  \throw If the data array of \a field is not set.
4678  *  \throw If \a this->_arr is already allocated but has different number of components
4679  *         than \a field.
4680  *  \throw If the underlying mesh of \a field has no name.
4681  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4682  */
4683 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4684 {
4685   const MEDCouplingMesh *mesh=field->getMesh();
4686   //
4687   TypeOfField type=field->getTypeOfField();
4688   std::vector<DataArrayInt *> dummy;
4689   int start=copyTinyInfoFrom(field,arr);
4690   int pos=addNewEntryIfNecessary(mesh);
4691   if(type!=ON_NODES)
4692     {
4693       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4694       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4695     }
4696   else
4697     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4698 }
4699
4700 /*!
4701  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4702  * of a given mesh are used as the support of the given field (a real support is not used). 
4703  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4704  * Order of underlying mesh entities of the given field specified by \a profile parameter
4705  * is not prescribed; this method permutes field values to have them sorted by element
4706  * type as required for writing to MED file. A new profile is added only if no equal
4707  * profile is missing. 
4708  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4709  *  \param [in] arrOfVals - the values of the field \a field used.
4710  *  \param [in] mesh - the supporting mesh of \a field.
4711  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4712  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4713  *  \param [in,out] glob - the global data where profiles and localization present in
4714  *          \a field, if any, are added.
4715  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4716  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4717  *  \throw If the data array of \a field is not set.
4718  *  \throw If \a this->_arr is already allocated but has different number of components
4719  *         than \a field.
4720  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4721  *  \sa setFieldNoProfileSBT()
4722  */
4723 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4724 {
4725   if(!field)
4726     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4727   if(!arrOfVals || !arrOfVals->isAllocated())
4728     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4729   TypeOfField type=field->getTypeOfField();
4730   std::vector<DataArrayInt *> idsInPflPerType;
4731   std::vector<DataArrayInt *> idsPerType;
4732   std::vector<int> code,code2;
4733   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4734   if(type!=ON_NODES)
4735     {
4736       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4737       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4738       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4739       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4740       // start of check
4741       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4742       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4743       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4744         {
4745           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4746           throw INTERP_KERNEL::Exception(oss.str());
4747         }
4748       // end of check
4749       int start=copyTinyInfoFrom(field,arrOfVals);
4750       code2=m->getDistributionOfTypes();
4751       //
4752       int pos=addNewEntryIfNecessary(m);
4753       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4754     }
4755   else
4756     {
4757       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4758         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4759       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4760       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4761       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4762       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4763         {
4764           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4765           throw INTERP_KERNEL::Exception(oss.str());
4766         }
4767       int start=copyTinyInfoFrom(field,arrOfVals);
4768       int pos=addNewEntryIfNecessary(m);
4769       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4770     }
4771 }
4772
4773 /*!
4774  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4775  */
4776 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4777 {
4778   if(_nb_of_tuples_to_be_allocated>=0)
4779     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 !");
4780   DataArray *arr(getOrCreateAndGetArray());
4781   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4782   _nb_of_tuples_to_be_allocated=-3;
4783 }
4784
4785 /*!
4786  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4787  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4788  * larger by the size of \a field. Returns an id of the first not filled
4789  * tuple of \a this->_arr.
4790  *  \param [in] field - the field to copy the info on components and the name from.
4791  *  \return int - the id of first not initialized tuple of \a this->_arr.
4792  *  \throw If the name of \a field is empty.
4793  *  \throw If the data array of \a field is not set.
4794  *  \throw If \a this->_arr is already allocated but has different number of components
4795  *         than \a field.
4796  */
4797 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4798 {
4799   if(!field)
4800     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4801   std::string name(field->getName());
4802   setName(name.c_str());
4803   setDtUnit(field->getTimeUnit());
4804   if(name.empty())
4805     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4806   if(!arr)
4807     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4808   if(!arr->isAllocated())
4809     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4810   _dt=field->getTime(_iteration,_order);
4811   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4812   if(!getOrCreateAndGetArray()->isAllocated())
4813     {
4814       allocNotFromFile(arr->getNumberOfTuples());
4815       return 0;
4816     }
4817   else
4818     {
4819       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4820       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4821       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4822       _nb_of_tuples_to_be_allocated=-3;
4823       return oldNbOfTuples;
4824     }
4825 }
4826
4827 /*!
4828  * Returns number of components in \a this field
4829  *  \return int - the number of components.
4830  */
4831 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4832 {
4833   return getOrCreateAndGetArray()->getNumberOfComponents();
4834 }
4835
4836 /*!
4837  * Change info on components in \a this.
4838  * \throw If size of \a infos is not equal to the number of components already in \a this.
4839  */
4840 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4841 {
4842   DataArray *arr=getOrCreateAndGetArray();
4843   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4844 }
4845
4846 /*!
4847  * Returns info on components of \a this field.
4848  *  \return const std::vector<std::string>& - a sequence of strings each being an
4849  *          information on _i_-th component.
4850  */
4851 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4852 {
4853   const DataArray *arr=getOrCreateAndGetArray();
4854   return arr->getInfoOnComponents();
4855 }
4856
4857 /*!
4858  * Returns a mutable info on components of \a this field.
4859  *  \return std::vector<std::string>& - a sequence of strings each being an
4860  *          information on _i_-th component.
4861  */
4862 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4863 {
4864   DataArray *arr=getOrCreateAndGetArray();
4865   return arr->getInfoOnComponents();
4866 }
4867
4868 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4869 {
4870   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4871     {
4872       const MEDFileFieldPerMesh *fpm(*it);
4873       if(!fpm)
4874         continue;
4875       if(fpm->presenceOfMultiDiscPerGeoType())
4876         return true;
4877     }
4878   return false;
4879 }
4880
4881 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4882 {
4883   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 !";
4884   if(_field_per_mesh.empty())
4885     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4886   if(_field_per_mesh.size()>1)
4887     throw INTERP_KERNEL::Exception(MSG0);
4888   if(_field_per_mesh[0].isNull())
4889     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4890   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4891   std::set<TypeOfField> types;
4892   pm->fillTypesOfFieldAvailable(types);
4893   if(types.size()!=1)
4894     throw INTERP_KERNEL::Exception(MSG0);
4895   TypeOfField type(*types.begin());
4896   int meshDimRelToMax(0);
4897   if(type==ON_NODES)
4898     meshDimRelToMax=0;
4899   else
4900     {
4901       int myDim(std::numeric_limits<int>::max());
4902       bool isUnique(pm->isUniqueLevel(myDim));
4903       if(!isUnique)
4904         throw INTERP_KERNEL::Exception(MSG0);
4905       meshDimRelToMax=myDim-mesh->getMeshDimension();
4906       if(meshDimRelToMax>0)
4907         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4908     }
4909   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4910 }
4911
4912 /*!
4913  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4914  *  \param [in] type - a spatial discretization of the new field.
4915  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4916  *  \param [in] mName - a name of the supporting mesh.
4917  *  \param [in] renumPol - specifies how to permute values of the result field according to
4918  *          the optional numbers of cells and nodes, if any. The valid values are
4919  *          - 0 - do not permute.
4920  *          - 1 - permute cells.
4921  *          - 2 - permute nodes.
4922  *          - 3 - permute cells and nodes.
4923  *
4924  *  \param [in] glob - the global data storing profiles and localization.
4925  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4926  *          caller is to delete this field using decrRef() as it is no more needed. 
4927  *  \throw If the MED file is not readable.
4928  *  \throw If there is no mesh named \a mName in the MED file.
4929  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4930  *  \throw If no field of \a this is lying on the mesh \a mName.
4931  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4932  */
4933 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4934 {
4935   MCAuto<MEDFileMesh> mm;
4936   if(mName.empty())
4937     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4938   else
4939     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4940   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4941 }
4942
4943 /*!
4944  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4945  *  \param [in] type - a spatial discretization of the new field.
4946  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4947  *  \param [in] renumPol - specifies how to permute values of the result field according to
4948  *          the optional numbers of cells and nodes, if any. The valid values are
4949  *          - 0 - do not permute.
4950  *          - 1 - permute cells.
4951  *          - 2 - permute nodes.
4952  *          - 3 - permute cells and nodes.
4953  *
4954  *  \param [in] glob - the global data storing profiles and localization.
4955  *  \param [in] mesh - the supporting mesh.
4956  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4957  *          caller is to delete this field using decrRef() as it is no more needed. 
4958  *  \throw If the MED file is not readable.
4959  *  \throw If no field of \a this is lying on \a mesh.
4960  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4961  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4962  */
4963 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4964 {
4965   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4966   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4967   if(meshDimRelToMax==1)
4968     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4969   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4970 }
4971
4972 /*!
4973  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4974  * given mesh. 
4975  *  \param [in] type - a spatial discretization of the new field.
4976  *  \param [in] mName - a name of the supporting mesh.
4977  *  \param [in] renumPol - specifies how to permute values of the result field according to
4978  *          the optional numbers of cells and nodes, if any. The valid values are
4979  *          - 0 - do not permute.
4980  *          - 1 - permute cells.
4981  *          - 2 - permute nodes.
4982  *          - 3 - permute cells and nodes.
4983  *
4984  *  \param [in] glob - the global data storing profiles and localization.
4985  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4986  *          caller is to delete this field using decrRef() as it is no more needed. 
4987  *  \throw If the MED file is not readable.
4988  *  \throw If there is no mesh named \a mName in the MED file.
4989  *  \throw If there are no mesh entities in the mesh.
4990  *  \throw If no field values of the given \a type are available.
4991  */
4992 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4993 {
4994   MCAuto<MEDFileMesh> mm;
4995   if(mName.empty())
4996     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4997   else
4998     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4999   int absDim=getDimension();
5000   int meshDimRelToMax=absDim-mm->getMeshDimension();
5001   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5002 }
5003
5004 /*!
5005  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5006  *  \param [in] type - a spatial discretization of the new field.
5007  *  \param [in] renumPol - specifies how to permute values of the result field according to
5008  *          the optional numbers of cells and nodes, if any. The valid values are
5009  *          - 0 - do not permute.
5010  *          - 1 - permute cells.
5011  *          - 2 - permute nodes.
5012  *          - 3 - permute cells and nodes.
5013  *
5014  *  \param [in] glob - the global data storing profiles and localization.
5015  *  \param [in] mesh - the supporting mesh.
5016  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5017  *         field according to \a renumPol.
5018  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5019  *         field according to \a renumPol.
5020  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5021  *          caller is to delete this field using decrRef() as it is no more needed. 
5022  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5023  *  \throw If no field of \a this is lying on \a mesh.
5024  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5025  */
5026 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
5027 {
5028   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5029   int meshId=getMeshIdFromMeshName(mesh->getName());
5030   bool isPfl=false;
5031   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5032   switch(renumPol)
5033   {
5034     case 0:
5035       {
5036         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5037         return ret.retn();
5038       }
5039     case 3:
5040     case 1:
5041       {
5042         if(isPfl)
5043           throw INTERP_KERNEL::Exception(msg1);
5044         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5045         if(cellRenum)
5046           {
5047             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5048               {
5049                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5050                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5051                 throw INTERP_KERNEL::Exception(oss.str());
5052               }
5053             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5054             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5055             std::vector<DataArray *> arrOut2(1,arrOut);
5056             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5057             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5058             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5059           }
5060         if(renumPol==1)
5061           return ret.retn();
5062       }
5063     case 2:
5064       {
5065         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5066         if(isPfl)
5067           throw INTERP_KERNEL::Exception(msg1);
5068         if(nodeRenum)
5069           {
5070             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5071               {
5072                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5073                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5074                 throw INTERP_KERNEL::Exception(oss.str());
5075               }
5076             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5077             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5078               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5079             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5080           }
5081         return ret.retn();
5082       }
5083     default:
5084       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5085   }
5086 }
5087
5088 /*!
5089  * Returns values and a profile of the field of a given type lying on a given support.
5090  *  \param [in] type - a spatial discretization of the field.
5091  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5092  *  \param [in] mesh - the supporting mesh.
5093  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5094  *          field of interest lies on. If the field lies on all entities of the given
5095  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5096  *          using decrRef() as it is no more needed.  
5097  *  \param [in] glob - the global data storing profiles and localization.
5098  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5099  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5100  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5101  *  \throw If no field of \a this is lying on \a mesh.
5102  *  \throw If no field values of the given \a type are available.
5103  */
5104 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5105 {
5106   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5107   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5108   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5109   ret->setName(nasc.getName().c_str());
5110   return ret.retn();
5111 }
5112
5113 //= MEDFileField1TSWithoutSDA
5114
5115 /*!
5116  * Throws if a given value is not a valid (non-extended) relative dimension.
5117  *  \param [in] meshDimRelToMax - the relative dimension value.
5118  *  \throw If \a meshDimRelToMax > 0.
5119  */
5120 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5121 {
5122   if(meshDimRelToMax>0)
5123     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5124 }
5125
5126 /*!
5127  * Checks if elements of a given mesh are in the order suitable for writing 
5128  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5129  * vector describing types of elements and their number.
5130  *  \param [in] mesh - the mesh to check.
5131  *  \return std::vector<int> - a vector holding for each element type (1) item of
5132  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5133  *          These values are in full-interlace mode.
5134  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5135  */
5136 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5137 {
5138   if(!mesh)
5139     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5140   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5141   int nbOfTypes=geoTypes.size();
5142   std::vector<int> code(3*nbOfTypes);
5143   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5144   arr1->alloc(nbOfTypes,1);
5145   int *arrPtr=arr1->getPointer();
5146   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5147   for(int i=0;i<nbOfTypes;i++,it++)
5148     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5149   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5150   const int *arrPtr2=arr2->getConstPointer();
5151   int i=0;
5152   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5153     {
5154       int pos=arrPtr2[i];
5155       int nbCells=mesh->getNumberOfCellsWithType(*it);
5156       code[3*pos]=(int)(*it);
5157       code[3*pos+1]=nbCells;
5158       code[3*pos+2]=-1;//no profiles
5159     }
5160   std::vector<const DataArrayInt *> idsPerType;//no profiles
5161   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5162   if(da)
5163     {
5164       da->decrRef();
5165       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5166     }
5167   return code;
5168 }
5169
5170 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5171 {
5172   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5173 }
5174
5175 /*!
5176  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5177  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5178  * item of every of returned sequences refers to the _i_-th part of \a this field.
5179  * Thus all sequences returned by this method are of the same length equal to number
5180  * of different types of supporting entities.<br>
5181  * A field part can include sub-parts with several different spatial discretizations,
5182  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5183  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5184  * of a nested sequence corresponds to a type of spatial discretization.<br>
5185  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5186  * The overhead is due to selecting values into new instances of DataArrayDouble.
5187  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5188  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5189  *          not checked if \a mname == \c NULL).
5190  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5191  *          a field part is returned. 
5192  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5193  *          A field part can include sub-parts with several different spatial discretizations,
5194  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5195  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5196  *          This sequence is of the same length as \a types. 
5197  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5198  *          discretization. A profile name can be empty.
5199  *          Length of this and of nested sequences is the same as that of \a typesF.
5200  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5201  *          discretization. A localization name can be empty.
5202  *          Length of this and of nested sequences is the same as that of \a typesF.
5203  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5204  *          per each type of spatial discretization within one mesh entity type.
5205  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5206  *          Length of this and of nested sequences is the same as that of \a typesF.
5207  *  \throw If no field is lying on \a mname.
5208  */
5209 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
5210 {
5211   int meshId=0;
5212   if(!mname.empty())
5213     meshId=getMeshIdFromMeshName(mname);
5214   else
5215     if(_field_per_mesh.empty())
5216       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5217   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5218   int nbOfRet=ret0.size();
5219   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5220   for(int i=0;i<nbOfRet;i++)
5221     {
5222       const std::vector< std::pair<int,int> >& p=ret0[i];
5223       int nbOfRet1=p.size();
5224       ret[i].resize(nbOfRet1);
5225       for(int j=0;j<nbOfRet1;j++)
5226         {
5227           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5228           ret[i][j]=tmp;
5229         }
5230     }
5231   return ret;
5232 }
5233
5234 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5235 {
5236   return TYPE_STR;
5237 }
5238
5239 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5240 {
5241   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5242   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5243   ret->deepCpyLeavesFrom(*this);
5244   const DataArrayDouble *arr(_arr);
5245   if(arr)
5246     {
5247       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5248       ret->setArray(arr2);
5249     }
5250   return ret.retn();
5251 }
5252
5253 /*!
5254  * Returns a pointer to the underground DataArrayDouble instance and a
5255  * sequence describing parameters of a support of each part of \a this field. The
5256  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5257  * direct access to the field values. This method is intended for the field lying on one
5258  * mesh only.
5259  *  \param [in,out] entries - the sequence describing parameters of a support of each
5260  *         part of \a this field. Each item of this sequence consists of two parts. The
5261  *         first part describes a type of mesh entity and an id of discretization of a
5262  *         current field part. The second part describes a range of values [begin,end)
5263  *         within the returned array relating to the current field part.
5264  *  \return DataArrayDouble * - the pointer to the field values array.
5265  *  \throw If the number of underlying meshes is not equal to 1.
5266  *  \throw If no field values are available.
5267  *  \sa getUndergroundDataArray()
5268  */
5269 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5270 {
5271   if(_field_per_mesh.size()!=1)
5272     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5273   if(_field_per_mesh[0]==0)
5274     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5275   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5276   return getUndergroundDataArrayTemplate();
5277 }
5278
5279 /*!
5280  * Returns a pointer to the underground DataArrayDouble instance and a
5281  * sequence describing parameters of a support of each part of \a this field. The
5282  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5283  * direct access to the field values. This method is intended for the field lying on one
5284  * mesh only.
5285  *  \param [in,out] entries - the sequence describing parameters of a support of each
5286  *         part of \a this field. Each item of this sequence consists of two parts. The
5287  *         first part describes a type of mesh entity and an id of discretization of a
5288  *         current field part. The second part describes a range of values [begin,end)
5289  *         within the returned array relating to the current field part.
5290  *  \return DataArrayDouble * - the pointer to the field values array.
5291  *  \throw If the number of underlying meshes is not equal to 1.
5292  *  \throw If no field values are available.
5293  *  \sa getUndergroundDataArray()
5294  */
5295 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5296 {
5297   return getUndergroundDataArrayDoubleExt(entries);
5298 }
5299
5300 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5301 {
5302   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5303   arr->setInfoAndChangeNbOfCompo(infos);
5304 }
5305
5306 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5307 {
5308 }
5309
5310 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5311 {
5312   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5313   ret->deepCpyLeavesFrom(*this);
5314   return ret.retn();
5315 }
5316
5317 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5318 {
5319   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5320   if((const DataArrayDouble *)_arr)
5321     ret->_arr=_arr->deepCopy();
5322   return ret.retn();
5323 }
5324
5325 //= MEDFileIntField1TSWithoutSDA
5326
5327 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5328 {
5329   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5330 }
5331
5332 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5333 {
5334 }
5335
5336 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5337                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5338 {
5339   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5340   arr->setInfoAndChangeNbOfCompo(infos);
5341 }
5342
5343 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5344 {
5345   return TYPE_STR;
5346 }
5347
5348 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5349 {
5350   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5351   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5352   ret->deepCpyLeavesFrom(*this);
5353   const DataArrayInt *arr(_arr);
5354   if(arr)
5355     {
5356       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5357       ret->setArray(arr2);
5358     }
5359   return ret.retn();
5360 }
5361
5362 /*!
5363  * Returns a pointer to the underground DataArrayInt instance and a
5364  * sequence describing parameters of a support of each part of \a this field. The
5365  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5366  * direct access to the field values. This method is intended for the field lying on one
5367  * mesh only.
5368  *  \param [in,out] entries - the sequence describing parameters of a support of each
5369  *         part of \a this field. Each item of this sequence consists of two parts. The
5370  *         first part describes a type of mesh entity and an id of discretization of a
5371  *         current field part. The second part describes a range of values [begin,end)
5372  *         within the returned array relating to the current field part.
5373  *  \return DataArrayInt * - the pointer to the field values array.
5374  *  \throw If the number of underlying meshes is not equal to 1.
5375  *  \throw If no field values are available.
5376  *  \sa getUndergroundDataArray()
5377  */
5378 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5379 {
5380   return getUndergroundDataArrayIntExt(entries);
5381 }
5382
5383 /*!
5384  * Returns a pointer to the underground DataArrayInt instance and a
5385  * sequence describing parameters of a support of each part of \a this field. The
5386  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5387  * direct access to the field values. This method is intended for the field lying on one
5388  * mesh only.
5389  *  \param [in,out] entries - the sequence describing parameters of a support of each
5390  *         part of \a this field. Each item of this sequence consists of two parts. The
5391  *         first part describes a type of mesh entity and an id of discretization of a
5392  *         current field part. The second part describes a range of values [begin,end)
5393  *         within the returned array relating to the current field part.
5394  *  \return DataArrayInt * - the pointer to the field values array.
5395  *  \throw If the number of underlying meshes is not equal to 1.
5396  *  \throw If no field values are available.
5397  *  \sa getUndergroundDataArray()
5398  */
5399 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5400 {
5401   if(_field_per_mesh.size()!=1)
5402     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5403   if(_field_per_mesh[0]==0)
5404     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5405   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5406   return getUndergroundDataArrayTemplate();
5407 }
5408
5409 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5410 {
5411   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5412   ret->deepCpyLeavesFrom(*this);
5413   return ret.retn();
5414 }
5415
5416 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5417 {
5418   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5419   if((const DataArrayInt *)_arr)
5420     ret->_arr=_arr->deepCopy();
5421   return ret.retn();
5422 }
5423
5424 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5425 {
5426 }
5427
5428 //= MEDFileAnyTypeField1TS
5429
5430 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5431 {
5432   med_field_type typcha;
5433   //
5434   std::vector<std::string> infos;
5435   std::string dtunit,fieldName;
5436   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5437   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5438   switch(typcha)
5439   {
5440     case MED_FLOAT64:
5441       {
5442         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5443         break;
5444       }
5445     case MED_INT32:
5446       {
5447         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5448         break;
5449       }
5450     default:
5451       {
5452         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] !";
5453         throw INTERP_KERNEL::Exception(oss.str());
5454       }
5455   }
5456   ret->setDtUnit(dtunit.c_str());
5457   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5458   //
5459   med_int numdt,numit;
5460   med_float dt;
5461   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5462   ret->setTime(numdt,numit,dt);
5463   ret->_csit=1;
5464   if(loadAll)
5465     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5466   else
5467     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5468   return ret.retn();
5469 }
5470
5471 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5472 try:MEDFileFieldGlobsReal(fid)
5473 {
5474   _content=BuildContentFrom(fid,loadAll,ms);
5475   loadGlobals(fid);
5476 }
5477 catch(INTERP_KERNEL::Exception& e)
5478 {
5479     throw e;
5480 }
5481
5482 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5483 {
5484   med_field_type typcha;
5485   std::vector<std::string> infos;
5486   std::string dtunit;
5487   int iii=-1;
5488   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5489   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5490   switch(typcha)
5491   {
5492     case MED_FLOAT64:
5493       {
5494         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5495         break;
5496       }
5497     case MED_INT32:
5498       {
5499         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5500         break;
5501       }
5502     default:
5503       {
5504         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] !";
5505         throw INTERP_KERNEL::Exception(oss.str());
5506       }
5507   }
5508   ret->setDtUnit(dtunit.c_str());
5509   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5510   //
5511   if(nbSteps<1)
5512     {
5513       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5514       throw INTERP_KERNEL::Exception(oss.str());
5515     }
5516   //
5517   med_int numdt,numit;
5518   med_float dt;
5519   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5520   ret->setTime(numdt,numit,dt);
5521   ret->_csit=1;
5522   if(loadAll)
5523     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5524   else
5525     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5526   return ret.retn();
5527 }
5528
5529 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5530 try:MEDFileFieldGlobsReal(fid)
5531 {
5532   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5533   loadGlobals(fid);
5534 }
5535 catch(INTERP_KERNEL::Exception& e)
5536 {
5537     throw e;
5538 }
5539
5540 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5541 {
5542   if(!c)
5543     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5544   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5545     {
5546       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5547       ret->_content=c; c->incrRef();
5548       return ret.retn();
5549     }
5550   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5551     {
5552       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5553       ret->_content=c; c->incrRef();
5554       return ret.retn();
5555     }
5556   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5557 }
5558
5559 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5560 {
5561   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5562   ret->setFileName(FileNameFromFID(fid));
5563   return ret;
5564 }
5565
5566 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5567 {
5568   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5569   return New(fid,loadAll);
5570 }
5571
5572 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5573 {
5574   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5575   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5576   ret->loadGlobals(fid);
5577   return ret.retn();
5578 }
5579
5580 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5581 {
5582   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5583   return New(fid,fieldName,loadAll);
5584 }
5585
5586 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5587 {
5588   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5589   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5590   ret->loadGlobals(fid);
5591   return ret.retn();
5592 }
5593
5594 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5595 {
5596   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5597   return New(fid,fieldName,iteration,order,loadAll);
5598 }
5599
5600 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5601 {
5602   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5603   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5604   ret->loadGlobals(fid);
5605   return ret.retn();
5606 }
5607
5608 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5609 {
5610   med_field_type typcha;
5611   std::vector<std::string> infos;
5612   std::string dtunit;
5613   int iii(-1);
5614   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5615   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5616   switch(typcha)
5617   {
5618     case MED_FLOAT64:
5619       {
5620         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5621         break;
5622       }
5623     case MED_INT32:
5624       {
5625         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5626         break;
5627       }
5628     default:
5629       {
5630         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] !";
5631         throw INTERP_KERNEL::Exception(oss.str());
5632       }
5633   }
5634   ret->setDtUnit(dtunit.c_str());
5635   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5636   //
5637   bool found=false;
5638   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5639   for(int i=0;i<nbOfStep2 && !found;i++)
5640     {
5641       med_int numdt,numit;
5642       med_float dt;
5643       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5644       if(numdt==iteration && numit==order)
5645         {
5646           found=true;
5647           ret->_csit=i+1;
5648         }
5649       else
5650         dtits[i]=std::pair<int,int>(numdt,numit);
5651     }
5652   if(!found)
5653     {
5654       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5655       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5656         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5657       throw INTERP_KERNEL::Exception(oss.str());
5658     }
5659   if(loadAll)
5660     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5661   else
5662     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5663   return ret.retn();
5664 }
5665
5666 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5667 try:MEDFileFieldGlobsReal(fid)
5668 {
5669   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5670   loadGlobals(fid);
5671 }
5672 catch(INTERP_KERNEL::Exception& e)
5673 {
5674     throw e;
5675 }
5676
5677 /*!
5678  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5679  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5680  *
5681  * \warning this is a shallow copy constructor
5682  */
5683 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5684 {
5685   if(!shallowCopyOfContent)
5686     {
5687       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5688       otherPtr->incrRef();
5689       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5690     }
5691   else
5692     {
5693       _content=other.shallowCpy();
5694     }
5695 }
5696
5697 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)
5698 {
5699   if(checkFieldId)
5700     {
5701       int nbFields=MEDnField(fid);
5702       if(fieldIdCFormat>=nbFields)
5703         {
5704           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5705           throw INTERP_KERNEL::Exception(oss.str());
5706         }
5707     }
5708   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5709   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5710   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5711   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5712   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5713   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5714   med_bool localMesh;
5715   int nbOfStep;
5716   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5717   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5718   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5719   infos.clear(); infos.resize(ncomp);
5720   for(int j=0;j<ncomp;j++)
5721     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5722   return nbOfStep;
5723 }
5724
5725 /*!
5726  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5727  * 
5728  * \param [out]
5729  * \return in case of success the number of time steps available for the field with name \a fieldName.
5730  */
5731 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5732 {
5733   int nbFields=MEDnField(fid);
5734   bool found=false;
5735   std::vector<std::string> fns(nbFields);
5736   int nbOfStep2(-1);
5737   for(int i=0;i<nbFields && !found;i++)
5738     {
5739       std::string tmp;
5740       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5741       fns[i]=tmp;
5742       found=(tmp==fieldName);
5743       if(found)
5744         posCFormat=i;
5745     }
5746   if(!found)
5747     {
5748       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5749       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5750         oss << "\"" << *it << "\" ";
5751       throw INTERP_KERNEL::Exception(oss.str());
5752     }
5753   return nbOfStep2;
5754 }
5755
5756 /*!
5757  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5758  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5759  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5760  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5761  * to keep a valid instance.
5762  * 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.
5763  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5764  * 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.
5765  *
5766  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5767  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5768  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5769  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5770  * \param [in] newLocName is the new localization name.
5771  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
5772  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5773  */
5774 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5775 {
5776   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5777   std::string oldPflName=disc->getProfile();
5778   std::vector<std::string> vv=getPflsReallyUsedMulti();
5779   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5780   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5781     {
5782       disc->setProfile(newPflName);
5783       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5784       pfl->setName(newPflName);
5785     }
5786   else
5787     {
5788       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5789       throw INTERP_KERNEL::Exception(oss.str());
5790     }
5791 }
5792
5793 /*!
5794  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5795  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5796  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5797  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5798  * to keep a valid instance.
5799  * 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.
5800  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5801  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5802  * 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.
5803  *
5804  * \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.
5805  * \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.
5806  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5807  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5808  * \param [in] newLocName is the new localization name.
5809  * \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.
5810  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5811  */
5812 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5813 {
5814   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5815   std::string oldLocName=disc->getLocalization();
5816   std::vector<std::string> vv=getLocsReallyUsedMulti();
5817   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5818   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5819     {
5820       disc->setLocalization(newLocName);
5821       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5822       loc.setName(newLocName);
5823     }
5824   else
5825     {
5826       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5827       throw INTERP_KERNEL::Exception(oss.str());
5828     }
5829 }
5830
5831 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5832 {
5833   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5834   if(!ret)
5835     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5836   return ret;
5837 }
5838
5839 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5840 {
5841   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5842   if(!ret)
5843     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5844   return ret;
5845 }
5846
5847 /*!
5848  * This method alloc the arrays and load potentially huge arrays contained in this field.
5849  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5850  * This method can be also called to refresh or reinit values from a file.
5851  * 
5852  * \throw If the fileName is not set or points to a non readable MED file.
5853  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5854  */
5855 void MEDFileAnyTypeField1TS::loadArrays()
5856 {
5857   if(getFileName().empty())
5858     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5859   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5860   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5861 }
5862
5863 /*!
5864  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5865  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5866  * this method does not throw if \a this does not come from file read.
5867  * 
5868  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5869  */
5870 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5871 {
5872   if(!getFileName().empty())
5873     {
5874       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5875       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5876     }
5877 }
5878
5879 /*!
5880  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5881  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5882  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5883  * 
5884  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5885  */
5886 void MEDFileAnyTypeField1TS::unloadArrays()
5887 {
5888   contentNotNullBase()->unloadArrays();
5889 }
5890
5891 /*!
5892  * 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.
5893  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5894  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5895  * 
5896  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5897  */
5898 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5899 {
5900   if(!getFileName().empty())
5901     contentNotNullBase()->unloadArrays();
5902 }
5903
5904 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5905 {
5906   int nbComp(getNumberOfComponents());
5907   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5908   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5909   for(int i=0;i<nbComp;i++)
5910     {
5911       std::string info=getInfo()[i];
5912       std::string c,u;
5913       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5914       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5915       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5916     }
5917   if(getName().empty())
5918     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5919   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5920   writeGlobals(fid,*this);
5921   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5922 }
5923
5924 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5925 {
5926   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5927 }
5928
5929 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5930 {
5931   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5932   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5933   return ret;
5934 }
5935
5936 /*!
5937  * Returns a string describing \a this field. This string is outputted 
5938  * by \c print Python command.
5939  */
5940 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5941 {
5942   std::ostringstream oss;
5943   contentNotNullBase()->simpleRepr(0,oss,-1);
5944   simpleReprGlobs(oss);
5945   return oss.str();
5946 }
5947
5948 /*!
5949  * This method returns all profiles whose name is non empty used.
5950  * \b WARNING If profile is used several times it will be reported \b only \b once.
5951  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5952  */
5953 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5954 {
5955   return contentNotNullBase()->getPflsReallyUsed2();
5956 }
5957
5958 /*!
5959  * This method returns all localizations whose name is non empty used.
5960  * \b WARNING If localization is used several times it will be reported \b only \b once.
5961  */
5962 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5963 {
5964   return contentNotNullBase()->getLocsReallyUsed2();
5965 }
5966
5967 /*!
5968  * This method returns all profiles whose name is non empty used.
5969  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5970  */
5971 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5972 {
5973   return contentNotNullBase()->getPflsReallyUsedMulti2();
5974 }
5975
5976 /*!
5977  * This method returns all localizations whose name is non empty used.
5978  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5979  */
5980 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5981 {
5982   return contentNotNullBase()->getLocsReallyUsedMulti2();
5983 }
5984
5985 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5986 {
5987   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5988 }
5989
5990 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5991 {
5992   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5993 }
5994
5995 int MEDFileAnyTypeField1TS::getDimension() const
5996 {
5997   return contentNotNullBase()->getDimension();
5998 }
5999
6000 int MEDFileAnyTypeField1TS::getIteration() const
6001 {
6002   return contentNotNullBase()->getIteration();
6003 }
6004
6005 int MEDFileAnyTypeField1TS::getOrder() const
6006 {
6007   return contentNotNullBase()->getOrder();
6008 }
6009
6010 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6011 {
6012   return contentNotNullBase()->getTime(iteration,order);
6013 }
6014
6015 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6016 {
6017   contentNotNullBase()->setTime(iteration,order,val);
6018 }
6019
6020 std::string MEDFileAnyTypeField1TS::getName() const
6021 {
6022   return contentNotNullBase()->getName();
6023 }
6024
6025 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6026 {
6027   contentNotNullBase()->setName(name);
6028 }
6029
6030 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6031 {
6032   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6033 }
6034
6035 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6036 {
6037   return contentNotNullBase()->getDtUnit();
6038 }
6039
6040 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6041 {
6042   contentNotNullBase()->setDtUnit(dtUnit);
6043 }
6044
6045 std::string MEDFileAnyTypeField1TS::getMeshName() const
6046 {
6047   return contentNotNullBase()->getMeshName();
6048 }
6049
6050 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6051 {
6052   contentNotNullBase()->setMeshName(newMeshName);
6053 }
6054
6055 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6056 {
6057   return contentNotNullBase()->changeMeshNames(modifTab);
6058 }
6059
6060 int MEDFileAnyTypeField1TS::getMeshIteration() const
6061 {
6062   return contentNotNullBase()->getMeshIteration();
6063 }
6064
6065 int MEDFileAnyTypeField1TS::getMeshOrder() const
6066 {
6067   return contentNotNullBase()->getMeshOrder();
6068 }
6069
6070 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6071 {
6072   return contentNotNullBase()->getNumberOfComponents();
6073 }
6074
6075 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6076 {
6077   return contentNotNullBase()->isDealingTS(iteration,order);
6078 }
6079
6080 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6081 {
6082   return contentNotNullBase()->getDtIt();
6083 }
6084
6085 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6086 {
6087   contentNotNullBase()->fillIteration(p);
6088 }
6089
6090 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6091 {
6092   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6093 }
6094
6095 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6096 {
6097   contentNotNullBase()->setInfo(infos);
6098 }
6099
6100 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6101 {
6102   return contentNotNullBase()->getInfo();
6103 }
6104 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6105 {
6106   return contentNotNullBase()->getInfo();
6107 }
6108
6109 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6110 {
6111   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6112 }
6113
6114 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6115 {
6116   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6117 }
6118
6119 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6120 {
6121   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6122 }
6123
6124 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6125 {
6126   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6127 }
6128
6129 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6130 {
6131   return contentNotNullBase()->getTypesOfFieldAvailable();
6132 }
6133
6134 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,
6135                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6136 {
6137   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6138 }
6139
6140 /*!
6141  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6142  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6143  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6144  */
6145 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6146 {
6147   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6148   if(!content)
6149     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6150   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6151   std::size_t sz(contentsSplit.size());
6152   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6153   for(std::size_t i=0;i<sz;i++)
6154     {
6155       ret[i]=shallowCpy();
6156       ret[i]->_content=contentsSplit[i];
6157     }
6158   return ret;
6159 }
6160
6161 /*!
6162  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6163  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6164  */
6165 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6166 {
6167   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6168   if(!content)
6169     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6170   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6171   std::size_t sz(contentsSplit.size());
6172   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6173   for(std::size_t i=0;i<sz;i++)
6174     {
6175       ret[i]=shallowCpy();
6176       ret[i]->_content=contentsSplit[i];
6177     }
6178   return ret;
6179 }
6180
6181 /*!
6182  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6183  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6184  */
6185 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6186 {
6187   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6188   if(!content)
6189     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6190   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6191   std::size_t sz(contentsSplit.size());
6192   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6193   for(std::size_t i=0;i<sz;i++)
6194     {
6195       ret[i]=shallowCpy();
6196       ret[i]->_content=contentsSplit[i];
6197     }
6198   return ret;
6199 }
6200
6201 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6202 {
6203   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6204   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6205     ret->_content=_content->deepCopy();
6206   ret->deepCpyGlobs(*this);
6207   return ret.retn();
6208 }
6209
6210 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6211 {
6212   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6213 }
6214
6215 //= MEDFileField1TS
6216
6217 /*!
6218  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6219  * the first field that has been read from a specified MED file.
6220  *  \param [in] fileName - the name of the MED file to read.
6221  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6222  *          is to delete this field using decrRef() as it is no more needed.
6223  *  \throw If reading the file fails.
6224  */
6225 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6226 {
6227   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6228   return New(fid,loadAll);
6229 }
6230
6231 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6232 {
6233   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6234   ret->contentNotNull();
6235   return ret.retn();
6236 }
6237
6238 /*!
6239  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6240  * a given field that has been read from a specified MED file.
6241  *  \param [in] fileName - the name of the MED file to read.
6242  *  \param [in] fieldName - the name of the field to read.
6243  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6244  *          is to delete this field using decrRef() as it is no more needed.
6245  *  \throw If reading the file fails.
6246  *  \throw If there is no field named \a fieldName in the file.
6247  */
6248 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6249 {
6250   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6251   return New(fid,fieldName,loadAll);
6252 }
6253
6254 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6255 {
6256   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6257   ret->contentNotNull();
6258   return ret.retn();
6259 }
6260
6261 /*!
6262  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6263  * a given field that has been read from a specified MED file.
6264  *  \param [in] fileName - the name of the MED file to read.
6265  *  \param [in] fieldName - the name of the field to read.
6266  *  \param [in] iteration - the iteration number of a required time step.
6267  *  \param [in] order - the iteration order number of required time step.
6268  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6269  *          is to delete this field using decrRef() as it is no more needed.
6270  *  \throw If reading the file fails.
6271  *  \throw If there is no field named \a fieldName in the file.
6272  *  \throw If the required time step is missing from the file.
6273  */
6274 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6275 {
6276   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6277   return New(fid,fieldName,iteration,order,loadAll);
6278 }
6279
6280 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6281 {
6282   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6283   ret->contentNotNull();
6284   return ret.retn();
6285 }
6286
6287 /*!
6288  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6289  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6290  *
6291  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6292  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6293  * \warning this is a shallow copy constructor
6294  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6295  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6296  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6297  *          is to delete this field using decrRef() as it is no more needed.
6298  */
6299 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6300 {
6301   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6302   ret->contentNotNull();
6303   return ret.retn();
6304 }
6305
6306 /*!
6307  * Returns a new empty instance of MEDFileField1TS.
6308  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6309  *          is to delete this field using decrRef() as it is no more needed.
6310  */
6311 MEDFileField1TS *MEDFileField1TS::New()
6312 {
6313   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6314   ret->contentNotNull();
6315   return ret.retn();
6316 }
6317
6318 /*!
6319  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6320  * following the given input policy.
6321  *
6322  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6323  *                            By default (true) the globals are deeply copied.
6324  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6325  */
6326 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6327 {
6328   MCAuto<MEDFileIntField1TS> ret;
6329   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6330   if(content)
6331     {
6332       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6333       if(!contc)
6334         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6335       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6336       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6337     }
6338   else
6339     ret=MEDFileIntField1TS::New();
6340   if(isDeepCpyGlobs)
6341     ret->deepCpyGlobs(*this);
6342   else
6343     ret->shallowCpyGlobs(*this);
6344   return ret.retn();
6345 }
6346
6347 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6348 {
6349   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6350   if(!pt)
6351     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6352   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6353   if(!ret)
6354     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 !");
6355   return ret;
6356 }
6357
6358 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6359 {
6360   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6361   if(!pt)
6362     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6363   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6364   if(!ret)
6365     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 !");
6366   return ret;
6367 }
6368
6369 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6370 {
6371   if(!f)
6372     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6373   if(arr.isNull())
6374     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6375   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6376   if(!arrOutC)
6377     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6378   f->setArray(arrOutC);
6379 }
6380
6381 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6382 {
6383   if(arr.isNull())
6384     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6385   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6386   if(!arrOutC)
6387     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6388   arrOutC->incrRef();
6389   return arrOutC;
6390 }
6391
6392 /*!
6393  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6394  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6395  *
6396  * \return A new object that the caller is responsible to deallocate.
6397  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6398  */
6399 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6400 {
6401   if(!mm)
6402     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6403   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6404   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6405   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6406     {
6407       if((*it0)!=ON_NODES)
6408         {
6409           std::vector<int> levs;
6410           getNonEmptyLevels(mm->getName(),levs);
6411           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6412             {
6413               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6414               if(it2!=extractDef.end())
6415                 {
6416                   MCAuto<DataArrayInt> t((*it2).second);
6417                   if(t.isNull())
6418                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6419                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6420                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6421                   ret->setFieldNoProfileSBT(fOut);
6422                 }
6423             }
6424         }
6425       else
6426         {
6427           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6428           if(it2==extractDef.end())
6429             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6430           MCAuto<DataArrayInt> t((*it2).second);
6431           if(t.isNull())
6432             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6433           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6434           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6435           DataArrayDouble *arr(f->getArray());
6436           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6437           fOut->setArray(newArr);
6438           ret->setFieldNoProfileSBT(fOut);
6439         }
6440     }
6441   return ret.retn();
6442 }
6443
6444 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6445 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6446 {
6447 }
6448 catch(INTERP_KERNEL::Exception& e)
6449 { throw e; }
6450
6451 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6452 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6453 {
6454 }
6455 catch(INTERP_KERNEL::Exception& e)
6456 { throw e; }
6457
6458 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6459 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6460 {
6461 }
6462 catch(INTERP_KERNEL::Exception& e)
6463 { throw e; }
6464
6465 /*!
6466  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6467  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6468  *
6469  * \warning this is a shallow copy constructor
6470  */
6471 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6472 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6473 {
6474 }
6475 catch(INTERP_KERNEL::Exception& e)
6476 { throw e; }
6477
6478 MEDFileField1TS::MEDFileField1TS()
6479 {
6480   _content=new MEDFileField1TSWithoutSDA;
6481 }
6482
6483 /*!
6484  * 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
6485  * method should be called (getFieldOnMeshAtLevel for example).
6486  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6487  *
6488  * \param [in] mesh - the mesh the field is lying on
6489  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6490  *          caller is to delete this field using decrRef() as it is no more needed. 
6491  */
6492 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6493 {
6494   MCAuto<DataArray> arrOut;
6495   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6496   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6497   return ret.retn();
6498 }
6499
6500 /*!
6501  * Returns a new MEDCouplingFieldDouble of a given type lying on
6502  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6503  * has not been constructed via file reading, an exception is thrown.
6504  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6505  *  \param [in] type - a spatial discretization of interest.
6506  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6507  *  \param [in] renumPol - specifies how to permute values of the result field according to
6508  *          the optional numbers of cells and nodes, if any. The valid values are
6509  *          - 0 - do not permute.
6510  *          - 1 - permute cells.
6511  *          - 2 - permute nodes.
6512  *          - 3 - permute cells and nodes.
6513  *
6514  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6515  *          caller is to delete this field using decrRef() as it is no more needed. 
6516  *  \throw If \a this field has not been constructed via file reading.
6517  *  \throw If the MED file is not readable.
6518  *  \throw If there is no mesh in the MED file.
6519  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6520  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6521  *  \sa getFieldOnMeshAtLevel()
6522  */
6523 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6524 {
6525   if(getFileName().empty())
6526     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6527   MCAuto<DataArray> arrOut;
6528   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6529   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6530   return ret.retn();
6531 }
6532
6533 /*!
6534  * Returns a new MEDCouplingFieldDouble of a given type lying on
6535  * the top level cells of the first mesh in MED file. If \a this field 
6536  * has not been constructed via file reading, an exception is thrown.
6537  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6538  *  \param [in] type - a spatial discretization of interest.
6539  *  \param [in] renumPol - specifies how to permute values of the result field according to
6540  *          the optional numbers of cells and nodes, if any. The valid values are
6541  *          - 0 - do not permute.
6542  *          - 1 - permute cells.
6543  *          - 2 - permute nodes.
6544  *          - 3 - permute cells and nodes.
6545  *
6546  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6547  *          caller is to delete this field using decrRef() as it is no more needed. 
6548  *  \throw If \a this field has not been constructed via file reading.
6549  *  \throw If the MED file is not readable.
6550  *  \throw If there is no mesh in the MED file.
6551  *  \throw If no field values of the given \a type.
6552  *  \throw If no field values lying on the top level support.
6553  *  \sa getFieldAtLevel()
6554  */
6555 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6556 {
6557   if(getFileName().empty())
6558     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6559   MCAuto<DataArray> arrOut;
6560   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6561   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6562   return ret.retn();
6563 }
6564
6565 /*!
6566  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6567  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6568  *  \param [in] type - a spatial discretization of the new field.
6569  *  \param [in] mesh - the supporting mesh.
6570  *  \param [in] renumPol - specifies how to permute values of the result field according to
6571  *          the optional numbers of cells and nodes, if any. The valid values are
6572  *          - 0 - do not permute.
6573  *          - 1 - permute cells.
6574  *          - 2 - permute nodes.
6575  *          - 3 - permute cells and nodes.
6576  *
6577  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6578  *          caller is to delete this field using decrRef() as it is no more needed. 
6579  *  \throw If no field of \a this is lying on \a mesh.
6580  *  \throw If the mesh is empty.
6581  *  \throw If no field values of the given \a type are available.
6582  *  \sa getFieldAtLevel()
6583  *  \sa getFieldOnMeshAtLevel() 
6584  */
6585 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6586 {
6587   MCAuto<DataArray> arrOut;
6588   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6589   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6590   return ret.retn();
6591 }
6592
6593 /*!
6594  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6595  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6596  *  \param [in] type - a spatial discretization of interest.
6597  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6598  *  \param [in] mesh - the supporting mesh.
6599  *  \param [in] renumPol - specifies how to permute values of the result field according to
6600  *          the optional numbers of cells and nodes, if any. The valid values are
6601  *          - 0 - do not permute.
6602  *          - 1 - permute cells.
6603  *          - 2 - permute nodes.
6604  *          - 3 - permute cells and nodes.
6605  *
6606  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6607  *          caller is to delete this field using decrRef() as it is no more needed. 
6608  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6609  *  \throw If no field of \a this is lying on \a mesh.
6610  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6611  *  \sa getFieldAtLevel()
6612  *  \sa getFieldOnMeshAtLevel() 
6613  */
6614 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6615 {
6616   MCAuto<DataArray> arrOut;
6617   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6618   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6619   return ret.retn();
6620 }
6621
6622 /*!
6623  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6624  * This method is called "Old" because in MED3 norm a field has only one meshName
6625  * attached, so this method is for readers of MED2 files. If \a this field 
6626  * has not been constructed via file reading, an exception is thrown.
6627  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6628  *  \param [in] type - a spatial discretization of interest.
6629  *  \param [in] mName - a name of the supporting mesh.
6630  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6631  *  \param [in] renumPol - specifies how to permute values of the result field according to
6632  *          the optional numbers of cells and nodes, if any. The valid values are
6633  *          - 0 - do not permute.
6634  *          - 1 - permute cells.
6635  *          - 2 - permute nodes.
6636  *          - 3 - permute cells and nodes.
6637  *
6638  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6639  *          caller is to delete this field using decrRef() as it is no more needed. 
6640  *  \throw If the MED file is not readable.
6641  *  \throw If there is no mesh named \a mName in the MED file.
6642  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6643  *  \throw If \a this field has not been constructed via file reading.
6644  *  \throw If no field of \a this is lying on the mesh named \a mName.
6645  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6646  *  \sa getFieldAtLevel()
6647  */
6648 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6649 {
6650   if(getFileName().empty())
6651     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6652   MCAuto<DataArray> arrOut;
6653   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6654   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6655   return ret.retn();
6656 }
6657
6658 /*!
6659  * Returns values and a profile of the field of a given type lying on a given support.
6660  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6661  *  \param [in] type - a spatial discretization of the field.
6662  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6663  *  \param [in] mesh - the supporting mesh.
6664  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6665  *          field of interest lies on. If the field lies on all entities of the given
6666  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6667  *          using decrRef() as it is no more needed.  
6668  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6669  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6670  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6671  *  \throw If no field of \a this is lying on \a mesh.
6672  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6673  */
6674 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6675 {
6676   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6677   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6678 }
6679
6680 /*!
6681  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6682  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6683  * "Sort By Type"), if not, an exception is thrown. 
6684  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6685  *  \param [in] field - the field to add to \a this.
6686  *  \throw If the name of \a field is empty.
6687  *  \throw If the data array of \a field is not set.
6688  *  \throw If the data array is already allocated but has different number of components
6689  *         than \a field.
6690  *  \throw If the underlying mesh of \a field has no name.
6691  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6692  */
6693 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6694 {
6695   setFileName("");
6696   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6697 }
6698
6699 /*!
6700  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6701  * can be an aggregation of several MEDCouplingFieldDouble instances.
6702  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6703  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6704  * and \a profile.
6705  *
6706  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6707  * A new profile is added only if no equal profile is missing.
6708  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6709  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6710  *  \param [in] mesh - the supporting mesh of \a field.
6711  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6712  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6713  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6714  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6715  *  \throw If the data array of \a field is not set.
6716  *  \throw If the data array of \a this is already allocated but has different number of
6717  *         components than \a field.
6718  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6719  *  \sa setFieldNoProfileSBT()
6720  */
6721 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6722 {
6723   setFileName("");
6724   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6725 }
6726
6727 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6728 {
6729   return new MEDFileField1TS(*this);
6730 }
6731
6732 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6733 {
6734   return contentNotNull()->getUndergroundDataArrayTemplate();
6735 }
6736
6737 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6738 {
6739   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6740 }
6741
6742 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6743                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6744 {
6745   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6746 }
6747
6748 //= MEDFileIntField1TS
6749
6750 MEDFileIntField1TS *MEDFileIntField1TS::New()
6751 {
6752   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6753   ret->contentNotNull();
6754   return ret.retn();
6755 }
6756
6757 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6758 {
6759   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6760   return MEDFileIntField1TS::New(fid,loadAll);
6761 }
6762
6763 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6764 {
6765   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6766   ret->contentNotNull();
6767   return ret.retn();
6768 }
6769
6770 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6771 {
6772   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6773   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6774 }
6775
6776 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6777 {
6778   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6779   ret->contentNotNull();
6780   return ret.retn();
6781 }
6782
6783 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6784 {
6785   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6786   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6787 }
6788
6789 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6790 {
6791   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6792   ret->contentNotNull();
6793   return ret.retn();
6794 }
6795
6796 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6797 {
6798   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6799   ret->contentNotNull();
6800   return ret.retn();
6801 }
6802
6803 MEDFileIntField1TS::MEDFileIntField1TS()
6804 {
6805   _content=new MEDFileIntField1TSWithoutSDA;
6806 }
6807
6808 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6809 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6810 {
6811 }
6812 catch(INTERP_KERNEL::Exception& e)
6813 { throw e; }
6814
6815 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6816 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6817 {
6818 }
6819 catch(INTERP_KERNEL::Exception& e)
6820 { throw e; }
6821
6822 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6823 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6824 {
6825 }
6826 catch(INTERP_KERNEL::Exception& e)
6827 { throw e; }
6828
6829 /*!
6830  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6831  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6832  *
6833  * \warning this is a shallow copy constructor
6834  */
6835 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6836 {
6837 }
6838
6839 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6840 {
6841   return new MEDFileIntField1TS(*this);
6842 }
6843
6844 /*!
6845  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6846  * following the given input policy.
6847  *
6848  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6849  *                            By default (true) the globals are deeply copied.
6850  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6851  */
6852 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6853 {
6854   MCAuto<MEDFileField1TS> ret;
6855   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6856   if(content)
6857     {
6858       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6859       if(!contc)
6860         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6861       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6862       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6863     }
6864   else
6865     ret=MEDFileField1TS::New();
6866   if(isDeepCpyGlobs)
6867     ret->deepCpyGlobs(*this);
6868   else
6869     ret->shallowCpyGlobs(*this);
6870   return ret.retn();
6871 }
6872
6873 /*!
6874  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6875  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6876  * "Sort By Type"), if not, an exception is thrown. 
6877  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6878  *  \param [in] field - the field to add to \a this.
6879  *  \throw If the name of \a field is empty.
6880  *  \throw If the data array of \a field is not set.
6881  *  \throw If the data array is already allocated but has different number of components
6882  *         than \a field.
6883  *  \throw If the underlying mesh of \a field has no name.
6884  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6885  */
6886 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6887 {
6888   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6889   setFileName("");
6890   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6891 }
6892
6893 /*!
6894  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6895  * can be an aggregation of several MEDCouplingFieldDouble instances.
6896  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6897  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6898  * and \a profile.
6899  *
6900  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6901  * A new profile is added only if no equal profile is missing.
6902  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6903  *  \param [in] field - the field to add to \a this.
6904  *  \param [in] mesh - the supporting mesh of \a field.
6905  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6906  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6907  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6908  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6909  *  \throw If the data array of \a field is not set.
6910  *  \throw If the data array of \a this is already allocated but has different number of
6911  *         components than \a field.
6912  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6913  *  \sa setFieldNoProfileSBT()
6914  */
6915 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6916 {
6917   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6918   setFileName("");
6919   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6920 }
6921
6922 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6923 {
6924   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6925   if(!pt)
6926     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6927   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6928   if(!ret)
6929     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 !");
6930   return ret;
6931 }
6932
6933 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6934 {
6935   if(getFileName().empty())
6936     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6937   MCAuto<DataArray> arrOut;
6938   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6939   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6940   return ret2.retn();
6941 }
6942
6943 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6944 {
6945   if(arr.isNull())
6946     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6947   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6948   if(!arrC)
6949     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6950   arrC->incrRef();
6951   return arrC;
6952 }
6953
6954 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6955 {
6956   int t1,t2;
6957   double t0(f->getTime(t1,t2));
6958   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6959   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6960   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6961   ret->setTime(t0,t1,t2); ret->setArray(arr2);
6962   return ret.retn();
6963 }
6964
6965 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6966 {
6967   if(!f)
6968     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6969   int t1,t2;
6970   double t0(f->getTime(t1,t2));
6971   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6972   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6973   ret->setTime(t0,t1,t2);
6974   return ret;
6975 }
6976
6977 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6978 {
6979   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6980 }
6981
6982 /*!
6983  * 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
6984  * method should be called (getFieldOnMeshAtLevel for example).
6985  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6986  *
6987  * \param [in] mesh - the mesh the field is lying on
6988  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6989  *          caller is to delete this field using decrRef() as it is no more needed. 
6990  */
6991 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6992 {
6993   MCAuto<DataArray> arrOut;
6994   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6995   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6996   return ret2.retn();
6997 }
6998
6999 /*!
7000  * Returns a new MEDCouplingFieldInt of a given type lying on
7001  * the top level cells of the first mesh in MED file. If \a this field 
7002  * has not been constructed via file reading, an exception is thrown.
7003  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7004  *  \param [in] type - a spatial discretization of interest.
7005  *  \param [in] renumPol - specifies how to permute values of the result field according to
7006  *          the optional numbers of cells and nodes, if any. The valid values are
7007  *          - 0 - do not permute.
7008  *          - 1 - permute cells.
7009  *          - 2 - permute nodes.
7010  *          - 3 - permute cells and nodes.
7011  *
7012  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7013  *          caller is to delete this field using decrRef() as it is no more needed. 
7014  *  \throw If \a this field has not been constructed via file reading.
7015  *  \throw If the MED file is not readable.
7016  *  \throw If there is no mesh in the MED file.
7017  *  \throw If no field values of the given \a type.
7018  *  \throw If no field values lying on the top level support.
7019  *  \sa getFieldAtLevel()
7020  */
7021 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7022 {
7023   if(getFileName().empty())
7024     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7025   MCAuto<DataArray> arrOut;
7026   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7027   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7028   return ret2.retn();
7029 }
7030
7031 /*!
7032  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7033  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7034  *  \param [in] type - a spatial discretization of the new field.
7035  *  \param [in] mesh - the supporting mesh.
7036  *  \param [in] renumPol - specifies how to permute values of the result field according to
7037  *          the optional numbers of cells and nodes, if any. The valid values are
7038  *          - 0 - do not permute.
7039  *          - 1 - permute cells.
7040  *          - 2 - permute nodes.
7041  *          - 3 - permute cells and nodes.
7042  *
7043  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7044  *          caller is to delete this field using decrRef() as it is no more needed. 
7045  *  \throw If no field of \a this is lying on \a mesh.
7046  *  \throw If the mesh is empty.
7047  *  \throw If no field values of the given \a type are available.
7048  *  \sa getFieldAtLevel()
7049  *  \sa getFieldOnMeshAtLevel() 
7050  */
7051 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7052 {
7053   MCAuto<DataArray> arrOut;
7054   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7055   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7056   return ret2.retn();
7057 }
7058
7059 /*!
7060  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7061  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7062  *  \param [in] type - a spatial discretization of interest.
7063  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7064  *  \param [in] mesh - the supporting mesh.
7065  *  \param [in] renumPol - specifies how to permute values of the result field according to
7066  *          the optional numbers of cells and nodes, if any. The valid values are
7067  *          - 0 - do not permute.
7068  *          - 1 - permute cells.
7069  *          - 2 - permute nodes.
7070  *          - 3 - permute cells and nodes.
7071  *
7072  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7073  *          caller is to delete this field using decrRef() as it is no more needed. 
7074  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7075  *  \throw If no field of \a this is lying on \a mesh.
7076  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7077  *  \sa getFieldAtLevel()
7078  *  \sa getFieldOnMeshAtLevel() 
7079  */
7080 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7081 {
7082   MCAuto<DataArray> arrOut;
7083   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7084   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7085   return ret2.retn();
7086 }
7087
7088 /*!
7089  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7090  * This method is called "Old" because in MED3 norm a field has only one meshName
7091  * attached, so this method is for readers of MED2 files. If \a this field 
7092  * has not been constructed via file reading, an exception is thrown.
7093  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7094  *  \param [in] type - a spatial discretization of interest.
7095  *  \param [in] mName - a name of the supporting mesh.
7096  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7097  *  \param [in] renumPol - specifies how to permute values of the result field according to
7098  *          the optional numbers of cells and nodes, if any. The valid values are
7099  *          - 0 - do not permute.
7100  *          - 1 - permute cells.
7101  *          - 2 - permute nodes.
7102  *          - 3 - permute cells and nodes.
7103  *
7104  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7105  *          caller is to delete this field using decrRef() as it is no more needed. 
7106  *  \throw If the MED file is not readable.
7107  *  \throw If there is no mesh named \a mName in the MED file.
7108  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7109  *  \throw If \a this field has not been constructed via file reading.
7110  *  \throw If no field of \a this is lying on the mesh named \a mName.
7111  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7112  *  \sa getFieldAtLevel()
7113  */
7114 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7115 {
7116   if(getFileName().empty())
7117     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7118   MCAuto<DataArray> arrOut;
7119   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7120   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7121   return ret2.retn();
7122 }
7123
7124 /*!
7125  * Returns values and a profile of the field of a given type lying on a given support.
7126  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7127  *  \param [in] type - a spatial discretization of the field.
7128  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7129  *  \param [in] mesh - the supporting mesh.
7130  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7131  *          field of interest lies on. If the field lies on all entities of the given
7132  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7133  *          using decrRef() as it is no more needed.  
7134  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7135  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7136  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7137  *  \throw If no field of \a this is lying on \a mesh.
7138  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7139  */
7140 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7141 {
7142   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7143   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7144 }
7145
7146 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7147 {
7148   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7149   if(!pt)
7150     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7151   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7152   if(!ret)
7153     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 !");
7154   return ret;
7155 }
7156
7157 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7158 {
7159   return contentNotNull()->getUndergroundDataArrayTemplate();
7160 }
7161
7162 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7163
7164 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7165 {
7166 }
7167
7168 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7169 {
7170 }
7171
7172 /*!
7173  * \param [in] fieldId field id in C mode
7174  */
7175 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7176 {
7177   med_field_type typcha;
7178   std::string dtunitOut;
7179   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7180   setDtUnit(dtunitOut.c_str());
7181   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7182 }
7183
7184 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)
7185 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7186 {
7187   setDtUnit(dtunit.c_str());
7188   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7189 }
7190 catch(INTERP_KERNEL::Exception& e)
7191 {
7192     throw e;
7193 }
7194
7195 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7196 {
7197   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7198   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7199     ret+=(*it).capacity();
7200   return ret;
7201 }
7202
7203 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7204 {
7205   std::vector<const BigMemoryObject *> ret;
7206   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7207     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7208   return ret;
7209 }
7210
7211 /*!
7212  * 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
7213  * NULL.
7214  */
7215 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7216 {
7217   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7218   ret->setInfo(_infos);
7219   int sz=(int)_time_steps.size();
7220   for(const int *id=startIds;id!=endIds;id++)
7221     {
7222       if(*id>=0 && *id<sz)
7223         {
7224           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7225           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7226           if(tse)
7227             {
7228               tse->incrRef();
7229               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7230             }
7231           ret->pushBackTimeStep(tse2);
7232         }
7233       else
7234         {
7235           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7236           oss << " ! Should be in [0," << sz << ") !";
7237           throw INTERP_KERNEL::Exception(oss.str());
7238         }
7239     }
7240   if(ret->getNumberOfTS()>0)
7241     ret->synchronizeNameScope();
7242   ret->copyNameScope(*this);
7243   return ret.retn();
7244 }
7245
7246 /*!
7247  * 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
7248  * NULL.
7249  */
7250 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7251 {
7252   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7253   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7254   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7255   ret->setInfo(_infos);
7256   int sz=(int)_time_steps.size();
7257   int j=bg;
7258   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7259     {
7260       if(j>=0 && j<sz)
7261         {
7262           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7263           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7264           if(tse)
7265             {
7266               tse->incrRef();
7267               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7268             }
7269           ret->pushBackTimeStep(tse2);
7270         }
7271       else
7272         {
7273           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7274           oss << " ! Should be in [0," << sz << ") !";
7275           throw INTERP_KERNEL::Exception(oss.str());
7276         }
7277     }
7278   if(ret->getNumberOfTS()>0)
7279     ret->synchronizeNameScope();
7280   ret->copyNameScope(*this);
7281   return ret.retn();
7282 }
7283
7284 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7285 {
7286   int id=0;
7287   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7288   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7289     {
7290       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7291       if(!cur)
7292         continue;
7293       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7294       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7295         ids->pushBackSilent(id);
7296     }
7297   return buildFromTimeStepIds(ids->begin(),ids->end());
7298 }
7299
7300 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7301 {
7302   int id=0;
7303   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7304   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7305     {
7306       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7307       if(!cur)
7308         continue;
7309       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7310       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7311         ids->pushBackSilent(id);
7312     }
7313   return buildFromTimeStepIds(ids->begin(),ids->end());
7314 }
7315
7316 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7317 {
7318   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7319     {
7320       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7321       if(!cur)
7322         continue;
7323       if(cur->presenceOfMultiDiscPerGeoType())
7324         return true;
7325     }
7326   return false;
7327 }
7328
7329 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7330 {
7331   return _infos;
7332 }
7333
7334 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7335 {
7336   _infos=info;
7337 }
7338
7339 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7340 {
7341   int ret=0;
7342   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7343     {
7344       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7345       if(pt->isDealingTS(iteration,order))
7346         return ret;
7347     }
7348   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7349   std::vector< std::pair<int,int> > vp=getIterations();
7350   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7351     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7352   throw INTERP_KERNEL::Exception(oss.str());
7353 }
7354
7355 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7356 {
7357   return *_time_steps[getTimeStepPos(iteration,order)];
7358 }
7359
7360 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7361 {
7362   return *_time_steps[getTimeStepPos(iteration,order)];
7363 }
7364
7365 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7366 {
7367   if(_time_steps.empty())
7368     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7369   return _time_steps[0]->getMeshName();
7370 }
7371
7372 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7373 {
7374   std::string oldName(getMeshName());
7375   std::vector< std::pair<std::string,std::string> > v(1);
7376   v[0].first=oldName; v[0].second=newMeshName;
7377   changeMeshNames(v);
7378 }
7379
7380 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7381 {
7382   bool ret=false;
7383   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7384     {
7385       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7386       if(cur)
7387         ret=cur->changeMeshNames(modifTab) || ret;
7388     }
7389   return ret;
7390 }
7391
7392 /*!
7393  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7394  */
7395 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7396 {
7397   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7398 }
7399
7400 /*!
7401  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7402  */
7403 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7404 {
7405   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7406 }
7407
7408 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7409                                                                        MEDFileFieldGlobsReal& glob)
7410 {
7411   bool ret=false;
7412   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7413     {
7414       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7415       if(f1ts)
7416         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7417     }
7418   return ret;
7419 }
7420
7421 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7422 {
7423   std::string startLine(bkOffset,' ');
7424   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7425   if(fmtsId>=0)
7426     oss << " (" << fmtsId << ")";
7427   oss << " has the following name: \"" << _name << "\"." << std::endl;
7428   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7429   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7430     {
7431       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7432     }
7433   int i=0;
7434   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7435     {
7436       std::string chapter(17,'0'+i);
7437       oss << startLine << chapter << std::endl;
7438       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7439       if(cur)
7440         cur->simpleRepr(bkOffset+2,oss,i);
7441       else
7442         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7443       oss << startLine << chapter << std::endl;
7444     }
7445 }
7446
7447 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7448 {
7449   std::size_t sz=_time_steps.size();
7450   std::vector< std::pair<int,int> > ret(sz);
7451   ret1.resize(sz);
7452   for(std::size_t i=0;i<sz;i++)
7453     {
7454       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7455       if(f1ts)
7456         {
7457           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7458         }
7459       else
7460         {
7461           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7462           throw INTERP_KERNEL::Exception(oss.str());
7463         }
7464     }
7465   return ret;
7466 }
7467
7468 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7469 {
7470   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7471   if(!tse2)
7472     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7473   checkCoherencyOfType(tse2);
7474   if(_time_steps.empty())
7475     {
7476       setName(tse2->getName().c_str());
7477       setInfo(tse2->getInfo());
7478     }
7479   checkThatComponentsMatch(tse2->getInfo());
7480   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7481     setDtUnit(tse->getDtUnit());
7482   _time_steps.push_back(tse);
7483 }
7484
7485 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7486 {
7487   std::size_t nbOfCompo=_infos.size();
7488   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7489     {
7490       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7491       if(cur)
7492         {
7493           if((cur->getInfo()).size()!=nbOfCompo)
7494             {
7495               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7496               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7497               throw INTERP_KERNEL::Exception(oss.str());
7498             }
7499           cur->copyNameScope(*this);
7500         }
7501     }
7502 }
7503
7504 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7505 {
7506   _time_steps.resize(nbPdt);
7507   for(int i=0;i<nbPdt;i++)
7508     {
7509       std::vector< std::pair<int,int> > ts;
7510       med_int numdt=0,numo=0;
7511       med_float dt=0.0;
7512       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7513       switch(fieldTyp)
7514       {
7515         case MED_FLOAT64:
7516           {
7517             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7518             break;
7519           }
7520         case MED_INT32:
7521           {
7522             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7523             break;
7524           }
7525         default:
7526           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7527       }
7528       if(loadAll)
7529         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7530       else
7531         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7532       synchronizeNameScope();
7533     }
7534 }
7535
7536 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7537 {
7538   if(_time_steps.empty())
7539     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7540   checkThatNbOfCompoOfTSMatchThis();
7541   std::vector<std::string> infos(getInfo());
7542   int nbComp=infos.size();
7543   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7544   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7545   for(int i=0;i<nbComp;i++)
7546     {
7547       std::string info=infos[i];
7548       std::string c,u;
7549       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7550       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7551       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7552     }
7553   if(_name.empty())
7554     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7555   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7556   int nbOfTS=_time_steps.size();
7557   for(int i=0;i<nbOfTS;i++)
7558     _time_steps[i]->writeLL(fid,opts,*this);
7559 }
7560
7561 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7562 {
7563   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7564     {
7565       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7566       if(elt)
7567         elt->loadBigArraysRecursively(fid,nasc);
7568     }
7569 }
7570
7571 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7572 {
7573   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7574     {
7575       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7576       if(elt)
7577         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7578     }
7579 }
7580
7581 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7582 {
7583   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7584     {
7585       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7586       if(elt)
7587         elt->unloadArrays();
7588     }
7589 }
7590
7591 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7592 {
7593   return _time_steps.size();
7594 }
7595
7596 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7597 {
7598   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7599   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7600     {
7601       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7602       if(tmp)
7603         newTS.push_back(*it);
7604     }
7605   _time_steps=newTS;
7606 }
7607
7608 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7609 {
7610   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7611   int maxId=(int)_time_steps.size();
7612   int ii=0;
7613   std::set<int> idsToDel;
7614   for(const int *id=startIds;id!=endIds;id++,ii++)
7615     {
7616       if(*id>=0 && *id<maxId)
7617         {
7618           idsToDel.insert(*id);
7619         }
7620       else
7621         {
7622           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7623           throw INTERP_KERNEL::Exception(oss.str());
7624         }
7625     }
7626   for(int iii=0;iii<maxId;iii++)
7627     if(idsToDel.find(iii)==idsToDel.end())
7628       newTS.push_back(_time_steps[iii]);
7629   _time_steps=newTS;
7630 }
7631
7632 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7633 {
7634   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7635   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7636   if(nbOfEntriesToKill==0)
7637     return ;
7638   std::size_t sz=_time_steps.size();
7639   std::vector<bool> b(sz,true);
7640   int j=bg;
7641   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7642     b[j]=false;
7643   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7644   for(std::size_t i=0;i<sz;i++)
7645     if(b[i])
7646       newTS.push_back(_time_steps[i]);
7647   _time_steps=newTS;
7648 }
7649
7650 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7651 {
7652   int ret=0;
7653   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7654   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7655     {
7656       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7657       if(tmp)
7658         {
7659           int it2,ord;
7660           tmp->getTime(it2,ord);
7661           if(it2==iteration && order==ord)
7662             return ret;
7663           else
7664             oss << "(" << it2 << ","  << ord << "), ";
7665         }
7666     }
7667   throw INTERP_KERNEL::Exception(oss.str());
7668 }
7669
7670 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7671 {
7672   int ret=0;
7673   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7674   oss.precision(15);
7675   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7676     {
7677       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7678       if(tmp)
7679         {
7680           int it2,ord;
7681           double ti=tmp->getTime(it2,ord);
7682           if(fabs(time-ti)<eps)
7683             return ret;
7684           else
7685             oss << ti << ", ";
7686         }
7687     }
7688   throw INTERP_KERNEL::Exception(oss.str());
7689 }
7690
7691 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7692 {
7693   int lgth=_time_steps.size();
7694   std::vector< std::pair<int,int> > ret(lgth);
7695   for(int i=0;i<lgth;i++)
7696     _time_steps[i]->fillIteration(ret[i]);
7697   return ret;
7698 }
7699
7700 /*!
7701  * 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'
7702  * This method returns two things.
7703  * - The absolute dimension of 'this' in first parameter. 
7704  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7705  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7706  *
7707  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7708  * Only these 3 discretizations will be taken into account here.
7709  *
7710  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7711  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7712  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7713  *
7714  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7715  * 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'.
7716  * 
7717  * Let's consider the typical following case :
7718  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7719  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7720  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7721  *   TETRA4 and SEG2
7722  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7723  *
7724  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7725  * 
7726  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7727  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7728  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7729  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7730  */
7731 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7732 {
7733   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7734 }
7735
7736 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7737 {
7738   if(pos<0 || pos>=(int)_time_steps.size())
7739     {
7740       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7741       throw INTERP_KERNEL::Exception(oss.str());
7742     }
7743   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7744   if(item==0)
7745     {
7746       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7747       oss << "\nTry to use following method eraseEmptyTS !";
7748       throw INTERP_KERNEL::Exception(oss.str());
7749     }
7750   return item;
7751 }
7752
7753 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7754 {
7755   if(pos<0 || pos>=(int)_time_steps.size())
7756     {
7757       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7758       throw INTERP_KERNEL::Exception(oss.str());
7759     }
7760   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7761   if(item==0)
7762     {
7763       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7764       oss << "\nTry to use following method eraseEmptyTS !";
7765       throw INTERP_KERNEL::Exception(oss.str());
7766     }
7767   return item;
7768 }
7769
7770 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7771 {
7772   std::vector<std::string> ret;
7773   std::set<std::string> ret2;
7774   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7775     {
7776       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7777       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7778         if(ret2.find(*it2)==ret2.end())
7779           {
7780             ret.push_back(*it2);
7781             ret2.insert(*it2);
7782           }
7783     }
7784   return ret;
7785 }
7786
7787 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7788 {
7789   std::vector<std::string> ret;
7790   std::set<std::string> ret2;
7791   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7792     {
7793       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7794       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7795         if(ret2.find(*it2)==ret2.end())
7796           {
7797             ret.push_back(*it2);
7798             ret2.insert(*it2);
7799           }
7800     }
7801   return ret;
7802 }
7803
7804 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7805 {
7806   std::vector<std::string> ret;
7807   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7808     {
7809       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7810       ret.insert(ret.end(),tmp.begin(),tmp.end());
7811     }
7812   return ret;
7813 }
7814
7815 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7816 {
7817   std::vector<std::string> ret;
7818   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7819     {
7820       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7821       ret.insert(ret.end(),tmp.begin(),tmp.end());
7822     }
7823   return ret;
7824 }
7825
7826 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7827 {
7828   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7829     (*it)->changePflsRefsNamesGen2(mapOfModif);
7830 }
7831
7832 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7833 {
7834   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7835     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7836 }
7837
7838 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7839 {
7840   int lgth=_time_steps.size();
7841   std::vector< std::vector<TypeOfField> > ret(lgth);
7842   for(int i=0;i<lgth;i++)
7843     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7844   return ret;
7845 }
7846
7847 /*!
7848  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7849  */
7850 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
7851 {
7852   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7853 }
7854
7855 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7856 {
7857   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7858   std::size_t i=0;
7859   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7860     {
7861       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7862         ret->_time_steps[i]=(*it)->deepCopy();
7863     }
7864   return ret.retn();
7865 }
7866
7867 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7868 {
7869   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7870   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7871   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7872   for(std::size_t i=0;i<sz;i++)
7873     {
7874       ret[i]=shallowCpy();
7875       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7876     }
7877   for(std::size_t i=0;i<sz2;i++)
7878     {
7879       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7880       if(ret1.size()!=sz)
7881         {
7882           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7883           throw INTERP_KERNEL::Exception(oss.str());
7884         }
7885       ts[i]=ret1;
7886     }
7887   for(std::size_t i=0;i<sz;i++)
7888     for(std::size_t j=0;j<sz2;j++)
7889       ret[i]->_time_steps[j]=ts[j][i];
7890   return ret;
7891 }
7892
7893 /*!
7894  * This method splits into discretization each time steps in \a this.
7895  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7896  */
7897 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7898 {
7899   std::size_t sz(_time_steps.size());
7900   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7901   for(std::size_t i=0;i<sz;i++)
7902     {
7903       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7904       if(!timeStep)
7905         {
7906           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7907           throw INTERP_KERNEL::Exception(oss.str());
7908         }
7909       items[i]=timeStep->splitDiscretizations();  
7910     }
7911   //
7912   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7913   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7914   std::vector< TypeOfField > types;
7915   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7916     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7917       {
7918         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7919         if(ts.size()!=1)
7920           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7921         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7922         if(it2==types.end())
7923           types.push_back(ts[0]);
7924       }
7925   ret.resize(types.size()); ret2.resize(types.size());
7926   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7927     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7928       {
7929         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7930         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7931         ret2[pos].push_back(*it1);
7932       }
7933   for(std::size_t i=0;i<types.size();i++)
7934     {
7935       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7936       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7937         elt->pushBackTimeStep(*it1);//also updates infos in elt
7938       ret[i]=elt;
7939       elt->MEDFileFieldNameScope::operator=(*this);
7940     }
7941   return ret;
7942 }
7943
7944 /*!
7945  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7946  */
7947 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7948 {
7949   std::size_t sz(_time_steps.size());
7950   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7951   std::size_t szOut(std::numeric_limits<std::size_t>::max());
7952   for(std::size_t i=0;i<sz;i++)
7953     {
7954       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7955       if(!timeStep)
7956         {
7957           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7958           throw INTERP_KERNEL::Exception(oss.str());
7959         }
7960       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7961       if(szOut==std::numeric_limits<std::size_t>::max())
7962         szOut=items[i].size();
7963       else
7964         if(items[i].size()!=szOut)
7965           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7966     }
7967   if(szOut==std::numeric_limits<std::size_t>::max())
7968     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7969   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7970   for(std::size_t i=0;i<szOut;i++)
7971     {
7972       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7973       for(std::size_t j=0;j<sz;j++)
7974         elt->pushBackTimeStep(items[j][i]);
7975       ret[i]=elt;
7976       elt->MEDFileFieldNameScope::operator=(*this);
7977     }
7978   return ret;
7979 }
7980
7981 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7982 {
7983   _name=field->getName();
7984   if(_name.empty())
7985     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7986   if(!arr)
7987     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7988   _infos=arr->getInfoOnComponents();
7989 }
7990
7991 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7992 {
7993   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7994   if(_name!=field->getName())
7995     {
7996       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7997       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7998       throw INTERP_KERNEL::Exception(oss.str());
7999     }
8000   if(!arr)
8001     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8002   checkThatComponentsMatch(arr->getInfoOnComponents());
8003 }
8004
8005 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8006 {
8007   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8008   if(getInfo().size()!=compos.size())
8009     {
8010       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8011       oss << " number of components of element to append (" << compos.size() << ") !";
8012       throw INTERP_KERNEL::Exception(oss.str());
8013     }
8014   if(_infos!=compos)
8015     {
8016       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8017       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8018       oss << " But compo in input fields are : ";
8019       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8020       oss << " !";
8021       throw INTERP_KERNEL::Exception(oss.str());
8022     }
8023 }
8024
8025 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8026 {
8027   std::size_t sz=_infos.size();
8028   int j=0;
8029   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8030     {
8031       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8032       if(elt)
8033         if(elt->getInfo().size()!=sz)
8034           {
8035             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8036             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8037             throw INTERP_KERNEL::Exception(oss.str());
8038           }
8039     }
8040 }
8041
8042 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8043 {
8044   if(!field)
8045     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8046   if(!_time_steps.empty())
8047     checkCoherencyOfTinyInfo(field,arr);
8048   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8049   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8050   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8051   copyTinyInfoFrom(field,arr);
8052   _time_steps.push_back(obj);
8053 }
8054
8055 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8056 {
8057   if(!field)
8058     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8059   if(!_time_steps.empty())
8060     checkCoherencyOfTinyInfo(field,arr);
8061   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8062   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8063   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8064   copyTinyInfoFrom(field,arr);
8065   _time_steps.push_back(obj);
8066 }
8067
8068 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8069 {
8070   int sz=(int)_time_steps.size();
8071   if(i<0 || i>=sz)
8072     {
8073       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8074       throw INTERP_KERNEL::Exception(oss.str());
8075     }
8076   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8077   if(tsPtr)
8078     {
8079       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8080         {
8081           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8082           throw INTERP_KERNEL::Exception(oss.str());
8083         }
8084     }
8085   _time_steps[i]=ts;
8086 }
8087
8088 //= MEDFileFieldMultiTSWithoutSDA
8089
8090 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)
8091 {
8092   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8093 }
8094
8095 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8096 {
8097 }
8098
8099 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8100 {
8101 }
8102
8103 /*!
8104  * \param [in] fieldId field id in C mode
8105  */
8106 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8107 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8108 {
8109 }
8110 catch(INTERP_KERNEL::Exception& e)
8111 { throw e; }
8112
8113 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)
8114 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8115 {
8116 }
8117 catch(INTERP_KERNEL::Exception& e)
8118 { throw e; }
8119
8120 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8121 {
8122   return new MEDFileField1TSWithoutSDA;
8123 }
8124
8125 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8126 {
8127   if(!f1ts)
8128     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8129   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8130   if(!f1tsC)
8131     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8132 }
8133
8134 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8135 {
8136   return MEDFileField1TSWithoutSDA::TYPE_STR;
8137 }
8138
8139 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8140 {
8141   return new MEDFileFieldMultiTSWithoutSDA(*this);
8142 }
8143
8144 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8145 {
8146   return new MEDFileFieldMultiTSWithoutSDA;
8147 }
8148
8149 /*!
8150  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8151  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8152  */
8153 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
8154 {
8155   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8156   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8157   if(!myF1TSC)
8158     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8159   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8160 }
8161
8162 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8163 {
8164   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8165   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8166   int i=0;
8167   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8168     {
8169       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8170       if(eltToConv)
8171         {
8172           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8173           if(!eltToConvC)
8174             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8175           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8176           ret->setIteration(i,elt);
8177         }
8178     }
8179   return ret.retn();
8180 }
8181
8182 //= MEDFileAnyTypeFieldMultiTS
8183
8184 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8185 {
8186 }
8187
8188 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8189 try:MEDFileFieldGlobsReal(fid)
8190 {
8191   _content=BuildContentFrom(fid,loadAll,ms);
8192   loadGlobals(fid);
8193 }
8194 catch(INTERP_KERNEL::Exception& e)
8195 {
8196     throw e;
8197 }
8198
8199 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8200 {
8201   med_field_type typcha;
8202   std::vector<std::string> infos;
8203   std::string dtunit;
8204   int i(-1);
8205   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8206   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8207   switch(typcha)
8208   {
8209     case MED_FLOAT64:
8210       {
8211         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8212         break;
8213       }
8214     case MED_INT32:
8215       {
8216         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8217         break;
8218       }
8219     default:
8220       {
8221         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] !";
8222         throw INTERP_KERNEL::Exception(oss.str());
8223       }
8224   }
8225   ret->setDtUnit(dtunit.c_str());
8226   return ret.retn();
8227 }
8228
8229 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8230 {
8231   med_field_type typcha;
8232   //
8233   std::vector<std::string> infos;
8234   std::string dtunit,fieldName;
8235   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8236   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8237   switch(typcha)
8238   {
8239     case MED_FLOAT64:
8240       {
8241         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8242         break;
8243       }
8244     case MED_INT32:
8245       {
8246         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8247         break;
8248       }
8249     default:
8250       {
8251         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] !";
8252         throw INTERP_KERNEL::Exception(oss.str());
8253       }
8254   }
8255   ret->setDtUnit(dtunit.c_str());
8256   return ret.retn();
8257 }
8258
8259 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8260 {
8261   if(!c)
8262     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8263   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8264     {
8265       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8266       ret->_content=c;  c->incrRef();
8267       return ret.retn();
8268     }
8269   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8270     {
8271       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8272       ret->_content=c;  c->incrRef();
8273       return ret.retn();
8274     }
8275   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8276 }
8277
8278 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8279 {
8280   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8281   std::string fileName(FileNameFromFID(fid));
8282   ret->setFileName(fileName);
8283   return ret;
8284 }
8285
8286 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8287 try:MEDFileFieldGlobsReal(fid)
8288 {
8289   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8290   loadGlobals(fid);
8291 }
8292 catch(INTERP_KERNEL::Exception& e)
8293 {
8294     throw e;
8295 }
8296
8297 //= MEDFileIntFieldMultiTSWithoutSDA
8298
8299 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)
8300 {
8301   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8302 }
8303
8304 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8305 {
8306 }
8307
8308 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8309 {
8310 }
8311
8312 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)
8313 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8314 {
8315 }
8316 catch(INTERP_KERNEL::Exception& e)
8317 { throw e; }
8318
8319 /*!
8320  * \param [in] fieldId field id in C mode
8321  */
8322 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8323 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8324 {
8325 }
8326 catch(INTERP_KERNEL::Exception& e)
8327 { throw e; }
8328
8329 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8330 {
8331   return new MEDFileIntField1TSWithoutSDA;
8332 }
8333
8334 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8335 {
8336   if(!f1ts)
8337     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8338   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8339   if(!f1tsC)
8340     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8341 }
8342
8343 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8344 {
8345   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8346 }
8347
8348 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8349 {
8350   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8351 }
8352
8353 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8354 {
8355   return new MEDFileIntFieldMultiTSWithoutSDA;
8356 }
8357
8358 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8359 {
8360   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8361   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8362   int i=0;
8363   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8364     {
8365       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8366       if(eltToConv)
8367         {
8368           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8369           if(!eltToConvC)
8370             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8371           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8372           ret->setIteration(i,elt);
8373         }
8374     }
8375   return ret.retn();
8376 }
8377
8378 //= MEDFileAnyTypeFieldMultiTS
8379
8380 /*!
8381  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8382  * that has been read from a specified MED file.
8383  *  \param [in] fileName - the name of the MED file to read.
8384  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8385  *          is to delete this field using decrRef() as it is no more needed.
8386  *  \throw If reading the file fails.
8387  */
8388 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8389 {
8390   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8391   return New(fid,loadAll);
8392 }
8393
8394 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8395 {
8396   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8397   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8398   ret->loadGlobals(fid);
8399   return ret.retn();
8400 }
8401
8402 /*!
8403  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8404  * that has been read from a specified MED file.
8405  *  \param [in] fileName - the name of the MED file to read.
8406  *  \param [in] fieldName - the name of the field to read.
8407  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8408  *          is to delete this field using decrRef() as it is no more needed.
8409  *  \throw If reading the file fails.
8410  *  \throw If there is no field named \a fieldName in the file.
8411  */
8412 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8413 {
8414   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8415   return New(fid,fieldName,loadAll);
8416 }
8417
8418 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8419 {
8420   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8421   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8422   ret->loadGlobals(fid);
8423   return ret.retn();
8424 }
8425
8426 /*!
8427  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8428  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8429  *
8430  * \warning this is a shallow copy constructor
8431  */
8432 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8433 {
8434   if(!shallowCopyOfContent)
8435     {
8436       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8437       otherPtr->incrRef();
8438       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8439     }
8440   else
8441     {
8442       _content=other.shallowCpy();
8443     }
8444 }
8445
8446 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8447 {
8448   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8449   if(!ret)
8450     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8451   return ret;
8452 }
8453
8454 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8455 {
8456   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8457   if(!ret)
8458     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8459   return ret;
8460 }
8461
8462 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8463 {
8464   return contentNotNullBase()->getPflsReallyUsed2();
8465 }
8466
8467 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8468 {
8469   return contentNotNullBase()->getLocsReallyUsed2();
8470 }
8471
8472 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8473 {
8474   return contentNotNullBase()->getPflsReallyUsedMulti2();
8475 }
8476
8477 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8478 {
8479   return contentNotNullBase()->getLocsReallyUsedMulti2();
8480 }
8481
8482 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8483 {
8484   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8485 }
8486
8487 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8488 {
8489   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8490 }
8491
8492 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8493 {
8494   return contentNotNullBase()->getNumberOfTS();
8495 }
8496
8497 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8498 {
8499   contentNotNullBase()->eraseEmptyTS();
8500 }
8501
8502 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8503 {
8504   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8505 }
8506
8507 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8508 {
8509   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8510 }
8511
8512 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8513 {
8514   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8515   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8516   ret->_content=c;
8517   return ret.retn();
8518 }
8519
8520 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8521 {
8522   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8523   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8524   ret->_content=c;
8525   return ret.retn();
8526 }
8527
8528 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8529 {
8530   return contentNotNullBase()->getIterations();
8531 }
8532
8533 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8534 {
8535   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8536     pushBackTimeStep(*it);
8537 }
8538
8539 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8540 {
8541   if(!fmts)
8542     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8543   int nbOfTS(fmts->getNumberOfTS());
8544   for(int i=0;i<nbOfTS;i++)
8545     {
8546       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8547       pushBackTimeStep(elt);
8548     }
8549 }
8550
8551 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8552 {
8553   if(!f1ts)
8554     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8555   checkCoherencyOfType(f1ts);
8556   f1ts->incrRef();
8557   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8558   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8559   c->incrRef();
8560   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8561   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8562     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8563   _content->pushBackTimeStep(cSafe);
8564   appendGlobs(*f1ts,1e-12);
8565 }
8566
8567 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8568 {
8569   contentNotNullBase()->synchronizeNameScope();
8570 }
8571
8572 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8573 {
8574   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8575 }
8576
8577 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8578 {
8579   return contentNotNullBase()->getPosGivenTime(time,eps);
8580 }
8581
8582 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8583 {
8584   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8585 }
8586
8587 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8588 {
8589   return contentNotNullBase()->getTypesOfFieldAvailable();
8590 }
8591
8592 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
8593 {
8594   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8595 }
8596
8597 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8598 {
8599   return contentNotNullBase()->getName();
8600 }
8601
8602 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8603 {
8604   contentNotNullBase()->setName(name);
8605 }
8606
8607 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8608 {
8609   return contentNotNullBase()->getDtUnit();
8610 }
8611
8612 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8613 {
8614   contentNotNullBase()->setDtUnit(dtUnit);
8615 }
8616
8617 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8618 {
8619   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8620 }
8621
8622 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8623 {
8624   return contentNotNullBase()->getTimeSteps(ret1);
8625 }
8626
8627 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8628 {
8629   return contentNotNullBase()->getMeshName();
8630 }
8631
8632 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8633 {
8634   contentNotNullBase()->setMeshName(newMeshName);
8635 }
8636
8637 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8638 {
8639   return contentNotNullBase()->changeMeshNames(modifTab);
8640 }
8641
8642 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8643 {
8644   return contentNotNullBase()->getInfo();
8645 }
8646
8647 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8648 {
8649   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8650 }
8651
8652 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8653 {
8654   return contentNotNullBase()->setInfo(info);
8655 }
8656
8657 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8658 {
8659   const std::vector<std::string> ret=getInfo();
8660   return (int)ret.size();
8661 }
8662
8663 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8664 {
8665   writeGlobals(fid,*this);
8666   contentNotNullBase()->writeLL(fid,*this);
8667 }
8668
8669 /*!
8670  * This method alloc the arrays and load potentially huge arrays contained in this field.
8671  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8672  * This method can be also called to refresh or reinit values from a file.
8673  * 
8674  * \throw If the fileName is not set or points to a non readable MED file.
8675  */
8676 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8677 {
8678   if(getFileName().empty())
8679     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8680   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8681   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8682 }
8683
8684 /*!
8685  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8686  * But once data loaded once, this method does nothing.
8687  * 
8688  * \throw If the fileName is not set or points to a non readable MED file.
8689  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8690  */
8691 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8692 {
8693   if(!getFileName().empty())
8694     {
8695       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8696       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8697     }
8698 }
8699
8700 /*!
8701  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8702  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8703  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8704  * 
8705  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8706  */
8707 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8708 {
8709   contentNotNullBase()->unloadArrays();
8710 }
8711
8712 /*!
8713  * 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.
8714  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8715  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8716  * 
8717  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8718  */
8719 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8720 {
8721   if(!getFileName().empty())
8722     contentNotNullBase()->unloadArrays();
8723 }
8724
8725 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8726 {
8727   std::ostringstream oss;
8728   contentNotNullBase()->simpleRepr(0,oss,-1);
8729   simpleReprGlobs(oss);
8730   return oss.str();
8731 }
8732
8733 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8734 {
8735   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8736 }
8737
8738 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8739 {
8740   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8741   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8742   return ret;
8743 }
8744
8745 /*!
8746  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8747  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8748  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8749  */
8750 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8751 {
8752   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8753   if(!content)
8754     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8755   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8756   std::size_t sz(contentsSplit.size());
8757   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8758   for(std::size_t i=0;i<sz;i++)
8759     {
8760       ret[i]=shallowCpy();
8761       ret[i]->_content=contentsSplit[i];
8762     }
8763   return ret;
8764 }
8765
8766 /*!
8767  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8768  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8769  */
8770 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8771 {
8772   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8773   if(!content)
8774     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8775   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8776   std::size_t sz(contentsSplit.size());
8777   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8778   for(std::size_t i=0;i<sz;i++)
8779     {
8780       ret[i]=shallowCpy();
8781       ret[i]->_content=contentsSplit[i];
8782     }
8783   return ret;
8784 }
8785
8786 /*!
8787  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8788  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8789  */
8790 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8791 {
8792   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8793   if(!content)
8794     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8795   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8796   std::size_t sz(contentsSplit.size());
8797   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8798   for(std::size_t i=0;i<sz;i++)
8799     {
8800       ret[i]=shallowCpy();
8801       ret[i]->_content=contentsSplit[i];
8802     }
8803   return ret;
8804 }
8805
8806 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8807 {
8808   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8809   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8810     ret->_content=_content->deepCopy();
8811   ret->deepCpyGlobs(*this);
8812   return ret.retn();
8813 }
8814
8815 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8816 {
8817   return _content;
8818 }
8819
8820 /*!
8821  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8822  *  \param [in] iteration - the iteration number of a required time step.
8823  *  \param [in] order - the iteration order number of required time step.
8824  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8825  *          delete this field using decrRef() as it is no more needed.
8826  *  \throw If there is no required time step in \a this field.
8827  */
8828 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8829 {
8830   int pos=getPosOfTimeStep(iteration,order);
8831   return getTimeStepAtPos(pos);
8832 }
8833
8834 /*!
8835  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8836  *  \param [in] time - the time of the time step of interest.
8837  *  \param [in] eps - a precision used to compare time values.
8838  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8839  *          delete this field using decrRef() as it is no more needed.
8840  *  \throw If there is no required time step in \a this field.
8841  */
8842 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8843 {
8844   int pos=getPosGivenTime(time,eps);
8845   return getTimeStepAtPos(pos);
8846 }
8847
8848 /*!
8849  * 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.
8850  * The float64 value of time attached to the pair of integers are not considered here.
8851  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8852  *
8853  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8854  * \throw If there is a null pointer in \a vectFMTS.
8855  */
8856 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8857 {
8858   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8859   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8860   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8861   while(!lstFMTS.empty())
8862     {
8863       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8864       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8865       if(!curIt)
8866         throw INTERP_KERNEL::Exception(msg);
8867       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8868       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8869       elt.push_back(curIt); it=lstFMTS.erase(it);
8870       while(it!=lstFMTS.end())
8871         {
8872           curIt=*it;
8873           if(!curIt)
8874             throw INTERP_KERNEL::Exception(msg);
8875           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8876           if(refIts==curIts)
8877             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8878           else
8879             it++;
8880         }
8881       ret.push_back(elt);
8882     }
8883   return ret;
8884 }
8885
8886 /*!
8887  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8888  * All returned instances in a subvector can be safely loaded, rendered along time
8889  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8890  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8891  * 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).
8892  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8893  * 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.
8894  *
8895  * \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().
8896  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8897  * \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.
8898  * \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.
8899  *
8900  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8901  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8902  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8903  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8904  * \throw If mesh is null.
8905  * \throw If an element in \a vectFMTS is null.
8906  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8907  */
8908 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8909 {
8910   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8911   if(!mesh)
8912     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8913   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8914   if(vectFMTS.empty())
8915     return ret;
8916   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8917   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8918   if(!frstElt)
8919     throw INTERP_KERNEL::Exception(msg);
8920   std::size_t i=0;
8921   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8922   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8923   for(;it!=vectFMTS.end();it++,i++)
8924     {
8925       if(!(*it))
8926         throw INTERP_KERNEL::Exception(msg);
8927       TypeOfField tof0,tof1;
8928       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8929         {
8930           if(tof1!=ON_NODES)
8931             vectFMTSNotNodes.push_back(*it);
8932           else
8933             vectFMTSNodes.push_back(*it);
8934         }
8935       else
8936         vectFMTSNotNodes.push_back(*it);
8937     }
8938   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8939   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8940   ret=retCell;
8941   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8942     {
8943       i=0;
8944       bool isFetched(false);
8945       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8946         {
8947           if((*it0).empty())
8948             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8949           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8950             { ret[i].push_back(*it2); isFetched=true; }
8951         }
8952       if(!isFetched)
8953         {
8954           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8955           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8956           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8957         }
8958     }
8959   fsc=cmps;
8960   return ret;
8961 }
8962
8963 /*!
8964  * 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.
8965  * \param [out] cmps - same size than the returned vector.
8966  */
8967 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8968 {
8969   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8970   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8971   while(!lstFMTS.empty())
8972     {
8973       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8974       MEDFileAnyTypeFieldMultiTS *ref(*it);
8975       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8976       elt.push_back(ref); it=lstFMTS.erase(it);
8977       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8978       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8979       while(it!=lstFMTS.end())
8980         {
8981           MEDFileAnyTypeFieldMultiTS *curIt(*it);
8982           if(cmp->isEqual(curIt))
8983             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8984           else
8985             it++;
8986         }
8987       ret.push_back(elt); cmps.push_back(cmp);
8988     }
8989   return ret;
8990 }
8991
8992 /*!
8993  * 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.
8994  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8995  *
8996  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8997  * \throw If \a f0 or \a f1 change of spatial discretization along time.
8998  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8999  * \thorw If \a f0 and \a f1 do not have the same times steps.
9000  * \throw If mesh is null.
9001  * \throw If \a f0 or \a f1 is null.
9002  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9003  */
9004 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9005 {
9006   if(!mesh)
9007     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9008   if(!f0 || !f1)
9009     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9010   if(f0->getMeshName()!=mesh->getName())
9011     {
9012       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9013       throw INTERP_KERNEL::Exception(oss.str());
9014     }
9015   if(f1->getMeshName()!=mesh->getName())
9016     {
9017       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9018       throw INTERP_KERNEL::Exception(oss.str());
9019     }
9020   int nts=f0->getNumberOfTS();
9021   if(nts!=f1->getNumberOfTS())
9022     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9023   if(nts==0)
9024     return nts;
9025   for(int i=0;i<nts;i++)
9026     {
9027       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9028       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9029       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9030       if(tofs0.size()!=1 || tofs1.size()!=1)
9031         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9032       if(i!=0)
9033         {
9034           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9035             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9036         }
9037       else
9038         { tof0=tofs0[0]; tof1=tofs1[0]; }
9039       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9040         {
9041           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() << ") !";
9042           throw INTERP_KERNEL::Exception(oss.str());
9043         }
9044       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9045         {
9046           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() << ") !";
9047           throw INTERP_KERNEL::Exception(oss.str());
9048         }
9049       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9050         {
9051           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() << ") !";
9052           throw INTERP_KERNEL::Exception(oss.str());
9053         }
9054     }
9055   return nts;
9056 }
9057
9058 /*!
9059  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9060  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9061  *
9062  * \return A new object that the caller is responsible to deallocate.
9063  */
9064 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9065 {
9066   if(!mm)
9067     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9068   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9069   int nbTS(getNumberOfTS());
9070   for(int i=0;i<nbTS;i++)
9071     {
9072       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9073       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9074       fmtsOut->pushBackTimeStep(f1tsOut);
9075     }
9076   return fmtsOut.retn();
9077 }
9078
9079 template<class T>
9080 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9081 {
9082   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9083   if(f1tss.empty())
9084     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9085   std::size_t sz(f1tss.size()),i(0);
9086   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9087   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9088     {
9089       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9090       if(!elt)
9091         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9092       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9093     }
9094   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9095   if(!retc)
9096     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9097   retc->aggregate(f1tsw,dts);
9098   ret->setDtUnit(f1tss[0]->getDtUnit());
9099   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9100 }
9101
9102 template<class T>
9103 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9104 {
9105   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9106   if(fmtss.empty())
9107     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9108   std::size_t sz(fmtss.size());
9109   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9110     {
9111       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9112       if(!elt)
9113         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9114     }
9115   int nbTS(fmtss[0]->getNumberOfTS());
9116   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9117     if((*it)->getNumberOfTS()!=nbTS)
9118       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9119   for(int iterTS=0;iterTS<nbTS;iterTS++)
9120     {
9121       std::size_t i(0);
9122       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9123       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9124       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9125         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9126       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9127       ret->pushBackTimeStep(f1ts);
9128       ret->setDtUnit(f1ts->getDtUnit());
9129     }
9130   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9131 }
9132
9133 /*!
9134  * \a dts and \a ftmss are expected to have same size.
9135  */
9136 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9137 {
9138   if(fmtss.empty())
9139     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9140   std::size_t sz(fmtss.size());
9141   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9142   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9143   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9144     {
9145       if(!(*it))
9146         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9147       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9148       if(elt1)
9149         {
9150           fmtss1.push_back(elt1);
9151           continue;
9152         }
9153       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9154       if(elt2)
9155         {
9156           fmtss2.push_back(elt2);
9157           continue;
9158         }
9159       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9160     }
9161   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9162     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9163   if(fmtss1.size()==sz)
9164     return AggregateHelperFMTS<double>(fmtss1,dts);
9165   if(fmtss2.size()!=sz)
9166     return AggregateHelperFMTS<int>(fmtss2,dts);
9167   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9168 }
9169
9170 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9171 {
9172   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9173 }
9174
9175 //= MEDFileFieldMultiTS
9176
9177 /*!
9178  * Returns a new empty instance of MEDFileFieldMultiTS.
9179  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9180  *          is to delete this field using decrRef() as it is no more needed.
9181  */
9182 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9183 {
9184   return new MEDFileFieldMultiTS;
9185 }
9186
9187 /*!
9188  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9189  * that has been read from a specified MED file.
9190  *  \param [in] fileName - the name of the MED file to read.
9191  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9192  *          is to delete this field using decrRef() as it is no more needed.
9193  *  \throw If reading the file fails.
9194  */
9195 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9196 {
9197   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9198   return New(fid,loadAll);
9199 }
9200
9201 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9202 {
9203   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9204   ret->contentNotNull();//to check that content type matches with \a this type.
9205   return ret.retn();
9206 }
9207
9208 /*!
9209  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9210  * that has been read from a specified MED file.
9211  *  \param [in] fileName - the name of the MED file to read.
9212  *  \param [in] fieldName - the name of the field to read.
9213  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9214  *          is to delete this field using decrRef() as it is no more needed.
9215  *  \throw If reading the file fails.
9216  *  \throw If there is no field named \a fieldName in the file.
9217  */
9218 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9219 {
9220   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9221   return New(fid,fieldName,loadAll);
9222 }
9223
9224 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9225 {
9226   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9227   ret->contentNotNull();//to check that content type matches with \a this type.
9228   return ret.retn();
9229 }
9230
9231 /*!
9232  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9233  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9234  *
9235  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9236  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9237  * \warning this is a shallow copy constructor
9238  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9239  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9240  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9241  *          is to delete this field using decrRef() as it is no more needed.
9242  */
9243 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9244 {
9245   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9246 }
9247
9248 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9249 {
9250   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9251   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9252   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9253   ret->contentNotNull();//to check that content type matches with \a this type.
9254   return ret.retn();
9255 }
9256
9257 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9258 {
9259   return new MEDFileFieldMultiTS(*this);
9260 }
9261
9262 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9263 {
9264   if(!f1ts)
9265     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9266   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9267   if(!f1tsC)
9268     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9269 }
9270
9271 /*!
9272  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9273  * following the given input policy.
9274  *
9275  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9276  *                            By default (true) the globals are deeply copied.
9277  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9278  */
9279 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9280 {
9281   MCAuto<MEDFileIntFieldMultiTS> ret;
9282   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9283   if(content)
9284     {
9285       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9286       if(!contc)
9287         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9288       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9289       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9290     }
9291   else
9292     ret=MEDFileIntFieldMultiTS::New();
9293   if(isDeepCpyGlobs)
9294     ret->deepCpyGlobs(*this);
9295   else
9296     ret->shallowCpyGlobs(*this);
9297   return ret.retn();
9298 }
9299
9300 /*!
9301  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9302  *  \param [in] pos - a time step id.
9303  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9304  *          delete this field using decrRef() as it is no more needed.
9305  *  \throw If \a pos is not a valid time step id.
9306  */
9307 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9308 {
9309   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9310   if(!item)
9311     {
9312       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9313       throw INTERP_KERNEL::Exception(oss.str());
9314     }
9315   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9316   if(itemC)
9317     {
9318       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9319       ret->shallowCpyGlobs(*this);
9320       return ret.retn();
9321     }
9322   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9323   throw INTERP_KERNEL::Exception(oss.str());
9324 }
9325
9326 /*!
9327  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9328  * mesh entities of a given dimension of the first mesh in MED file.
9329  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9330  *  \param [in] type - a spatial discretization of interest.
9331  *  \param [in] iteration - the iteration number of a required time step.
9332  *  \param [in] order - the iteration order number of required time step.
9333  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9334  *  \param [in] renumPol - specifies how to permute values of the result field according to
9335  *          the optional numbers of cells and nodes, if any. The valid values are
9336  *          - 0 - do not permute.
9337  *          - 1 - permute cells.
9338  *          - 2 - permute nodes.
9339  *          - 3 - permute cells and nodes.
9340  *
9341  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9342  *          caller is to delete this field using decrRef() as it is no more needed. 
9343  *  \throw If the MED file is not readable.
9344  *  \throw If there is no mesh in the MED file.
9345  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9346  *  \throw If no field values of the required parameters are available.
9347  */
9348 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9349 {
9350   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9351   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9352   if(!myF1TSC)
9353     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9354   MCAuto<DataArray> arrOut;
9355   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9356   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9357   return ret.retn();
9358 }
9359
9360 /*!
9361  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9362  * the top level cells of the first mesh in MED file.
9363  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9364  *  \param [in] type - a spatial discretization of interest.
9365  *  \param [in] iteration - the iteration number of a required time step.
9366  *  \param [in] order - the iteration order number of required time step.
9367  *  \param [in] renumPol - specifies how to permute values of the result field according to
9368  *          the optional numbers of cells and nodes, if any. The valid values are
9369  *          - 0 - do not permute.
9370  *          - 1 - permute cells.
9371  *          - 2 - permute nodes.
9372  *          - 3 - permute cells and nodes.
9373  *
9374  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9375  *          caller is to delete this field using decrRef() as it is no more needed. 
9376  *  \throw If the MED file is not readable.
9377  *  \throw If there is no mesh in the MED file.
9378  *  \throw If no field values of the required parameters are available.
9379  */
9380 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9381 {
9382   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9383   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9384   if(!myF1TSC)
9385     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9386   MCAuto<DataArray> arrOut;
9387   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9388   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9389   return ret.retn();
9390 }
9391
9392 /*!
9393  * 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
9394  * method should be called (getFieldOnMeshAtLevel for example).
9395  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9396  *
9397  * \param [in] iteration - the iteration number of a required time step.
9398  * \param [in] order - the iteration order number of required time step.
9399  * \param [in] mesh - the mesh the field is lying on
9400  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9401  *          caller is to delete this field using decrRef() as it is no more needed. 
9402  */
9403 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9404 {
9405   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9406   MCAuto<DataArray> arrOut;
9407   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9408   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9409   return ret.retn();
9410 }
9411
9412 /*!
9413  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9414  * a given support.
9415  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9416  *  \param [in] type - a spatial discretization of interest.
9417  *  \param [in] iteration - the iteration number of a required time step.
9418  *  \param [in] order - the iteration order number of required time step.
9419  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9420  *  \param [in] mesh - the supporting mesh.
9421  *  \param [in] renumPol - specifies how to permute values of the result field according to
9422  *          the optional numbers of cells and nodes, if any. The valid values are
9423  *          - 0 - do not permute.
9424  *          - 1 - permute cells.
9425  *          - 2 - permute nodes.
9426  *          - 3 - permute cells and nodes.
9427  *
9428  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9429  *          caller is to delete this field using decrRef() as it is no more needed. 
9430  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9431  *  \throw If no field of \a this is lying on \a mesh.
9432  *  \throw If no field values of the required parameters are available.
9433  */
9434 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9435 {
9436   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9437   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9438   if(!myF1TSC)
9439     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9440   MCAuto<DataArray> arrOut;
9441   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9442   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9443   return ret.retn();
9444 }
9445
9446 /*!
9447  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9448  * given support. 
9449  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9450  *  \param [in] type - a spatial discretization of the new field.
9451  *  \param [in] iteration - the iteration number of a required time step.
9452  *  \param [in] order - the iteration order number of required time step.
9453  *  \param [in] mesh - the supporting mesh.
9454  *  \param [in] renumPol - specifies how to permute values of the result field according to
9455  *          the optional numbers of cells and nodes, if any. The valid values are
9456  *          - 0 - do not permute.
9457  *          - 1 - permute cells.
9458  *          - 2 - permute nodes.
9459  *          - 3 - permute cells and nodes.
9460  *
9461  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9462  *          caller is to delete this field using decrRef() as it is no more needed. 
9463  *  \throw If no field of \a this is lying on \a mesh.
9464  *  \throw If no field values of the required parameters are available.
9465  */
9466 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9467 {
9468   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9469   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9470   if(!myF1TSC)
9471     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9472   MCAuto<DataArray> arrOut;
9473   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9474   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9475   return ret.retn();
9476 }
9477
9478 /*!
9479  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9480  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9481  * This method is useful for MED2 file format when field on different mesh was autorized.
9482  */
9483 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9484 {
9485   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9486   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9487   if(!myF1TSC)
9488     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9489   MCAuto<DataArray> arrOut;
9490   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9491   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9492   return ret.retn();
9493 }
9494
9495 /*!
9496  * Returns values and a profile of the field of a given type, of a given time step,
9497  * lying on a given support.
9498  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9499  *  \param [in] type - a spatial discretization of the field.
9500  *  \param [in] iteration - the iteration number of a required time step.
9501  *  \param [in] order - the iteration order number of required time step.
9502  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9503  *  \param [in] mesh - the supporting mesh.
9504  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9505  *          field of interest lies on. If the field lies on all entities of the given
9506  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9507  *          using decrRef() as it is no more needed.  
9508  *  \param [in] glob - the global data storing profiles and localization.
9509  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9510  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9511  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9512  *  \throw If no field of \a this is lying on \a mesh.
9513  *  \throw If no field values of the required parameters are available.
9514  */
9515 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9516 {
9517   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9518   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9519   if(!myF1TSC)
9520     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9521   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9522   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9523 }
9524
9525 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9526 {
9527   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9528   if(!pt)
9529     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9530   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9531   if(!ret)
9532     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 !");
9533   return ret;
9534 }
9535
9536 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9537 {
9538   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9539   if(!pt)
9540     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9541   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9542   if(!ret)
9543     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 !");
9544   return ret;
9545 }
9546
9547 /*!
9548  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9549  * the given field is checked if its elements are sorted suitable for writing to MED file
9550  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9551  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9552  *  \param [in] field - the field to add to \a this.
9553  *  \throw If the name of \a field is empty.
9554  *  \throw If the data array of \a field is not set.
9555  *  \throw If existing time steps have different name or number of components than \a field.
9556  *  \throw If the underlying mesh of \a field has no name.
9557  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9558  */
9559 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9560 {
9561   const DataArrayDouble *arr=0;
9562   if(field)
9563     arr=field->getArray();
9564   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9565 }
9566
9567 /*!
9568  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9569  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9570  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9571  * and \a profile.
9572  *
9573  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9574  * A new profile is added only if no equal profile is missing.
9575  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9576  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9577  *  \param [in] mesh - the supporting mesh of \a field.
9578  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9579  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9580  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9581  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9582  *  \throw If the data array of \a field is not set.
9583  *  \throw If the data array of \a this is already allocated but has different number of
9584  *         components than \a field.
9585  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9586  *  \sa setFieldNoProfileSBT()
9587  */
9588 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9589 {
9590   const DataArrayDouble *arr=0;
9591   if(field)
9592     arr=field->getArray();
9593   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9594 }
9595
9596 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9597 {
9598   _content=new MEDFileFieldMultiTSWithoutSDA;
9599 }
9600
9601 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9602 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9603 {
9604 }
9605 catch(INTERP_KERNEL::Exception& e)
9606 { throw e; }
9607
9608 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9609 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9610 {
9611 }
9612 catch(INTERP_KERNEL::Exception& e)
9613 { throw e; }
9614
9615 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9616 {
9617 }
9618
9619 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
9620 {
9621   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9622 }
9623
9624 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9625 {
9626   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9627 }
9628
9629 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9630 {
9631   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9632 }
9633
9634 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9635 {
9636   return MEDFileFieldMultiTS::New();
9637 }
9638
9639 //= MEDFileAnyTypeFieldMultiTSIterator
9640
9641 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9642 {
9643   if(fmts)
9644     {
9645       fmts->incrRef();
9646       _nb_iter=fmts->getNumberOfTS();
9647     }
9648 }
9649
9650 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9651 {
9652 }
9653
9654 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9655 {
9656   if(_iter_id<_nb_iter)
9657     {
9658       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9659       if(fmts)
9660         return fmts->getTimeStepAtPos(_iter_id++);
9661       else
9662         return 0;
9663     }
9664   else
9665     return 0;
9666 }
9667
9668 //= MEDFileIntFieldMultiTS
9669
9670 /*!
9671  * Returns a new empty instance of MEDFileFieldMultiTS.
9672  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9673  *          is to delete this field using decrRef() as it is no more needed.
9674  */
9675 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9676 {
9677   return new MEDFileIntFieldMultiTS;
9678 }
9679
9680 /*!
9681  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9682  * that has been read from a specified MED file.
9683  *  \param [in] fileName - the name of the MED file to read.
9684  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9685  *          is to delete this field using decrRef() as it is no more needed.
9686  *  \throw If reading the file fails.
9687  */
9688 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9689 {
9690   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9691   return New(fid,loadAll);
9692 }
9693
9694 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9695 {
9696   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9697   ret->contentNotNull();//to check that content type matches with \a this type.
9698   return ret.retn();
9699 }
9700
9701 /*!
9702  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9703  * that has been read from a specified MED file.
9704  *  \param [in] fileName - the name of the MED file to read.
9705  *  \param [in] fieldName - the name of the field to read.
9706  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9707  *          is to delete this field using decrRef() as it is no more needed.
9708  *  \throw If reading the file fails.
9709  *  \throw If there is no field named \a fieldName in the file.
9710  */
9711 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9712 {
9713   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9714   return New(fid,fieldName,loadAll);
9715 }
9716
9717 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9718 {
9719   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9720   ret->contentNotNull();//to check that content type matches with \a this type.
9721   return ret.retn();
9722 }
9723
9724 /*!
9725  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9726  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9727  *
9728  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9729  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9730  * \warning this is a shallow copy constructor
9731  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9732  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9733  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9734  *          is to delete this field using decrRef() as it is no more needed.
9735  */
9736 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9737 {
9738   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9739 }
9740
9741 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9742 {
9743   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9744   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9745   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9746   ret->contentNotNull();//to check that content type matches with \a this type.
9747   return ret.retn();
9748 }
9749
9750 /*!
9751  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9752  * following the given input policy.
9753  *
9754  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9755  *                            By default (true) the globals are deeply copied.
9756  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9757  */
9758 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9759 {
9760   MCAuto<MEDFileFieldMultiTS> ret;
9761   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9762   if(content)
9763     {
9764       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9765       if(!contc)
9766         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9767       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9768       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9769     }
9770   else
9771     ret=MEDFileFieldMultiTS::New();
9772   if(isDeepCpyGlobs)
9773     ret->deepCpyGlobs(*this);
9774   else
9775     ret->shallowCpyGlobs(*this);
9776   return ret.retn();
9777 }
9778
9779 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9780 {
9781   return new MEDFileIntFieldMultiTS(*this);
9782 }
9783
9784 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9785 {
9786   if(!f1ts)
9787     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9788   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9789   if(!f1tsC)
9790     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9791 }
9792
9793 /*!
9794  * 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
9795  * method should be called (getFieldOnMeshAtLevel for example).
9796  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9797  *
9798  * \param [in] iteration - the iteration number of a required time step.
9799  * \param [in] order - the iteration order number of required time step.
9800  * \param [in] mesh - the mesh the field is lying on
9801  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9802  *          caller is to delete this field using decrRef() as it is no more needed. 
9803  */
9804 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9805 {
9806   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9807   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9808   if(!myF1TSC)
9809     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9810   MCAuto<DataArray> arrOut;
9811   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9812   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9813   return ret2.retn();
9814 }
9815
9816 /*!
9817  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9818  * mesh entities of a given dimension of the first mesh in MED file.
9819  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9820  *  \param [in] type - a spatial discretization of interest.
9821  *  \param [in] iteration - the iteration number of a required time step.
9822  *  \param [in] order - the iteration order number of required time step.
9823  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9824  *  \param [in] renumPol - specifies how to permute values of the result field according to
9825  *          the optional numbers of cells and nodes, if any. The valid values are
9826  *          - 0 - do not permute.
9827  *          - 1 - permute cells.
9828  *          - 2 - permute nodes.
9829  *          - 3 - permute cells and nodes.
9830  *
9831  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9832  *          caller is to delete this field using decrRef() as it is no more needed. 
9833  *  \throw If the MED file is not readable.
9834  *  \throw If there is no mesh in the MED file.
9835  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9836  *  \throw If no field values of the required parameters are available.
9837  */
9838 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9839 {
9840   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9841   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9842   if(!myF1TSC)
9843     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9844   MCAuto<DataArray> arr;
9845   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9846   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9847   return ret2.retn();
9848 }
9849
9850 /*!
9851  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9852  * the top level cells of the first mesh in MED file.
9853  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9854  *  \param [in] type - a spatial discretization of interest.
9855  *  \param [in] iteration - the iteration number of a required time step.
9856  *  \param [in] order - the iteration order number of required time step.
9857  *  \param [in] renumPol - specifies how to permute values of the result field according to
9858  *          the optional numbers of cells and nodes, if any. The valid values are
9859  *          - 0 - do not permute.
9860  *          - 1 - permute cells.
9861  *          - 2 - permute nodes.
9862  *          - 3 - permute cells and nodes.
9863  *
9864  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9865  *          caller is to delete this field using decrRef() as it is no more needed. 
9866  *  \throw If the MED file is not readable.
9867  *  \throw If there is no mesh in the MED file.
9868  *  \throw If no field values of the required parameters are available.
9869  */
9870 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9871 {
9872   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9873   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9874   if(!myF1TSC)
9875     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9876   MCAuto<DataArray> arr;
9877   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9878   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9879   return ret2.retn();
9880 }
9881
9882 /*!
9883  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9884  * a given support.
9885  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9886  *  \param [in] type - a spatial discretization of interest.
9887  *  \param [in] iteration - the iteration number of a required time step.
9888  *  \param [in] order - the iteration order number of required time step.
9889  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9890  *  \param [in] mesh - the supporting mesh.
9891  *  \param [in] renumPol - specifies how to permute values of the result field according to
9892  *          the optional numbers of cells and nodes, if any. The valid values are
9893  *          - 0 - do not permute.
9894  *          - 1 - permute cells.
9895  *          - 2 - permute nodes.
9896  *          - 3 - permute cells and nodes.
9897  *
9898  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9899  *          caller is to delete this field using decrRef() as it is no more needed. 
9900  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9901  *  \throw If no field of \a this is lying on \a mesh.
9902  *  \throw If no field values of the required parameters are available.
9903  */
9904 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9905 {
9906   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9907   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9908   if(!myF1TSC)
9909     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9910   MCAuto<DataArray> arr;
9911   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9912   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9913   return ret2.retn();
9914 }
9915
9916 /*!
9917  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9918  * given support. 
9919  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9920  *  \param [in] type - a spatial discretization of the new field.
9921  *  \param [in] iteration - the iteration number of a required time step.
9922  *  \param [in] order - the iteration order number of required time step.
9923  *  \param [in] mesh - the supporting mesh.
9924  *  \param [out] arrOut - the DataArrayInt containing values of field.
9925  *  \param [in] renumPol - specifies how to permute values of the result field according to
9926  *          the optional numbers of cells and nodes, if any. The valid values are
9927  *          - 0 - do not permute.
9928  *          - 1 - permute cells.
9929  *          - 2 - permute nodes.
9930  *          - 3 - permute cells and nodes.
9931  *
9932  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9933  *          caller is to delete this field using decrRef() as it is no more needed. 
9934  *  \throw If no field of \a this is lying on \a mesh.
9935  *  \throw If no field values of the required parameters are available.
9936  */
9937 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9938 {
9939   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9940   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9941   if(!myF1TSC)
9942     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9943   MCAuto<DataArray> arr;
9944   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9945   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9946   return ret2.retn();
9947 }
9948
9949 /*!
9950  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9951  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9952  * This method is useful for MED2 file format when field on different mesh was autorized.
9953  */
9954 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9955 {
9956   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9957   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9958   if(!myF1TSC)
9959     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9960   MCAuto<DataArray> arr;
9961   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9962   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9963   return ret2.retn();
9964 }
9965
9966 /*!
9967  * Returns values and a profile of the field of a given type, of a given time step,
9968  * lying on a given support.
9969  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9970  *  \param [in] type - a spatial discretization of the field.
9971  *  \param [in] iteration - the iteration number of a required time step.
9972  *  \param [in] order - the iteration order number of required time step.
9973  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9974  *  \param [in] mesh - the supporting mesh.
9975  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9976  *          field of interest lies on. If the field lies on all entities of the given
9977  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9978  *          using decrRef() as it is no more needed.  
9979  *  \param [in] glob - the global data storing profiles and localization.
9980  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9981  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9982  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9983  *  \throw If no field of \a this is lying on \a mesh.
9984  *  \throw If no field values of the required parameters are available.
9985  */
9986 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9987 {
9988   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9989   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9990   if(!myF1TSC)
9991     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9992   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9993   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9994 }
9995
9996 /*!
9997  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9998  *  \param [in] pos - a time step id.
9999  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10000  *          delete this field using decrRef() as it is no more needed.
10001  *  \throw If \a pos is not a valid time step id.
10002  */
10003 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10004 {
10005   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10006   if(!item)
10007     {
10008       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10009       throw INTERP_KERNEL::Exception(oss.str());
10010     }
10011   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10012   if(itemC)
10013     {
10014       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10015       ret->shallowCpyGlobs(*this);
10016       return ret.retn();
10017     }
10018   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10019   throw INTERP_KERNEL::Exception(oss.str());
10020 }
10021
10022 /*!
10023  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10024  * the given field is checked if its elements are sorted suitable for writing to MED file
10025  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10026  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10027  *  \param [in] field - the field to add to \a this.
10028  *  \throw If the name of \a field is empty.
10029  *  \throw If the data array of \a field is not set.
10030  *  \throw If existing time steps have different name or number of components than \a field.
10031  *  \throw If the underlying mesh of \a field has no name.
10032  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10033  */
10034 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10035 {
10036   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10037   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10038 }
10039
10040 /*!
10041  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10042  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10043  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10044  * and \a profile.
10045  *
10046  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10047  * A new profile is added only if no equal profile is missing.
10048  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10049  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10050  *  \param [in] arrOfVals - the values of the field \a field used.
10051  *  \param [in] mesh - the supporting mesh of \a field.
10052  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10053  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10054  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10055  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10056  *  \throw If the data array of \a field is not set.
10057  *  \throw If the data array of \a this is already allocated but has different number of
10058  *         components than \a field.
10059  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10060  *  \sa setFieldNoProfileSBT()
10061  */
10062 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10063 {
10064   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10065   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10066 }
10067
10068 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10069 {
10070   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10071   if(!pt)
10072     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10073   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10074   if(!ret)
10075     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 !");
10076   return ret;
10077 }
10078
10079 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10080 {
10081   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10082   if(!pt)
10083     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10084   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10085   if(!ret)
10086     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 !");
10087   return ret;
10088 }
10089
10090 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10091 {
10092   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10093 }
10094
10095 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10096 {
10097 }
10098
10099 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10100 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10101 {
10102 }
10103 catch(INTERP_KERNEL::Exception& e)
10104 { throw e; }
10105
10106 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10107 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10108 {
10109 }
10110 catch(INTERP_KERNEL::Exception& e)
10111 { throw e; }
10112
10113 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10114 {
10115   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10116 }
10117
10118 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10119 {
10120   return MEDFileIntFieldMultiTS::New();
10121 }
10122
10123 //= MEDFileFields
10124
10125 MEDFileFields *MEDFileFields::New()
10126 {
10127   return new MEDFileFields;
10128 }
10129
10130 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10131 {
10132   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10133   return New(fid,loadAll);
10134 }
10135
10136 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10137 {
10138   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10139   if(!se)
10140     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10141   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10142   return new MEDFileFields(fid,loadAll,0,entities);
10143 }
10144
10145 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10146 {
10147   return new MEDFileFields(fid,loadAll,0,0);
10148 }
10149
10150 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10151 {
10152   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10153   return new MEDFileFields(fid,loadAll,ms,0);
10154 }
10155
10156 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10157 {
10158   MEDFileUtilities::CheckFileForRead(fileName);
10159   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10160   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10161   return new MEDFileFields(fid,loadAll,0,ent);
10162 }
10163
10164 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10165 {
10166   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10167   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10168   return ret;
10169 }
10170
10171 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10172 {
10173   std::vector<const BigMemoryObject *> ret;
10174   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10175     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10176   return ret;
10177 }
10178
10179 MEDFileFields *MEDFileFields::deepCopy() const
10180 {
10181   MCAuto<MEDFileFields> ret(shallowCpy());
10182   std::size_t i(0);
10183   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10184     {
10185       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10186         ret->_fields[i]=(*it)->deepCopy();
10187     }
10188   ret->deepCpyGlobs(*this);
10189   return ret.retn();
10190 }
10191
10192 MEDFileFields *MEDFileFields::shallowCpy() const
10193 {
10194   return new MEDFileFields(*this);
10195 }
10196
10197 /*!
10198  * 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
10199  * 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.
10200  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10201  *
10202  * \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.
10203  * \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.
10204  * 
10205  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10206  */
10207 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10208 {
10209   std::set< std::pair<int,int> > s;
10210   bool firstShot=true;
10211   areThereSomeForgottenTS=false;
10212   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10213     {
10214       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10215         continue;
10216       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10217       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10218       if(firstShot)
10219         { s=s1; firstShot=false; }
10220       else
10221         {
10222           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10223           if(s!=s2)
10224             areThereSomeForgottenTS=true;
10225           s=s2;
10226         }
10227     }
10228   std::vector< std::pair<int,int> > ret;
10229   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10230   return ret;
10231 }
10232
10233 int MEDFileFields::getNumberOfFields() const
10234 {
10235   return _fields.size();
10236 }
10237
10238 std::vector<std::string> MEDFileFields::getFieldsNames() const
10239 {
10240   std::vector<std::string> ret(_fields.size());
10241   int i(0);
10242   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10243     {
10244       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10245       if(f)
10246         {
10247           ret[i]=f->getName();
10248         }
10249       else
10250         {
10251           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10252           throw INTERP_KERNEL::Exception(oss.str());
10253         }
10254     }
10255   return ret;
10256 }
10257
10258 std::vector<std::string> MEDFileFields::getMeshesNames() const
10259 {
10260   std::vector<std::string> ret;
10261   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10262     {
10263       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10264       if(cur)
10265         ret.push_back(cur->getMeshName());
10266     }
10267   return ret;
10268 }
10269
10270 std::string MEDFileFields::simpleRepr() const
10271 {
10272   std::ostringstream oss;
10273   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10274   simpleRepr(0,oss);
10275   return oss.str();
10276 }
10277
10278 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10279 {
10280   int nbOfFields(getNumberOfFields());
10281   std::string startLine(bkOffset,' ');
10282   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10283   int i=0;
10284   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10285     {
10286       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10287       if(cur)
10288         {
10289           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10290         }
10291       else
10292         {
10293           oss << startLine << "  - not defined !" << std::endl;
10294         }
10295     }
10296   i=0;
10297   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10298     {
10299       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10300       std::string chapter(17,'0'+i);
10301       oss << startLine << chapter << std::endl;
10302       if(cur)
10303         {
10304           cur->simpleRepr(bkOffset+2,oss,i);
10305         }
10306       else
10307         {
10308           oss << startLine << "  - not defined !" << std::endl;
10309         }
10310       oss << startLine << chapter << std::endl;
10311     }
10312   simpleReprGlobs(oss);
10313 }
10314
10315 MEDFileFields::MEDFileFields()
10316 {
10317 }
10318
10319 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10320 try:MEDFileFieldGlobsReal(fid)
10321 {
10322   int nbFields(MEDnField(fid));
10323   _fields.resize(nbFields);
10324   med_field_type typcha;
10325   for(int i=0;i<nbFields;i++)
10326     {
10327       std::vector<std::string> infos;
10328       std::string fieldName,dtunit;
10329       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10330       switch(typcha)
10331       {
10332         case MED_FLOAT64:
10333           {
10334             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10335             break;
10336           }
10337         case MED_INT32:
10338           {
10339             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10340             break;
10341           }
10342         default:
10343           {
10344             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] !";
10345             throw INTERP_KERNEL::Exception(oss.str());
10346           }
10347       }
10348     }
10349   loadAllGlobals(fid);
10350 }
10351 catch(INTERP_KERNEL::Exception& e)
10352 {
10353     throw e;
10354 }
10355
10356 void MEDFileFields::writeLL(med_idt fid) const
10357 {
10358   int i=0;
10359   writeGlobals(fid,*this);
10360   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10361     {
10362       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10363       if(!elt)
10364         {
10365           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10366           throw INTERP_KERNEL::Exception(oss.str());
10367         }
10368       elt->writeLL(fid,*this);
10369     }
10370 }
10371
10372 /*!
10373  * This method alloc the arrays and load potentially huge arrays contained in this field.
10374  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10375  * This method can be also called to refresh or reinit values from a file.
10376  * 
10377  * \throw If the fileName is not set or points to a non readable MED file.
10378  */
10379 void MEDFileFields::loadArrays()
10380 {
10381   if(getFileName().empty())
10382     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10383   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10384   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10385     {
10386       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10387       if(elt)
10388         elt->loadBigArraysRecursively(fid,*elt);
10389     }
10390 }
10391
10392 /*!
10393  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10394  * But once data loaded once, this method does nothing.
10395  * 
10396  * \throw If the fileName is not set or points to a non readable MED file.
10397  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10398  */
10399 void MEDFileFields::loadArraysIfNecessary()
10400 {
10401   if(!getFileName().empty())
10402     {
10403       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10404       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10405         {
10406           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10407           if(elt)
10408             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10409         }
10410     }
10411 }
10412
10413 /*!
10414  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10415  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10416  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10417  * 
10418  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10419  */
10420 void MEDFileFields::unloadArrays()
10421 {
10422   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10423     {
10424       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10425       if(elt)
10426         elt->unloadArrays();
10427     }
10428 }
10429
10430 /*!
10431  * 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.
10432  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10433  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10434  * 
10435  * \sa MEDFileFields::loadArraysIfNecessary
10436  */
10437 void MEDFileFields::unloadArraysWithoutDataLoss()
10438 {
10439   if(!getFileName().empty())
10440     unloadArrays();
10441 }
10442
10443 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10444 {
10445   std::vector<std::string> ret;
10446   std::set<std::string> ret2;
10447   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10448     {
10449       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10450       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10451         if(ret2.find(*it2)==ret2.end())
10452           {
10453             ret.push_back(*it2);
10454             ret2.insert(*it2);
10455           }
10456     }
10457   return ret;
10458 }
10459
10460 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10461 {
10462   std::vector<std::string> ret;
10463   std::set<std::string> ret2;
10464   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10465     {
10466       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10467       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10468         if(ret2.find(*it2)==ret2.end())
10469           {
10470             ret.push_back(*it2);
10471             ret2.insert(*it2);
10472           }
10473     }
10474   return ret;
10475 }
10476
10477 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10478 {
10479   std::vector<std::string> ret;
10480   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10481     {
10482       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10483       ret.insert(ret.end(),tmp.begin(),tmp.end());
10484     }
10485   return ret;
10486 }
10487
10488 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10489 {
10490   std::vector<std::string> ret;
10491   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10492     {
10493       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10494       ret.insert(ret.end(),tmp.begin(),tmp.end());
10495     }
10496   return ret;
10497 }
10498
10499 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10500 {
10501   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10502     (*it)->changePflsRefsNamesGen2(mapOfModif);
10503 }
10504
10505 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10506 {
10507   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10508     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10509 }
10510
10511 void MEDFileFields::resize(int newSize)
10512 {
10513   _fields.resize(newSize);
10514 }
10515
10516 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10517 {
10518   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10519     pushField(*it);
10520 }
10521
10522 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10523 {
10524   if(!field)
10525     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10526   _fields.push_back(field->getContent());
10527   appendGlobs(*field,1e-12);
10528 }
10529
10530 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10531 {
10532   if(!field)
10533     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10534   if(i>=(int)_fields.size())
10535     _fields.resize(i+1);
10536   _fields[i]=field->getContent();
10537   appendGlobs(*field,1e-12);
10538 }
10539
10540 void MEDFileFields::destroyFieldAtPos(int i)
10541 {
10542   destroyFieldsAtPos(&i,&i+1);
10543 }
10544
10545 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10546 {
10547   std::vector<bool> b(_fields.size(),true);
10548   for(const int *i=startIds;i!=endIds;i++)
10549     {
10550       if(*i<0 || *i>=(int)_fields.size())
10551         {
10552           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10553           throw INTERP_KERNEL::Exception(oss.str());
10554         }
10555       b[*i]=false;
10556     }
10557   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10558   std::size_t j=0;
10559   for(std::size_t i=0;i<_fields.size();i++)
10560     if(b[i])
10561       fields[j++]=_fields[i];
10562   _fields=fields;
10563 }
10564
10565 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10566 {
10567   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10568   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10569   std::vector<bool> b(_fields.size(),true);
10570   int k=bg;
10571   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10572     {
10573       if(k<0 || k>=(int)_fields.size())
10574         {
10575           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10576           throw INTERP_KERNEL::Exception(oss.str());
10577         }
10578       b[k]=false;
10579     }
10580   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10581   std::size_t j(0);
10582   for(std::size_t i=0;i<_fields.size();i++)
10583     if(b[i])
10584       fields[j++]=_fields[i];
10585   _fields=fields;
10586 }
10587
10588 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10589 {
10590   bool ret(false);
10591   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10592     {
10593       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10594       if(cur)
10595         ret=cur->changeMeshNames(modifTab) || ret;
10596     }
10597   return ret;
10598 }
10599
10600 /*!
10601  * \param [in] meshName the name of the mesh that will be renumbered.
10602  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10603  *             This code corresponds to the distribution of types in the corresponding mesh.
10604  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10605  * \param [in] renumO2N the old to new renumber array.
10606  * \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 
10607  *         field in \a this.
10608  */
10609 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10610 {
10611   bool ret(false);
10612   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10613     {
10614       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10615       if(fmts)
10616         {
10617           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10618         }
10619     }
10620   return ret;
10621 }
10622
10623 /*!
10624  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10625  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10626  *
10627  * \return A new object that the caller is responsible to deallocate.
10628  */
10629 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10630 {
10631   if(!mm)
10632     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10633   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10634   int nbFields(getNumberOfFields());
10635   for(int i=0;i<nbFields;i++)
10636     {
10637       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10638       if(!fmts)
10639         {
10640           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10641           throw INTERP_KERNEL::Exception(oss.str());
10642         }
10643       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10644       fsOut->pushField(fmtsOut);
10645     }
10646   return fsOut.retn();
10647 }
10648
10649 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10650 {
10651   if(i<0 || i>=(int)_fields.size())
10652     {
10653       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10654       throw INTERP_KERNEL::Exception(oss.str());
10655     }
10656   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10657   if(!fmts)
10658     return 0;
10659   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10660   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10661   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10662   if(fmtsC)
10663     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10664   else if(fmtsC2)
10665     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10666   else
10667     {
10668       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10669       throw INTERP_KERNEL::Exception(oss.str());
10670     }
10671   ret->shallowCpyGlobs(*this);
10672   return ret.retn();
10673 }
10674
10675 /*!
10676  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10677  * This method is accessible in python using __getitem__ with a list in input.
10678  * \return a new object that the caller should deal with.
10679  */
10680 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10681 {
10682   MCAuto<MEDFileFields> ret=shallowCpy();
10683   std::size_t sz=std::distance(startIds,endIds);
10684   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10685   int j=0;
10686   for(const int *i=startIds;i!=endIds;i++,j++)
10687     {
10688       if(*i<0 || *i>=(int)_fields.size())
10689         {
10690           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10691           throw INTERP_KERNEL::Exception(oss.str());
10692         }
10693       fields[j]=_fields[*i];
10694     }
10695   ret->_fields=fields;
10696   return ret.retn();
10697 }
10698
10699 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10700 {
10701   return getFieldAtPos(getPosFromFieldName(fieldName));
10702 }
10703
10704 /*!
10705  * This method removes, if any, fields in \a this having no time steps.
10706  * 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.
10707  * 
10708  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10709  */
10710 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10711 {
10712   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10713   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10714     {
10715       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10716       if(elt)
10717         {
10718           if(elt->getNumberOfTS()>0)
10719             newFields.push_back(*it);
10720         }
10721     }
10722   if(_fields.size()==newFields.size())
10723     return false;
10724   _fields=newFields;
10725   return true;
10726 }
10727
10728 /*!
10729  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10730  * This method can be seen as a filter applied on \a this, that returns an object containing
10731  * 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
10732  * shallow copied from \a this.
10733  * 
10734  * \param [in] meshName - the name of the mesh on w
10735  * \return a new object that the caller should deal with.
10736  */
10737 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10738 {
10739   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10740   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10741     {
10742       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10743       if(!cur)
10744         continue;
10745       if(cur->getMeshName()==meshName)
10746         {
10747           cur->incrRef();
10748           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10749           ret->_fields.push_back(cur2);
10750         }
10751     }
10752   ret->shallowCpyOnlyUsedGlobs(*this);
10753   return ret.retn();
10754 }
10755
10756 /*!
10757  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10758  * Input time steps are specified using a pair of integer (iteration, order).
10759  * 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,
10760  * but for each multitimestep only the time steps in \a timeSteps are kept.
10761  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10762  * 
10763  * The returned object points to shallow copy of elements in \a this.
10764  * 
10765  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10766  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10767  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10768  */
10769 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10770 {
10771   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10772   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10773     {
10774       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10775       if(!cur)
10776         continue;
10777       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10778       ret->_fields.push_back(elt);
10779     }
10780   ret->shallowCpyOnlyUsedGlobs(*this);
10781   return ret.retn();
10782 }
10783
10784 /*!
10785  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10786  */
10787 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10788 {
10789   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10790   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10791     {
10792       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10793       if(!cur)
10794         continue;
10795       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10796       if(elt->getNumberOfTS()!=0)
10797         ret->_fields.push_back(elt);
10798     }
10799   ret->shallowCpyOnlyUsedGlobs(*this);
10800   return ret.retn();
10801 }
10802
10803 MEDFileFieldsIterator *MEDFileFields::iterator()
10804 {
10805   return new MEDFileFieldsIterator(this);
10806 }
10807
10808 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10809 {
10810   std::string tmp(fieldName);
10811   std::vector<std::string> poss;
10812   for(std::size_t i=0;i<_fields.size();i++)
10813     {
10814       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10815       if(f)
10816         {
10817           std::string fname(f->getName());
10818           if(tmp==fname)
10819             return i;
10820           else
10821             poss.push_back(fname);
10822         }
10823     }
10824   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10825   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10826   oss << " !";
10827   throw INTERP_KERNEL::Exception(oss.str());
10828 }
10829
10830 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10831 {
10832   if(fs)
10833     {
10834       fs->incrRef();
10835       _nb_iter=fs->getNumberOfFields();
10836     }
10837 }
10838
10839 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10840 {
10841 }
10842
10843 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10844 {
10845   if(_iter_id<_nb_iter)
10846     {
10847       MEDFileFields *fs(_fs);
10848       if(fs)
10849         return fs->getFieldAtPos(_iter_id++);
10850       else
10851         return 0;
10852     }
10853   else
10854     return 0;
10855 }