]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Refacto for integration into MEDFileFields
[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 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
666 {
667   types.insert(_type);
668 }
669
670 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
671 {
672   _type=newType;
673 }
674
675 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
676 {
677   return _father->getGeoType();
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 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1053 {
1054   _father=father;
1055 }
1056
1057 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1058 {
1059   std::size_t i=0;
1060   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1061     {
1062       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1063         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1064     }
1065 }
1066
1067 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1068 {
1069   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1070 }
1071
1072 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1073 {
1074   std::vector<const BigMemoryObject *> ret;
1075   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1076     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1077   return ret;
1078 }
1079
1080 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1081 {
1082   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1083   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1084     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1085 }
1086
1087 /*!
1088  * This method is the most general one. No optimization is done here.
1089  * \param [in] multiTypePfl is the end user profile specified in high level API
1090  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1091  * \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.
1092  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1093  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1094  * \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.
1095  */
1096 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)
1097 {
1098   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1099   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1100     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1101 }
1102
1103 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1104 {
1105   _field_pm_pt_pd.resize(1);
1106   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1107   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1108 }
1109
1110 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1111 {
1112   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1113   if(!arr || !arr->isAllocated())
1114     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1115   _field_pm_pt_pd.resize(1);
1116   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1117   _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.
1118 }
1119
1120 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1121 {
1122   TypeOfField type=field->getTypeOfField();
1123   if(type!=ON_GAUSS_PT)
1124     {
1125       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1126       int sz=_field_pm_pt_pd.size();
1127       bool found=false;
1128       for(int j=0;j<sz && !found;j++)
1129         {
1130           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1131             {
1132               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1133               found=true;
1134             }
1135         }
1136       if(!found)
1137         {
1138           _field_pm_pt_pd.resize(sz+1);
1139           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1140         }
1141       std::vector<int> ret(1,(int)sz);
1142       return ret;
1143     }
1144   else
1145     {
1146       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1147       int sz2=ret2.size();
1148       std::vector<int> ret3(sz2);
1149       int k=0;
1150       for(int i=0;i<sz2;i++)
1151         {
1152           int sz=_field_pm_pt_pd.size();
1153           int locIdToFind=ret2[i];
1154           bool found=false;
1155           for(int j=0;j<sz && !found;j++)
1156             {
1157               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1158                 {
1159                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1160                   ret3[k++]=j;
1161                   found=true;
1162                 }
1163             }
1164           if(!found)
1165             {
1166               _field_pm_pt_pd.resize(sz+1);
1167               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1168               ret3[k++]=sz;
1169             }
1170         }
1171       return ret3;
1172     }
1173 }
1174
1175 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1176 {
1177   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1178   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1179   if(!disc2)
1180     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1181   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1182   if(!da)
1183     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1184   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1185   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1186   if(retTmp->presenceOfValue(-1))
1187     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1188   std::vector<int> ret(retTmp->begin(),retTmp->end());
1189   return ret;
1190 }
1191
1192 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1193 {
1194   TypeOfField type=field->getTypeOfField();
1195   if(type!=ON_GAUSS_PT)
1196     {
1197       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1198       int sz=_field_pm_pt_pd.size();
1199       bool found=false;
1200       for(int j=0;j<sz && !found;j++)
1201         {
1202           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1203             {
1204               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1205               found=true;
1206             }
1207         }
1208       if(!found)
1209         {
1210           _field_pm_pt_pd.resize(sz+1);
1211           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1212         }
1213       std::vector<int> ret(1,0);
1214       return ret;
1215     }
1216   else
1217     {
1218       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1219       int sz2=ret2.size();
1220       std::vector<int> ret3(sz2);
1221       int k=0;
1222       for(int i=0;i<sz2;i++)
1223         {
1224           int sz=_field_pm_pt_pd.size();
1225           int locIdToFind=ret2[i];
1226           bool found=false;
1227           for(int j=0;j<sz && !found;j++)
1228             {
1229               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1230                 {
1231                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1232                   ret3[k++]=j;
1233                   found=true;
1234                 }
1235             }
1236           if(!found)
1237             {
1238               _field_pm_pt_pd.resize(sz+1);
1239               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1240               ret3[k++]=sz;
1241             }
1242         }
1243       return ret3;
1244     }
1245 }
1246
1247 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1248 {
1249   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1250   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1251   if(!disc2)
1252     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1253   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1254   if(!da)
1255     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1256   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1257   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1258   if(retTmp->presenceOfValue(-1))
1259     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1260   std::vector<int> ret(retTmp->begin(),retTmp->end());
1261   return ret;
1262 }
1263
1264 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1265 {
1266   return _father;
1267 }
1268
1269 void MEDFileFieldPerMeshPerTypeCommon::getDimension(int& dim) const
1270 {
1271   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1272   int curDim((int)cm.getDimension());
1273   dim=std::max(dim,curDim);
1274 }
1275
1276 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1277 {
1278   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1279   int curDim((int)cm.getDimension());
1280   if(dim!=std::numeric_limits<int>::max())
1281     {
1282       if(dim!=curDim)
1283         return false;
1284     }
1285   else
1286     dim=curDim;
1287   return true;
1288 }
1289
1290 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1291 {
1292   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1293     {
1294       (*it)->fillTypesOfFieldAvailable(types);
1295     }
1296 }
1297
1298 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
1299 {
1300   int sz=_field_pm_pt_pd.size();
1301   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1302   for(int i=0;i<sz;i++)
1303     {
1304       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1305     }
1306 }
1307
1308 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1309 {
1310   return _father->getIteration();
1311 }
1312
1313 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1314 {
1315   return _father->getOrder();
1316 }
1317
1318 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1319 {
1320   return _father->getTime();
1321 }
1322
1323 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1324 {
1325   return _father->getMeshName();
1326 }
1327
1328 void MEDFileFieldPerMeshPerTypeCommon::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1329 {
1330   const char startLine[]="  ## ";
1331   std::string startLine2(bkOffset,' ');
1332   std::string startLine3(startLine2);
1333   startLine3+=startLine;
1334   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1335     {
1336       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1337       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1338     }
1339   else
1340     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1341   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1342   int i=0;
1343   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1344     {
1345       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1346       if(cur)
1347         cur->simpleRepr(bkOffset,oss,i);
1348       else
1349         {
1350           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1351         }
1352     }
1353 }
1354
1355 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1356 {
1357   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1358     {
1359       globalSz+=(*it)->getNumberOfTuples();
1360     }
1361   nbOfEntries+=(int)_field_pm_pt_pd.size();
1362 }
1363
1364 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeCommon::getGeoType() const
1365 {
1366   return _geo_type;
1367 }
1368
1369
1370 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1371 {
1372   return _father->getNumberOfComponents();
1373 }
1374
1375 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1376 {
1377   std::size_t nb(0);
1378   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1379     {
1380       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1381       if(fmtd)
1382         nb++;
1383     }
1384   return nb>1;
1385 }
1386
1387 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1388 {
1389   return _father->getOrCreateAndGetArray();
1390 }
1391
1392 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1393 {
1394   const MEDFileFieldPerMesh *fath=_father;
1395   return fath->getOrCreateAndGetArray();
1396 }
1397
1398 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1399 {
1400   return _father->getInfo();
1401 }
1402
1403 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1404 {
1405   std::vector<std::string> ret;
1406   std::set<std::string> ret2;
1407   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1408     {
1409       std::string tmp=(*it1)->getProfile();
1410       if(!tmp.empty())
1411         if(ret2.find(tmp)==ret2.end())
1412           {
1413             ret.push_back(tmp);
1414             ret2.insert(tmp);
1415           }
1416     }
1417   return ret;
1418 }
1419
1420 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1421 {
1422   std::vector<std::string> ret;
1423   std::set<std::string> ret2;
1424   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1425     {
1426       std::string tmp=(*it1)->getLocalization();
1427       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1428         if(ret2.find(tmp)==ret2.end())
1429           {
1430             ret.push_back(tmp);
1431             ret2.insert(tmp);
1432           }
1433     }
1434   return ret;
1435 }
1436
1437 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1438 {
1439   std::vector<std::string> ret;
1440   std::set<std::string> ret2;
1441   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1442     {
1443       std::string tmp=(*it1)->getProfile();
1444       if(!tmp.empty())
1445         ret.push_back(tmp);
1446     }
1447   return ret;
1448 }
1449
1450 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1451 {
1452   std::vector<std::string> ret;
1453   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1454     {
1455       std::string tmp=(*it1)->getLocalization();
1456       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1457         ret.push_back(tmp);
1458     }
1459   return ret;
1460 }
1461
1462 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1463 {
1464   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1465     (*it1)->changePflsRefsNamesGen(mapOfModif);
1466 }
1467
1468 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1469 {
1470   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1471     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1472 }
1473
1474 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1475 {
1476   if(_field_pm_pt_pd.empty())
1477     {
1478       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1479       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1480       throw INTERP_KERNEL::Exception(oss.str());
1481     }
1482   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1483     return _field_pm_pt_pd[locId];
1484   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1485   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1486   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1487   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1488   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1489 }
1490
1491 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1492 {
1493   if(_field_pm_pt_pd.empty())
1494     {
1495       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1496       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1497       throw INTERP_KERNEL::Exception(oss.str());
1498     }
1499   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1500     return _field_pm_pt_pd[locId];
1501   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1502   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1503   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1504   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1505   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1506 }
1507
1508 void MEDFileFieldPerMeshPerTypeCommon::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
1509 {
1510   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1511     {
1512       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1513       if(meshDim!=(int)cm.getDimension())
1514         return ;
1515     }
1516   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1517     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1518 }
1519
1520 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1521 {
1522   int i=0;
1523   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1524     {
1525       (*it)->fillValues(i,startEntryId,entries);
1526     }
1527 }
1528
1529 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1530 {
1531   _field_pm_pt_pd=leaves;
1532   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1533     (*it)->setFather(this);
1534 }
1535
1536 /*!
1537  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1538  *  \param [out] its - list of pair (start,stop) kept
1539  *  \return bool - false if the type of field \a tof is not contained in \a this.
1540  */
1541 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1542 {
1543   bool ret(false);
1544   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1545   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1546     if((*it)->getType()==tof)
1547       {
1548         newPmPtPd.push_back(*it);
1549         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1550         (*it)->setNewStart(globalNum);
1551         globalNum=(*it)->getEnd();
1552         its.push_back(bgEnd);
1553         ret=true;
1554       }
1555   if(ret)
1556     _field_pm_pt_pd=newPmPtPd;
1557   return ret;
1558 }
1559
1560 /*!
1561  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1562  *  \param [out] its - list of pair (start,stop) kept
1563  *  \return bool - false if the type of field \a tof is not contained in \a this.
1564  */
1565 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1566 {
1567   if(_field_pm_pt_pd.size()<=idOfDisc)
1568     return false;
1569   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1570   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1571   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1572   elt->setNewStart(globalNum);
1573   globalNum=elt->getEnd();
1574   its.push_back(bgEnd);
1575   _field_pm_pt_pd=newPmPtPd;
1576   return true;
1577 }
1578
1579 MEDFileFieldPerMeshPerTypeCommon::MEDFileFieldPerMeshPerTypeCommon(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1580 {
1581   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1582   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1583   med_geometry_type mgeoti;
1584   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1585   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1586   _field_pm_pt_pd.resize(nbProfiles);
1587   for(int i=0;i<nbProfiles;i++)
1588     {
1589       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1590     }
1591   if(type==ON_CELLS)
1592     {
1593       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1594       for(int i=0;i<nbProfiles2;i++)
1595         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1596     }
1597 }
1598
1599 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1600 {
1601   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1602     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1603 }
1604
1605 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1606 {
1607   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1608     (*it)->loadBigArray(fid,nasc);
1609 }
1610
1611 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1612 {
1613   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1614     {
1615       (*it)->copyOptionsFrom(*this);
1616       (*it)->writeLL(fid,nasc);
1617     }
1618 }
1619
1620 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1621 {
1622   switch(ikType)
1623   {
1624     case ON_CELLS:
1625       medfGeoType=typmai3[(int)ikGeoType];
1626       return MED_CELL;
1627     case ON_NODES:
1628       medfGeoType=MED_NONE;
1629       return MED_NODE;
1630     case ON_GAUSS_NE:
1631       medfGeoType=typmai3[(int)ikGeoType];
1632       return MED_NODE_ELEMENT;
1633     case ON_GAUSS_PT:
1634       medfGeoType=typmai3[(int)ikGeoType];
1635       return MED_CELL;
1636     default:
1637       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1638   }
1639   return MED_UNDEF_ENTITY_TYPE;
1640 }
1641
1642 //////////////////////////////////////////////////
1643
1644 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1645 {
1646   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1647 }
1648
1649 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1650 {
1651   return new MEDFileFieldPerMeshPerType(fath,geoType);
1652 }
1653
1654 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1655 {
1656   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1657   ret->setFather(father);
1658   ret->deepCopyElements();
1659   return ret.retn();
1660 }
1661
1662 //////////////////////////////////////////////////
1663
1664 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1665 {
1666   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1667 }
1668
1669 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1670 {
1671   return new MEDFileFieldPerMesh(fath,mesh);
1672 }
1673
1674 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1675 {
1676   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1677 }
1678
1679 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1680 {
1681   std::vector<const BigMemoryObject *> ret;
1682   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1683     ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1684   return ret;
1685 }
1686
1687 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1688 {
1689   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1690   ret->_father=father;
1691   std::size_t i=0;
1692   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1693     {
1694       if((const MEDFileFieldPerMeshPerType *)*it)
1695         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1696     }
1697   return ret.retn();
1698 }
1699
1700 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1701 {
1702   std::string startLine(bkOffset,' ');
1703   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1704   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1705   int i=0;
1706   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1707     {
1708       const MEDFileFieldPerMeshPerType *cur=*it;
1709       if(cur)
1710         cur->simpleRepr(bkOffset,oss,i);
1711       else
1712         {
1713           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1714         }
1715     }
1716 }
1717
1718 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1719 {
1720   _mesh_name=mesh->getName();
1721   mesh->getTime(_mesh_iteration,_mesh_order);
1722 }
1723
1724 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1725 {
1726   int nbOfTypes=code.size()/3;
1727   int offset=0;
1728   for(int i=0;i<nbOfTypes;i++)
1729     {
1730       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1731       int nbOfCells=code[3*i+1];
1732       int pos=addNewEntryIfNecessary(type);
1733       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1734       offset+=nbOfCells;
1735     }
1736 }
1737
1738 /*!
1739  * This method is the most general one. No optimization is done here.
1740  * \param [in] multiTypePfl is the end user profile specified in high level API
1741  * \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].
1742  * \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.
1743  * \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.
1744  * \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.
1745  * \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.
1746  */
1747 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)
1748 {
1749   int nbOfTypes(code.size()/3);
1750   for(int i=0;i<nbOfTypes;i++)
1751     {
1752       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1753       int pos=addNewEntryIfNecessary(type);
1754       DataArrayInt *pfl=0;
1755       if(code[3*i+2]!=-1)
1756         pfl=idsPerType[code[3*i+2]];
1757       int nbOfTupes2=code2.size()/3;
1758       int found=0;
1759       for(;found<nbOfTupes2;found++)
1760         if(code[3*i]==code2[3*found])
1761           break;
1762       if(found==nbOfTupes2)
1763         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1764       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1765     }
1766 }
1767
1768 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1769 {
1770   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1771   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1772 }
1773
1774 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1775 {
1776   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1777   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1778 }
1779
1780 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1781 {
1782   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1783     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1784 }
1785
1786 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1787 {
1788   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1789     (*it)->loadBigArraysRecursively(fid,nasc);
1790 }
1791
1792 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1793 {
1794   int nbOfTypes=_field_pm_pt.size();
1795   for(int i=0;i<nbOfTypes;i++)
1796     {
1797       _field_pm_pt[i]->copyOptionsFrom(*this);
1798       _field_pm_pt[i]->writeLL(fid,nasc);
1799     }
1800 }
1801
1802 void MEDFileFieldPerMesh::getDimension(int& dim) const
1803 {
1804   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1805     (*it)->getDimension(dim);
1806 }
1807
1808 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1809 {
1810   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1811     if(!(*it)->isUniqueLevel(dim))
1812       return false;
1813   return true;
1814 }
1815
1816 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1817 {
1818   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1819     (*it)->fillTypesOfFieldAvailable(types);
1820 }
1821
1822 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
1823 {
1824   int sz=_field_pm_pt.size();
1825   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1826   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1827   for(int i=0;i<sz;i++)
1828     {
1829       types[i]=_field_pm_pt[i]->getGeoType();
1830       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1831     }
1832   return ret;
1833 }
1834
1835 double MEDFileFieldPerMesh::getTime() const
1836 {
1837   int tmp1,tmp2;
1838   return _father->getTime(tmp1,tmp2);
1839 }
1840
1841 int MEDFileFieldPerMesh::getIteration() const
1842 {
1843   return _father->getIteration();
1844 }
1845
1846 int MEDFileFieldPerMesh::getOrder() const
1847 {
1848   return _father->getOrder();
1849 }
1850
1851 int MEDFileFieldPerMesh::getNumberOfComponents() const
1852 {
1853   return _father->getNumberOfComponents();
1854 }
1855
1856 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1857 {
1858   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1859     {
1860       const MEDFileFieldPerMeshPerType *fpmt(*it);
1861       if(!fpmt)
1862         continue;
1863       if(fpmt->presenceOfMultiDiscPerGeoType())
1864         return true;
1865     }
1866   return false;
1867 }
1868
1869 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1870 {
1871   if(!_father)
1872     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1873   return _father->getOrCreateAndGetArray();
1874 }
1875
1876 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1877 {
1878   if(!_father)
1879     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1880   return _father->getOrCreateAndGetArray();
1881 }
1882
1883 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1884 {
1885   return _father->getInfo();
1886 }
1887
1888 /*!
1889  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1890  * 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.
1891  * It returns 2 output vectors :
1892  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1893  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1894  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1895  */
1896 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)
1897 {
1898   int notNullPflsSz=0;
1899   int nbOfArrs=geoTypes.size();
1900   for(int i=0;i<nbOfArrs;i++)
1901     if(pfls[i])
1902       notNullPflsSz++;
1903   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1904   int nbOfDiffGeoTypes=geoTypes3.size();
1905   code.resize(3*nbOfDiffGeoTypes);
1906   notNullPfls.resize(notNullPflsSz);
1907   notNullPflsSz=0;
1908   int j=0;
1909   for(int i=0;i<nbOfDiffGeoTypes;i++)
1910     {
1911       int startZone=j;
1912       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1913       std::vector<const DataArrayInt *> notNullTmp;
1914       if(pfls[j])
1915         notNullTmp.push_back(pfls[j]);
1916       j++;
1917       for(;j<nbOfArrs;j++)
1918         if(geoTypes[j]==refType)
1919           {
1920             if(pfls[j])
1921               notNullTmp.push_back(pfls[j]);
1922           }
1923         else
1924           break;
1925       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1926       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1927       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1928       code[3*i]=(int)refType;
1929       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1930       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1931       if(notNullTmp.empty())
1932         code[3*i+2]=-1;
1933       else
1934         {
1935           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1936           code[3*i+2]=notNullPflsSz++;
1937         }
1938     }
1939 }
1940
1941 /*!
1942  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1943  */
1944 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)
1945 {
1946   int sz=dads.size();
1947   int ret=0;
1948   for(int i=0;i<sz;i++)
1949     {
1950       if(locs[i]==-1)
1951         {
1952           if(type!=ON_GAUSS_NE)
1953             ret+=dads[i].second-dads[i].first;
1954           else
1955             {
1956               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1957               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1958             }
1959         }
1960       else
1961         {
1962           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1963           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1964         }
1965     }
1966   return ret;
1967 }
1968
1969 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1970 {
1971   std::vector<std::string> ret;
1972   std::set<std::string> ret2;
1973   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1974     {
1975       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1976       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1977         if(ret2.find(*it2)==ret2.end())
1978           {
1979             ret.push_back(*it2);
1980             ret2.insert(*it2);
1981           }
1982     }
1983   return ret;
1984 }
1985
1986 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1987 {
1988   std::vector<std::string> ret;
1989   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1990     {
1991       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1992       ret.insert(ret.end(),tmp.begin(),tmp.end());
1993     }
1994   return ret;
1995 }
1996
1997 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1998 {
1999   std::vector<std::string> ret;
2000   std::set<std::string> ret2;
2001   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2002     {
2003       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2004       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2005         if(ret2.find(*it2)==ret2.end())
2006           {
2007             ret.push_back(*it2);
2008             ret2.insert(*it2);
2009           }
2010     }
2011   return ret;
2012 }
2013
2014 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2015 {
2016   std::vector<std::string> ret;
2017   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2018     {
2019       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2020       ret.insert(ret.end(),tmp.begin(),tmp.end());
2021     }
2022   return ret;
2023 }
2024
2025 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2026 {
2027   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2028     {
2029       if((*it).first==_mesh_name)
2030         {
2031           _mesh_name=(*it).second;
2032           return true;
2033         }
2034     }
2035   return false;
2036 }
2037
2038 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2039                                                       MEDFileFieldGlobsReal& glob)
2040 {
2041   if(_mesh_name!=meshName)
2042     return false;
2043   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2044   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2045   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2046   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2047   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2048   getUndergroundDataArrayExt(entries);
2049   DataArray *arr0(getOrCreateAndGetArray());//tony
2050   if(!arr0)
2051     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2052   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2053   if(!arr0)
2054     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2055   int sz=0;
2056   if(!arr)
2057     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2058   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2059     {
2060       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2061         {
2062           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2063           sz+=(*it).second.second-(*it).second.first;
2064         }
2065       else
2066         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2067     }
2068   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2069   ////////////////////
2070   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2071   int *workI2=explicitIdsOldInMesh->getPointer();
2072   int sz1=0,sz2=0,sid=1;
2073   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2074   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2075   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2076     {
2077       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2078       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2079       int *workI=explicitIdsOldInArr->getPointer();
2080       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2081         {
2082           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2083           (*itL2)->setLocId(sz2);
2084           (*itL2)->_tmp_work1=(*itL2)->getStart();
2085           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2086         }
2087       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2088     }
2089   explicitIdsOldInMesh->reAlloc(sz2);
2090   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2091   ////////////////////
2092   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2093   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2094   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2095   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2096     {
2097       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2098       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2099       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2100     }
2101   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2102   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2103   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2104     {
2105       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2106       int newStart=elt->getLocId();
2107       elt->setLocId((*it)->getGeoType());
2108       elt->setNewStart(newStart);
2109       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2110       entriesKeptNew.push_back(elt);
2111       entriesKeptNew2.push_back(elt);
2112     }
2113   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2114   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2115   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2116   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2117   bool ret=false;
2118   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2119     {
2120       sid=0;
2121       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2122         {
2123           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2124           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2125           }*/
2126       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2127                                                             glob,arr2,otherEntriesNew) || ret;
2128     }
2129   if(!ret)
2130     return false;
2131   // Assign new dispatching
2132   assignNewLeaves(otherEntriesNew);
2133   arr->deepCopyFrom(*arr2);
2134   return true;
2135 }
2136
2137 /*!
2138  * \param [in,out] globalNum a global numbering counter for the renumbering.
2139  * \param [out] its - list of pair (start,stop) kept
2140  */
2141 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2142 {
2143   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2144   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2145     {
2146       std::vector< std::pair<int,int> > its2;
2147       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2148         {
2149           ret.push_back(*it);
2150           its.insert(its.end(),its2.begin(),its2.end());
2151         }
2152     }
2153   _field_pm_pt=ret;
2154 }
2155
2156 /*!
2157  * \param [in,out] globalNum a global numbering counter for the renumbering.
2158  * \param [out] its - list of pair (start,stop) kept
2159  */
2160 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2161 {
2162   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2163   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2164     {
2165       std::vector< std::pair<int,int> > its2;
2166       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2167         {
2168           ret.push_back(*it);
2169           its.insert(its.end(),its2.begin(),its2.end());
2170         }
2171     }
2172   _field_pm_pt=ret;
2173 }
2174
2175 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2176 {
2177   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2178   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2179     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2180   //
2181   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2182   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2183   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2184   for(;it1!=types.end();it1++,it2++)
2185     {
2186       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2187       elt->setLeaves((*it1).second);
2188       *it2=elt;
2189     }
2190   _field_pm_pt=fieldPmPt;
2191 }
2192
2193 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2194 {
2195   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2196     (*it)->changePflsRefsNamesGen(mapOfModif);
2197 }
2198
2199 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2200 {
2201   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2202     (*it)->changeLocsRefsNamesGen(mapOfModif);
2203 }
2204
2205 /*!
2206  * \param [in] mesh is the whole mesh
2207  */
2208 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2209 {
2210   if(_field_pm_pt.empty())
2211     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2212   //
2213   std::vector< std::pair<int,int> > dads;
2214   std::vector<const DataArrayInt *> pfls;
2215   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2216   std::vector<int> locs,code;
2217   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2218   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2219     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2220   // Sort by types
2221   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2222   if(code.empty())
2223     {
2224       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2225       throw INTERP_KERNEL::Exception(oss.str());
2226     }
2227   //
2228   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2229   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2230   if(type!=ON_NODES)
2231     {
2232       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2233       if(!arr)
2234         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2235       else
2236         {
2237           MCAuto<DataArrayInt> arr2(arr);
2238           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2239         }
2240     }
2241   else
2242     {
2243       if(code.size()!=3)
2244         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2245       int nb=code[1];
2246       if(code[2]==-1)
2247         {
2248           if(nb!=mesh->getNumberOfNodes())
2249             {
2250               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2251               oss << " nodes in mesh !";
2252               throw INTERP_KERNEL::Exception(oss.str());
2253             }
2254           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2255         }
2256       else
2257         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2258     }
2259 }
2260
2261 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2262 {
2263   if(_field_pm_pt.empty())
2264     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2265   //
2266   std::vector<std::pair<int,int> > dads;
2267   std::vector<const DataArrayInt *> pfls;
2268   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2269   std::vector<int> locs,code;
2270   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2271   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2272     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2273   // Sort by types
2274   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2275   if(code.empty())
2276     {
2277       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2278       throw INTERP_KERNEL::Exception(oss.str());
2279     }
2280   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2281   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2282   if(type!=ON_NODES)
2283     {
2284       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2285       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2286     }
2287   else
2288     {
2289       if(code.size()!=3)
2290         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2291       int nb=code[1];
2292       if(code[2]==-1)
2293         {
2294           if(nb!=mesh->getNumberOfNodes())
2295             {
2296               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2297               oss << " nodes in mesh !";
2298               throw INTERP_KERNEL::Exception(oss.str());
2299             }
2300         }
2301       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2302     }
2303   //
2304   return 0;
2305 }
2306
2307 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2308 {
2309   int globalSz=0;
2310   int nbOfEntries=0;
2311   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2312     {
2313       (*it)->getSizes(globalSz,nbOfEntries);
2314     }
2315   entries.resize(nbOfEntries);
2316   nbOfEntries=0;
2317   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2318     {
2319       (*it)->fillValues(nbOfEntries,entries);
2320     }
2321 }
2322
2323 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2324 {
2325   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2326     {
2327       if((*it)->getGeoType()==typ)
2328         return (*it)->getLeafGivenLocId(locId);
2329     }
2330   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2331   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2332   oss << "Possiblities are : ";
2333   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2334     {
2335       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2336       oss << "\"" << cm2.getRepr() << "\", ";
2337     }
2338   throw INTERP_KERNEL::Exception(oss.str());
2339 }
2340
2341 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2342 {
2343   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2344     {
2345       if((*it)->getGeoType()==typ)
2346         return (*it)->getLeafGivenLocId(locId);
2347     }
2348   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2349   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2350   oss << "Possiblities are : ";
2351   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2352     {
2353       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2354       oss << "\"" << cm2.getRepr() << "\", ";
2355     }
2356   throw INTERP_KERNEL::Exception(oss.str());
2357 }
2358
2359 /*!
2360  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2361  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2362  * \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.
2363  * \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.
2364  */
2365 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)
2366 {
2367   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2368   if(pms.empty())
2369     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2370   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2371     {
2372       if(!(*it).second)
2373         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2374       if(!(*it).second->getProfile().empty())
2375         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2376       if(!(*it).second->getLocalization().empty())
2377         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2378     }
2379   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2380   std::size_t i(0);
2381   std::vector< std::pair<int,int> > filteredDTS;
2382   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2383     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2384       if((*it2).first==gt)
2385         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2386   if(pms.size()!=filteredDTS.size())
2387     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2388   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2389   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2390   int zeStart(start),nval(0);
2391   for(;it1!=pms.end();it1++,it2++)
2392     {
2393       if((*it1).first!=(*it2).first)
2394         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2395       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2396       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2397       start+=e1-s1;
2398       nval+=((*it1).second)->getNumberOfVals();
2399     }
2400   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2401   return ret;
2402 }
2403
2404 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)
2405 {
2406   MCAuto<MEDFileFieldPerMeshPerType> ret(new MEDFileFieldPerMeshPerType(father,gt));
2407   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
2408   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2409     {
2410       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
2411         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
2412     }
2413   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
2414     {
2415       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2416       ret->_field_pm_pt_pd.push_back(agg);
2417     }
2418   return ret;
2419 }
2420
2421 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)
2422 {
2423   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2424   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2425   std::size_t i(0);
2426   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2427     {
2428       const std::vector< MCAuto< MEDFileFieldPerMeshPerType > >& v((*it)->_field_pm_pt);
2429       for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2430         {
2431           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2432           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
2433         }
2434     }
2435   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2436     {
2437       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerTypeCommon::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2438       ret->_field_pm_pt.push_back(agg);
2439     }
2440   return ret;
2441 }
2442
2443 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2444 {
2445   int i=0;
2446   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2447   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2448   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2449     {
2450       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2451       if(type==curType)
2452         return i;
2453       else
2454         {
2455           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2456           if(pos>pos2)
2457             it2=it+1;
2458         }
2459     }
2460   int ret=std::distance(_field_pm_pt.begin(),it2);
2461   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2462   return ret;
2463 }
2464
2465 /*!
2466  * 'dads' and 'locs' input parameters have the same number of elements
2467  * \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
2468  */
2469 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2470                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2471                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2472 {
2473   isPfl=false;
2474   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2475   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2476   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2477   const std::vector<std::string>& infos=getInfo();
2478   da->setInfoOnComponents(infos);
2479   da->setName("");
2480   if(type==ON_GAUSS_PT)
2481     {
2482       int offset=0;
2483       int nbOfArrs=dads.size();
2484       for(int i=0;i<nbOfArrs;i++)
2485         {
2486           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2487           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2488           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2489           MCAuto<DataArrayInt> di=DataArrayInt::New();
2490           di->alloc(nbOfElems,1);
2491           di->iota(offset);
2492           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2493           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2494           offset+=nbOfElems;
2495         }
2496     }
2497   arrOut=da;
2498   return ret.retn();
2499 }
2500
2501 /*!
2502  * 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.
2503  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2504  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2505  * The order of cells in the returned field is those imposed by the profile.
2506  * \param [in] mesh is the global mesh.
2507  */
2508 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2509                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2510                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2511                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2512 {
2513   if(da->isIota(mesh->getNumberOfCells()))
2514     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2515   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2516   m2->setName(mesh->getName().c_str());
2517   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2518   isPfl=true;
2519   return ret.retn();
2520 }
2521
2522 /*!
2523  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2524  */
2525 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2526                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2527                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2528 {
2529   if(da->isIota(mesh->getNumberOfNodes()))
2530     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2531   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2532   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2533   if(meshu)
2534     {
2535       if(meshu->getNodalConnectivity()==0)
2536         {
2537           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2538           int nb=da->getNbOfElems();
2539           const int *ptr=da->getConstPointer();
2540           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2541           meshuc->allocateCells(nb);
2542           for(int i=0;i<nb;i++)
2543             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2544           meshuc->finishInsertingCells();
2545           ret->setMesh(meshuc);
2546           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2547           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2548           disc->checkCoherencyBetween(meshuc,arrOut);
2549           return ret.retn();
2550         }
2551     }
2552   //
2553   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2554   isPfl=true;
2555   DataArrayInt *arr2=0;
2556   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2557   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2558   MCAuto<DataArrayInt> arr3(arr2);
2559   int nnodes=mesh2->getNumberOfNodes();
2560   if(nnodes==(int)da->getNbOfElems())
2561     {
2562       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2563       arrOut->renumberInPlace(da3->getConstPointer());
2564       mesh2->setName(mesh->getName().c_str());
2565       ret->setMesh(mesh2);
2566       return ret.retn();
2567     }
2568   else
2569     {
2570       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 !!!";
2571       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2572       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2573       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2574       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2575       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2576       throw INTERP_KERNEL::Exception(oss.str());
2577     }
2578   return 0;
2579 }
2580
2581 /*!
2582  * This method is the most light method of field retrieving.
2583  */
2584 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2585 {
2586   if(!pflIn)
2587     {
2588       pflOut=DataArrayInt::New();
2589       pflOut->alloc(nbOfElems,1);
2590       pflOut->iota(0);
2591     }
2592   else
2593     {
2594       pflOut=const_cast<DataArrayInt*>(pflIn);
2595       pflOut->incrRef();
2596     }
2597   MCAuto<DataArrayInt> safePfl(pflOut);
2598   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2599   const std::vector<std::string>& infos=getInfo();
2600   int nbOfComp=infos.size();
2601   for(int i=0;i<nbOfComp;i++)
2602     da->setInfoOnComponent(i,infos[i].c_str());
2603   safePfl->incrRef();
2604   return da.retn();
2605 }
2606
2607
2608 /// @cond INTERNAL
2609
2610 class MFFPMIter
2611 {
2612 public:
2613   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2614   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2615   virtual ~MFFPMIter() { }
2616   virtual void begin() = 0;
2617   virtual bool finished() const = 0;
2618   virtual void next() = 0;
2619   virtual int current() const = 0;
2620 };
2621
2622 class MFFPMIterSimple : public MFFPMIter
2623 {
2624 public:
2625   MFFPMIterSimple():_pos(0) { }
2626   void begin() { _pos=0; }
2627   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2628   void next() { _pos++; }
2629   int current() const { return _pos; }
2630 private:
2631   int _pos;
2632 };
2633
2634 class MFFPMIter2 : public MFFPMIter
2635 {
2636 public:
2637   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2638   void begin() { _it=_ids.begin(); }
2639   bool finished() const { return _it==_ids.end(); }
2640   void next() { _it++; }
2641   int current() const { return *_it; }
2642 private:
2643   std::vector<int> _ids;
2644   std::vector<int>::const_iterator _it;
2645 };
2646
2647 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2648 {
2649   if(!entities)
2650     return new MFFPMIterSimple;
2651   else
2652     {
2653       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2654       if(entities2)
2655         {
2656           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2657           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2658           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2659             {
2660               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2661                 tmp.push_back((*it).second);
2662             }
2663           return new MFFPMIter2(tmp);
2664         }
2665       else
2666         throw INTERP_KERNEL::Exception("MFFPMIter::NewCell : not recognized type !");
2667     }
2668 }
2669
2670 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2671 {
2672   if(!entities)
2673     return true;
2674   else
2675     {
2676       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2677       if(entities2)
2678         {
2679           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2680           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2681             if((*it).first==ON_NODES)
2682               return true;
2683           return false;
2684         }
2685       else
2686         throw INTERP_KERNEL::Exception("MFFPMIter::IsPresenceOfNode : not recognized type !");
2687     }
2688 }
2689
2690 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2691 {
2692   std::size_t sz(cts.size());
2693   _ids.resize(sz);
2694   for(std::size_t i=0;i<sz;i++)
2695     {
2696       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2697       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2698         _ids[i]=(int)std::distance(typmai2,loc);
2699       else
2700         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2701     }
2702 }
2703
2704 /// @endcond
2705
2706 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),
2707     _father(fath)
2708 {
2709   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2710   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2711   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2712   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2713   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2714   for(iter0->begin();!iter0->finished();iter0->next())
2715     {
2716       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2717       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2718       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2719       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2720       if(nbProfile>0 || nbProfile2>0)
2721         {
2722           const PartDefinition *pd(0);
2723           if(mmu)
2724             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2725           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2726           if(nbProfile>0)
2727             _mesh_name=name0;
2728           else
2729             _mesh_name=name1;
2730         }
2731     }
2732   if(MFFPMIter::IsPresenceOfNode(entities))
2733     {
2734       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2735       if(nbProfile>0)
2736         {
2737           const PartDefinition *pd(0);
2738           if(mmu)
2739             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2740           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2741           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2742         }
2743     }
2744 }
2745
2746 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2747 {
2748   copyTinyInfoFrom(mesh);
2749 }
2750
2751 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2752 {
2753   if(id>=(int)_pfls.size())
2754     _pfls.resize(id+1);
2755   _pfls[id]=DataArrayInt::New();
2756   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2757   _pfls[id]->setName(pflName);
2758   _pfls[id]->alloc(lgth,1);
2759   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2760   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2761 }
2762
2763 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2764 {
2765   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2766   int sz;
2767   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2768   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2769   if(i>=(int)_pfls.size())
2770     _pfls.resize(i+1);
2771   _pfls[i]=DataArrayInt::New();
2772   _pfls[i]->alloc(sz,1);
2773   _pfls[i]->setName(pflCpp.c_str());
2774   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2775   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2776 }
2777
2778 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2779 {
2780   int nbOfPfls=_pfls.size();
2781   for(int i=0;i<nbOfPfls;i++)
2782     {
2783       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2784       cpy->applyLin(1,1,0);
2785       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2786       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2787       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2788     }
2789   //
2790   int nbOfLocs=_locs.size();
2791   for(int i=0;i<nbOfLocs;i++)
2792     _locs[i]->writeLL(fid);
2793 }
2794
2795 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2796 {
2797   std::vector<std::string> pfls=getPfls();
2798   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2799     {
2800       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2801       if(it2==pfls.end())
2802         {
2803           _pfls.push_back(*it);
2804         }
2805       else
2806         {
2807           int id=std::distance(pfls.begin(),it2);
2808           if(!(*it)->isEqual(*_pfls[id]))
2809             {
2810               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2811               throw INTERP_KERNEL::Exception(oss.str());
2812             }
2813         }
2814     }
2815   std::vector<std::string> locs=getLocs();
2816   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2817     {
2818       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2819       if(it2==locs.end())
2820         {
2821           _locs.push_back(*it);
2822         }
2823       else
2824         {
2825           int id=std::distance(locs.begin(),it2);
2826           if(!(*it)->isEqual(*_locs[id],eps))
2827             {
2828               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2829               throw INTERP_KERNEL::Exception(oss.str());
2830             }
2831         }
2832     }
2833 }
2834
2835 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2836 {
2837   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2838     getProfile((*it).c_str());
2839 }
2840
2841 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2842 {
2843   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2844     getLocalization((*it).c_str());
2845 }
2846
2847 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2848 {
2849   std::vector<std::string> profiles=real.getPflsReallyUsed();
2850   int sz=profiles.size();
2851   _pfls.resize(sz);
2852   for(int i=0;i<sz;i++)
2853     loadProfileInFile(fid,i,profiles[i].c_str());
2854   //
2855   std::vector<std::string> locs=real.getLocsReallyUsed();
2856   sz=locs.size();
2857   _locs.resize(sz);
2858   for(int i=0;i<sz;i++)
2859     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2860 }
2861
2862 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2863 {
2864   int nProfil=MEDnProfile(fid);
2865   for(int i=0;i<nProfil;i++)
2866     loadProfileInFile(fid,i);
2867   int sz=MEDnLocalization(fid);
2868   _locs.resize(sz);
2869   for(int i=0;i<sz;i++)
2870     {
2871       _locs[i]=MEDFileFieldLoc::New(fid,i);
2872     }
2873 }
2874
2875 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2876 {
2877   return new MEDFileFieldGlobs(fid);
2878 }
2879
2880 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2881 {
2882   return new MEDFileFieldGlobs;
2883 }
2884
2885 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2886 {
2887   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2888 }
2889
2890 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2891 {
2892   std::vector<const BigMemoryObject *> ret;
2893   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2894     ret.push_back((const DataArrayInt *)*it);
2895   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2896     ret.push_back((const MEDFileFieldLoc *)*it);
2897   return ret;
2898 }
2899
2900 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2901 {
2902   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2903   std::size_t i=0;
2904   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2905     {
2906       if((const DataArrayInt *)*it)
2907         ret->_pfls[i]=(*it)->deepCopy();
2908     }
2909   i=0;
2910   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2911     {
2912       if((const MEDFileFieldLoc*)*it)
2913         ret->_locs[i]=(*it)->deepCopy();
2914     }
2915   return ret.retn();
2916 }
2917
2918 /*!
2919  * \throw if a profile in \a pfls in not in \a this.
2920  * \throw if a localization in \a locs in not in \a this.
2921  * \sa MEDFileFieldGlobs::deepCpyPart
2922  */
2923 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2924 {
2925   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2926   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2927     {
2928       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2929       if(!pfl)
2930         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2931       pfl->incrRef();
2932       MCAuto<DataArrayInt> pfl2(pfl);
2933       ret->_pfls.push_back(pfl2);
2934     }
2935   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2936     {
2937       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2938       if(!loc)
2939         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2940       loc->incrRef();
2941       MCAuto<MEDFileFieldLoc> loc2(loc);
2942       ret->_locs.push_back(loc2);
2943     }
2944   ret->setFileName(getFileName());
2945   return ret.retn();
2946 }
2947
2948 /*!
2949  * \throw if a profile in \a pfls in not in \a this.
2950  * \throw if a localization in \a locs in not in \a this.
2951  * \sa MEDFileFieldGlobs::shallowCpyPart
2952  */
2953 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2954 {
2955   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2956   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2957     {
2958       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2959       if(!pfl)
2960         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2961       ret->_pfls.push_back(pfl->deepCopy());
2962     }
2963   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2964     {
2965       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2966       if(!loc)
2967         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2968       ret->_locs.push_back(loc->deepCopy());
2969     }
2970   ret->setFileName(getFileName());
2971   return ret.retn();
2972 }
2973
2974 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
2975 {
2976 }
2977
2978 MEDFileFieldGlobs::MEDFileFieldGlobs()
2979 {
2980 }
2981
2982 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2983 {
2984 }
2985
2986 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2987 {
2988   oss << "Profiles :\n";
2989   std::size_t n=_pfls.size();
2990   for(std::size_t i=0;i<n;i++)
2991     {
2992       oss << "  - #" << i << " ";
2993       const DataArrayInt *pfl=_pfls[i];
2994       if(pfl)
2995         oss << "\"" << pfl->getName() << "\"\n";
2996       else
2997         oss << "EMPTY !\n";
2998     }
2999   n=_locs.size();
3000   oss << "Localizations :\n";
3001   for(std::size_t i=0;i<n;i++)
3002     {
3003       oss << "  - #" << i << " ";
3004       const MEDFileFieldLoc *loc=_locs[i];
3005       if(loc)
3006         loc->simpleRepr(oss);
3007       else
3008         oss<< "EMPTY !\n";
3009     }
3010 }
3011
3012 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3013 {
3014   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3015     {
3016       DataArrayInt *elt(*it);
3017       if(elt)
3018         {
3019           std::string name(elt->getName());
3020           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3021             {
3022               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3023                 {
3024                   elt->setName((*it2).second.c_str());
3025                   return;
3026                 }
3027             }
3028         }
3029     }
3030 }
3031
3032 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3033 {
3034   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3035     {
3036       MEDFileFieldLoc *elt(*it);
3037       if(elt)
3038         {
3039           std::string name(elt->getName());
3040           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3041             {
3042               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3043                 {
3044                   elt->setName((*it2).second.c_str());
3045                   return;
3046                 }
3047             }
3048         }
3049     }
3050 }
3051
3052 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3053 {
3054   if(locId<0 || locId>=(int)_locs.size())
3055     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3056   return _locs[locId]->getNbOfGaussPtPerCell();
3057 }
3058
3059 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3060 {
3061   return getLocalizationFromId(getLocalizationId(locName));
3062 }
3063
3064 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3065 {
3066   if(locId<0 || locId>=(int)_locs.size())
3067     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3068   return *_locs[locId];
3069 }
3070
3071 /// @cond INTERNAL
3072 namespace MEDCouplingImpl
3073 {
3074   class LocFinder
3075   {
3076   public:
3077     LocFinder(const std::string& loc):_loc(loc) { }
3078     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3079   private:
3080     const std::string &_loc;
3081   };
3082
3083   class PflFinder
3084   {
3085   public:
3086     PflFinder(const std::string& pfl):_pfl(pfl) { }
3087     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3088   private:
3089     const std::string& _pfl;
3090   };
3091 }
3092 /// @endcond
3093
3094 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3095 {
3096   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3097   if(it==_locs.end())
3098     {
3099       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3100       for(it=_locs.begin();it!=_locs.end();it++)
3101         oss << "\"" << (*it)->getName() << "\", ";
3102       throw INTERP_KERNEL::Exception(oss.str());
3103     }
3104   return std::distance(_locs.begin(),it);
3105 }
3106
3107 /*!
3108  * The returned value is never null.
3109  */
3110 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3111 {
3112   std::string pflNameCpp(pflName);
3113   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3114   if(it==_pfls.end())
3115     {
3116       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3117       for(it=_pfls.begin();it!=_pfls.end();it++)
3118         oss << "\"" << (*it)->getName() << "\", ";
3119       throw INTERP_KERNEL::Exception(oss.str());
3120     }
3121   return *it;
3122 }
3123
3124 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3125 {
3126   if(pflId<0 || pflId>=(int)_pfls.size())
3127     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3128   return _pfls[pflId];
3129 }
3130
3131 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3132 {
3133   if(locId<0 || locId>=(int)_locs.size())
3134     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3135   return *_locs[locId];
3136 }
3137
3138 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3139 {
3140   return getLocalizationFromId(getLocalizationId(locName));
3141 }
3142
3143 /*!
3144  * The returned value is never null.
3145  */
3146 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3147 {
3148   std::string pflNameCpp(pflName);
3149   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3150   if(it==_pfls.end())
3151     {
3152       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3153       for(it=_pfls.begin();it!=_pfls.end();it++)
3154         oss << "\"" << (*it)->getName() << "\", ";
3155       throw INTERP_KERNEL::Exception(oss.str());
3156     }
3157   return *it;
3158 }
3159
3160 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3161 {
3162   if(pflId<0 || pflId>=(int)_pfls.size())
3163     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3164   return _pfls[pflId];
3165 }
3166
3167 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3168 {
3169   std::vector< MCAuto<DataArrayInt> > newPfls;
3170   int i=0;
3171   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3172     {
3173       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3174         newPfls.push_back(*it);
3175     }
3176   _pfls=newPfls;
3177 }
3178
3179 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3180 {
3181   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3182   int i=0;
3183   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3184     {
3185       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3186         newLocs.push_back(*it);
3187     }
3188   _locs=newLocs;
3189 }
3190
3191 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3192 {
3193   int sz=_pfls.size();
3194   std::vector<std::string> ret(sz);
3195   for(int i=0;i<sz;i++)
3196     ret[i]=_pfls[i]->getName();
3197   return ret;
3198 }
3199
3200 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3201 {
3202   int sz=_locs.size();
3203   std::vector<std::string> ret(sz);
3204   for(int i=0;i<sz;i++)
3205     ret[i]=_locs[i]->getName();
3206   return ret;
3207 }
3208
3209 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3210 {
3211   std::vector<std::string> v=getPfls();
3212   std::string s(pflName);
3213   return std::find(v.begin(),v.end(),s)!=v.end();
3214 }
3215
3216 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3217 {
3218   std::vector<std::string> v=getLocs();
3219   std::string s(locName);
3220   return std::find(v.begin(),v.end(),s)!=v.end();
3221 }
3222
3223 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3224 {
3225   std::map<int,std::vector<int> > m;
3226   int i=0;
3227   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3228     {
3229       const DataArrayInt *tmp=(*it);
3230       if(tmp)
3231         {
3232           m[tmp->getHashCode()].push_back(i);
3233         }
3234     }
3235   std::vector< std::vector<int> > ret;
3236   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3237     {
3238       if((*it2).second.size()>1)
3239         {
3240           std::vector<int> ret0;
3241           bool equalityOrNot=false;
3242           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3243             {
3244               std::vector<int>::const_iterator it4=it3; it4++;
3245               for(;it4!=(*it2).second.end();it4++)
3246                 {
3247                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3248                     {
3249                       if(!equalityOrNot)
3250                         ret0.push_back(*it3);
3251                       ret0.push_back(*it4);
3252                       equalityOrNot=true;
3253                     }
3254                 }
3255             }
3256           if(!ret0.empty())
3257             ret.push_back(ret0);
3258         }
3259     }
3260   return ret;
3261 }
3262
3263 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3264 {
3265   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3266 }
3267
3268 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3269 {
3270   std::string name(pfl->getName());
3271   if(name.empty())
3272     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3273   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3274     if(name==(*it)->getName())
3275       {
3276         if(!pfl->isEqual(*(*it)))
3277           {
3278             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3279             throw INTERP_KERNEL::Exception(oss.str());
3280           }
3281       }
3282   pfl->incrRef();
3283   _pfls.push_back(pfl);
3284 }
3285
3286 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)
3287 {
3288   std::string name(locName);
3289   if(name.empty())
3290     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3291   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3292   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3293     if((*it)->isName(locName))
3294       {
3295         if(!(*it)->isEqual(*obj,1e-12))
3296           {
3297             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3298             throw INTERP_KERNEL::Exception(oss.str());
3299           }
3300       }
3301   _locs.push_back(obj);
3302 }
3303
3304 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3305 {
3306   std::vector<std::string> names=getPfls();
3307   return CreateNewNameNotIn("NewPfl_",names);
3308 }
3309
3310 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3311 {
3312   std::vector<std::string> names=getLocs();
3313   return CreateNewNameNotIn("NewLoc_",names);
3314 }
3315
3316 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3317 {
3318   for(std::size_t sz=0;sz<100000;sz++)
3319     {
3320       std::ostringstream tryName;
3321       tryName << prefix << sz;
3322       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3323         return tryName.str();
3324     }
3325   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3326 }
3327
3328 /*!
3329  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3330  *  \param [in] fname - the file name.
3331  */
3332 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3333 {
3334 }
3335
3336 /*!
3337  * Creates an empty MEDFileFieldGlobsReal.
3338  */
3339 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3340 {
3341 }
3342
3343 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3344 {
3345   return 0;
3346 }
3347
3348 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3349 {
3350   std::vector<const BigMemoryObject *> ret;
3351   ret.push_back((const MEDFileFieldGlobs *)_globals);
3352   return ret;
3353 }
3354
3355 /*!
3356  * Returns a string describing profiles and Gauss points held in \a this.
3357  *  \return std::string - the description string.
3358  */
3359 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3360 {
3361   const MEDFileFieldGlobs *glob=_globals;
3362   std::ostringstream oss2; oss2 << glob;
3363   std::string stars(oss2.str().length(),'*');
3364   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3365   if(glob)
3366     glob->simpleRepr(oss);
3367   else
3368     oss << "NO GLOBAL INFORMATION !\n";
3369 }
3370
3371 void MEDFileFieldGlobsReal::resetContent()
3372 {
3373   _globals=MEDFileFieldGlobs::New();
3374 }
3375
3376 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3377 {
3378 }
3379
3380 /*!
3381  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3382  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3383  */
3384 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3385 {
3386   _globals=other._globals;
3387 }
3388
3389 /*!
3390  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3391  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3392  */
3393 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3394 {
3395   const MEDFileFieldGlobs *otherg(other._globals);
3396   if(!otherg)
3397     return ;
3398   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3399 }
3400
3401 /*!
3402  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3403  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3404  */
3405 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3406 {
3407   const MEDFileFieldGlobs *otherg(other._globals);
3408   if(!otherg)
3409     return ;
3410   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3411 }
3412
3413 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3414 {
3415   _globals=other._globals;
3416   if((const MEDFileFieldGlobs *)_globals)
3417     _globals=other._globals->deepCopy();
3418 }
3419
3420 /*!
3421  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3422  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3423  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3424  *         \a this and \a other MEDFileFieldGlobsReal.
3425  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3426  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3427  */
3428 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3429 {
3430   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3431   if(thisGlobals==otherGlobals)
3432     return ;
3433   if(!thisGlobals)
3434     {
3435       _globals=other._globals;
3436       return ;
3437     }
3438   _globals->appendGlobs(*other._globals,eps);
3439 }
3440
3441 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3442 {
3443   checkGlobsPflsPartCoherency();
3444   checkGlobsLocsPartCoherency();
3445 }
3446
3447 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3448 {
3449   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3450 }
3451
3452 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3453 {
3454   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3455 }
3456
3457 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3458 {
3459   contentNotNull()->loadProfileInFile(fid,id,pflName);
3460 }
3461
3462 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3463 {
3464   contentNotNull()->loadProfileInFile(fid,id);
3465 }
3466
3467 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3468 {
3469   contentNotNull()->loadGlobals(fid,*this);
3470 }
3471
3472 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3473 {
3474   contentNotNull()->loadAllGlobals(fid);
3475 }
3476
3477 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3478 {
3479   contentNotNull()->writeGlobals(fid,opt);
3480 }
3481
3482 /*!
3483  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3484  * or getPflsReallyUsedMulti().
3485  *  \return std::vector<std::string> - a sequence of names of all profiles.
3486  */
3487 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3488 {
3489   return contentNotNull()->getPfls();
3490 }
3491
3492 /*!
3493  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3494  * or getLocsReallyUsedMulti().
3495  *  \return std::vector<std::string> - a sequence of names of all localizations.
3496  */
3497 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3498 {
3499   return contentNotNull()->getLocs();
3500 }
3501
3502 /*!
3503  * Checks if the profile with a given name exists.
3504  *  \param [in] pflName - the profile name of interest.
3505  *  \return bool - \c true if the profile named \a pflName exists.
3506  */
3507 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3508 {
3509   return contentNotNull()->existsPfl(pflName);
3510 }
3511
3512 /*!
3513  * Checks if the localization with a given name exists.
3514  *  \param [in] locName - the localization name of interest.
3515  *  \return bool - \c true if the localization named \a locName exists.
3516  */
3517 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3518 {
3519   return contentNotNull()->existsLoc(locName);
3520 }
3521
3522 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3523 {
3524   return contentNotNull()->createNewNameOfPfl();
3525 }
3526
3527 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3528 {
3529   return contentNotNull()->createNewNameOfLoc();
3530 }
3531
3532 /*!
3533  * Sets the name of a MED file.
3534  *  \param [inout] fileName - the file name.
3535  */
3536 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3537 {
3538   contentNotNull()->setFileName(fileName);
3539 }
3540
3541 /*!
3542  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3543  * in the same order.
3544  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3545  *          Each item of this sequence is a vector containing ids of equal profiles.
3546  */
3547 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3548 {
3549   return contentNotNull()->whichAreEqualProfiles();
3550 }
3551
3552 /*!
3553  * Finds equal localizations.
3554  *  \param [in] eps - a precision used to compare real values of the localizations.
3555  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3556  *          Each item of this sequence is a vector containing ids of equal localizations.
3557  */
3558 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3559 {
3560   return contentNotNull()->whichAreEqualLocs(eps);
3561 }
3562
3563 /*!
3564  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3565  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3566  *        this sequence is a pair whose 
3567  *        - the first item is a vector of profile names to replace by the second item,
3568  *        - the second item is a profile name to replace every profile name of the first item.
3569  */
3570 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3571 {
3572   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3573 }
3574
3575 /*!
3576  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3577  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3578  *        this sequence is a pair whose 
3579  *        - the first item is a vector of localization names to replace by the second item,
3580  *        - the second item is a localization name to replace every localization name of the first item.
3581  */
3582 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3583 {
3584   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3585 }
3586
3587 /*!
3588  * Replaces references to some profiles (a reference is a profile name) by references
3589  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3590  * them-selves accordingly. <br>
3591  * This method is a generalization of changePflName().
3592  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3593  *        this sequence is a pair whose 
3594  *        - the first item is a vector of profile names to replace by the second item,
3595  *        - the second item is a profile name to replace every profile of the first item.
3596  * \sa changePflsRefsNamesGen()
3597  * \sa changePflName()
3598  */
3599 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3600 {
3601   changePflsRefsNamesGen(mapOfModif);
3602   changePflsNamesInStruct(mapOfModif);
3603 }
3604
3605 /*!
3606  * Replaces references to some localizations (a reference is a localization name) by references
3607  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3608  * them-selves accordingly. <br>
3609  * This method is a generalization of changeLocName().
3610  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3611  *        this sequence is a pair whose 
3612  *        - the first item is a vector of localization names to replace by the second item,
3613  *        - the second item is a localization name to replace every localization of the first item.
3614  * \sa changeLocsRefsNamesGen()
3615  * \sa changeLocName()
3616  */
3617 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3618 {
3619   changeLocsRefsNamesGen(mapOfModif);
3620   changeLocsNamesInStruct(mapOfModif);
3621 }
3622
3623 /*!
3624  * Renames the profile having a given name and updates references to this profile.
3625  *  \param [in] oldName - the name of the profile to rename.
3626  *  \param [in] newName - a new name of the profile.
3627  * \sa changePflsNames().
3628  */
3629 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3630 {
3631   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3632   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3633   mapOfModif[0]=p;
3634   changePflsNames(mapOfModif);
3635 }
3636
3637 /*!
3638  * Renames the localization having a given name and updates references to this localization.
3639  *  \param [in] oldName - the name of the localization to rename.
3640  *  \param [in] newName - a new name of the localization.
3641  * \sa changeLocsNames().
3642  */
3643 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3644 {
3645   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3646   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3647   mapOfModif[0]=p;
3648   changeLocsNames(mapOfModif);
3649 }
3650
3651 /*!
3652  * Removes duplicated profiles. Returns a map used to update references to removed 
3653  * profiles via changePflsRefsNamesGen().
3654  * Equal profiles are found using whichAreEqualProfiles().
3655  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3656  *          a sequence describing the performed replacements of profiles. Each element of
3657  *          this sequence is a pair whose
3658  *          - the first item is a vector of profile names replaced by the second item,
3659  *          - the second item is a profile name replacing every profile of the first item.
3660  */
3661 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3662 {
3663   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3664   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3665   int i=0;
3666   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3667     {
3668       std::vector< std::string > tmp((*it).size());
3669       int j=0;
3670       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3671         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3672       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3673       ret[i]=p;
3674       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3675       killProfileIds(tmp2);
3676     }
3677   changePflsRefsNamesGen(ret);
3678   return ret;
3679 }
3680
3681 /*!
3682  * Removes duplicated localizations. Returns a map used to update references to removed 
3683  * localizations via changeLocsRefsNamesGen().
3684  * Equal localizations are found using whichAreEqualLocs().
3685  *  \param [in] eps - a precision used to compare real values of the localizations.
3686  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3687  *          a sequence describing the performed replacements of localizations. Each element of
3688  *          this sequence is a pair whose
3689  *          - the first item is a vector of localization names replaced by the second item,
3690  *          - the second item is a localization name replacing every localization of the first item.
3691  */
3692 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3693 {
3694   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3695   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3696   int i=0;
3697   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3698     {
3699       std::vector< std::string > tmp((*it).size());
3700       int j=0;
3701       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3702         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3703       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3704       ret[i]=p;
3705       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3706       killLocalizationIds(tmp2);
3707     }
3708   changeLocsRefsNamesGen(ret);
3709   return ret;
3710 }
3711
3712 /*!
3713  * Returns number of Gauss points per cell in a given localization.
3714  *  \param [in] locId - an id of the localization of interest.
3715  *  \return int - the number of the Gauss points per cell.
3716  */
3717 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3718 {
3719   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3720 }
3721
3722 /*!
3723  * Returns an id of a localization by its name.
3724  *  \param [in] loc - the localization name of interest.
3725  *  \return int - the id of the localization.
3726  *  \throw If there is no a localization named \a loc.
3727  */
3728 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3729 {
3730   return contentNotNull()->getLocalizationId(loc);
3731 }
3732
3733 /*!
3734  * Returns the name of the MED file.
3735  *  \return const std::string&  - the MED file name.
3736  */
3737 std::string MEDFileFieldGlobsReal::getFileName() const
3738 {
3739   return contentNotNull()->getFileName();
3740 }
3741
3742 /*!
3743  * Returns a localization object by its name.
3744  *  \param [in] locName - the name of the localization of interest.
3745  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3746  *  \throw If there is no a localization named \a locName.
3747  */
3748 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3749 {
3750   return contentNotNull()->getLocalization(locName);
3751 }
3752
3753 /*!
3754  * Returns a localization object by its id.
3755  *  \param [in] locId - the id of the localization of interest.
3756  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3757  *  \throw If there is no a localization with id \a locId.
3758  */
3759 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3760 {
3761   return contentNotNull()->getLocalizationFromId(locId);
3762 }
3763
3764 /*!
3765  * Returns a profile array by its name.
3766  *  \param [in] pflName - the name of the profile of interest.
3767  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3768  *  \throw If there is no a profile named \a pflName.
3769  */
3770 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3771 {
3772   return contentNotNull()->getProfile(pflName);
3773 }
3774
3775 /*!
3776  * Returns a profile array by its id.
3777  *  \param [in] pflId - the id of the profile of interest.
3778  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3779  *  \throw If there is no a profile with id \a pflId.
3780  */
3781 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3782 {
3783   return contentNotNull()->getProfileFromId(pflId);
3784 }
3785
3786 /*!
3787  * Returns a localization object, apt for modification, by its id.
3788  *  \param [in] locId - the id of the localization of interest.
3789  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3790  *          having the id \a locId.
3791  *  \throw If there is no a localization with id \a locId.
3792  */
3793 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3794 {
3795   return contentNotNull()->getLocalizationFromId(locId);
3796 }
3797
3798 /*!
3799  * Returns a localization object, apt for modification, by its name.
3800  *  \param [in] locName - the name of the localization of interest.
3801  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3802  *          having the name \a locName.
3803  *  \throw If there is no a localization named \a locName.
3804  */
3805 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3806 {
3807   return contentNotNull()->getLocalization(locName);
3808 }
3809
3810 /*!
3811  * Returns a profile array, apt for modification, by its name.
3812  *  \param [in] pflName - the name of the profile of interest.
3813  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3814  *  \throw If there is no a profile named \a pflName.
3815  */
3816 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3817 {
3818   return contentNotNull()->getProfile(pflName);
3819 }
3820
3821 /*!
3822  * Returns a profile array, apt for modification, by its id.
3823  *  \param [in] pflId - the id of the profile of interest.
3824  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3825  *  \throw If there is no a profile with id \a pflId.
3826  */
3827 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3828 {
3829   return contentNotNull()->getProfileFromId(pflId);
3830 }
3831
3832 /*!
3833  * Removes profiles given by their ids. No data is updated to track this removal.
3834  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3835  */
3836 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3837 {
3838   contentNotNull()->killProfileIds(pflIds);
3839 }
3840
3841 /*!
3842  * Removes localizations given by their ids. No data is updated to track this removal.
3843  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3844  */
3845 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3846 {
3847   contentNotNull()->killLocalizationIds(locIds);
3848 }
3849
3850 /*!
3851  * Stores a profile array.
3852  *  \param [in] pfl - the profile array to store.
3853  *  \throw If the name of \a pfl is empty.
3854  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3855  *         different ids.
3856  */
3857 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3858 {
3859   contentNotNull()->appendProfile(pfl);
3860 }
3861
3862 /*!
3863  * Adds a new localization of Gauss points.
3864  *  \param [in] locName - the name of the new localization.
3865  *  \param [in] geoType - a geometrical type of the reference cell.
3866  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3867  *         must be \c nbOfNodesPerCell * \c dimOfType.
3868  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3869  *         must be  _wg_.size() * \c dimOfType.
3870  *  \param [in] w - the weights of Gauss points.
3871  *  \throw If \a locName is empty.
3872  *  \throw If a localization with the name \a locName already exists but is
3873  *         different form the new one.
3874  */
3875 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)
3876 {
3877   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3878 }
3879
3880 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3881 {
3882   MEDFileFieldGlobs *g(_globals);
3883   if(!g)
3884     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3885   return g;
3886 }
3887
3888 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3889 {
3890   const MEDFileFieldGlobs *g(_globals);
3891   if(!g)
3892     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3893   return g;
3894 }
3895
3896 //= MEDFileFieldNameScope
3897
3898 MEDFileFieldNameScope::MEDFileFieldNameScope()
3899 {
3900 }
3901
3902 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3903 {
3904 }
3905
3906 /*!
3907  * Returns the name of \a this field.
3908  *  \return std::string - a string containing the field name.
3909  */
3910 std::string MEDFileFieldNameScope::getName() const
3911 {
3912   return _name;
3913 }
3914
3915 /*!
3916  * Sets name of \a this field
3917  *  \param [in] name - the new field name.
3918  */
3919 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3920 {
3921   _name=fieldName;
3922 }
3923
3924 std::string MEDFileFieldNameScope::getDtUnit() const
3925 {
3926   return _dt_unit;
3927 }
3928
3929 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3930 {
3931   _dt_unit=dtUnit;
3932 }
3933
3934 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3935 {
3936   _name=other._name;
3937   _dt_unit=other._dt_unit;
3938 }
3939
3940 //= MEDFileAnyTypeField1TSWithoutSDA
3941
3942 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3943 {
3944   _field_per_mesh.resize(other._field_per_mesh.size());
3945   std::size_t i=0;
3946   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3947     {
3948       if((const MEDFileFieldPerMesh *)*it)
3949         _field_per_mesh[i]=(*it)->deepCopy(this);
3950     }
3951 }
3952
3953 /*!
3954  * Prints a string describing \a this field into a stream. This string is outputted 
3955  * by \c print Python command.
3956  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3957  *  \param [in,out] oss - the out stream.
3958  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3959  *          info id printed, else, not.
3960  */
3961 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3962 {
3963   std::string startOfLine(bkOffset,' ');
3964   oss << startOfLine << "Field ";
3965   if(bkOffset==0)
3966     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3967   oss << "on one time Step ";
3968   if(f1tsId>=0)
3969     oss << "(" << f1tsId << ") ";
3970   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3971   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3972   const DataArray *arr=getUndergroundDataArray();
3973   if(arr)
3974     {
3975       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3976       if(f1tsId<0)
3977         {
3978           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3979           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3980             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3981         }
3982       if(arr->isAllocated())
3983         {
3984           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3985         }
3986       else
3987         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3988     }
3989   else
3990     {
3991       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3992     }
3993   oss << startOfLine << "----------------------" << std::endl;
3994   if(!_field_per_mesh.empty())
3995     {
3996       int i=0;
3997       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3998         {
3999           const MEDFileFieldPerMesh *cur=(*it2);
4000           if(cur)
4001             cur->simpleRepr(bkOffset,oss,i);
4002           else
4003             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4004         }
4005     }
4006   else
4007     {
4008       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4009     }
4010   oss << startOfLine << "----------------------" << std::endl;
4011 }
4012
4013 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4014 {
4015   const DataArray *arr(getUndergroundDataArray());
4016   if(!arr)
4017     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4018   int nbOfCompo=arr->getNumberOfComponents();
4019   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4020   for(int i=0;i<nbOfCompo;i++)
4021     {
4022       ret[i]=deepCopy();
4023       std::vector<int> v(1,i);
4024       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4025       ret[i]->setArray(arr2);
4026     }
4027   return ret;
4028 }
4029
4030 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)
4031 {
4032 }
4033
4034 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4035 {
4036 }
4037
4038 /*!
4039  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4040  * empty. Returns -1 if this in on nodes.
4041  *  \return int - the dimension of \a this.
4042  */
4043 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4044 {
4045   int ret=-2;
4046   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4047     (*it)->getDimension(ret);
4048   return ret;
4049 }
4050
4051 /*!
4052  * Returns the mesh name.
4053  *  \return std::string - a string holding the mesh name.
4054  *  \throw If \c _field_per_mesh.empty()
4055  */
4056 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4057 {
4058   if(_field_per_mesh.empty())
4059     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4060   return _field_per_mesh[0]->getMeshName();
4061 }
4062
4063 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4064 {
4065   std::string oldName(getMeshName());
4066   std::vector< std::pair<std::string,std::string> > v(1);
4067   v[0].first=oldName; v[0].second=newMeshName;
4068   changeMeshNames(v);
4069 }
4070
4071 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4072 {
4073   bool ret=false;
4074   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4075     {
4076       MEDFileFieldPerMesh *cur(*it);
4077       if(cur)
4078         ret=cur->changeMeshNames(modifTab) || ret;
4079     }
4080   return ret;
4081 }
4082
4083 /*!
4084  * Returns the number of iteration of the state of underlying mesh.
4085  *  \return int - the iteration number.
4086  *  \throw If \c _field_per_mesh.empty()
4087  */
4088 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4089 {
4090   if(_field_per_mesh.empty())
4091     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4092   return _field_per_mesh[0]->getMeshIteration();
4093 }
4094
4095 /*!
4096  * Returns the order number of iteration of the state of underlying mesh.
4097  *  \return int - the order number.
4098  *  \throw If \c _field_per_mesh.empty()
4099  */
4100 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4101 {
4102   if(_field_per_mesh.empty())
4103     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4104   return _field_per_mesh[0]->getMeshOrder();
4105 }
4106
4107 /*!
4108  * Checks if \a this field is tagged by a given iteration number and a given
4109  * iteration order number.
4110  *  \param [in] iteration - the iteration number of interest.
4111  *  \param [in] order - the iteration order number of interest.
4112  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4113  *          \a this->getOrder() == \a order.
4114  */
4115 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4116 {
4117   return iteration==_iteration && order==_order;
4118 }
4119
4120 /*!
4121  * Returns number of iteration and order number of iteration when
4122  * \a this field has been calculated.
4123  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4124  *          order number.
4125  */
4126 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4127 {
4128   std::pair<int,int> p;
4129   fillIteration(p);
4130   return p;
4131 }
4132
4133 /*!
4134  * Returns number of iteration and order number of iteration when
4135  * \a this field has been calculated.
4136  *  \param [in,out] p - a pair returning the iteration number and the iteration
4137  *          order number.
4138  */
4139 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4140 {
4141   p.first=_iteration;
4142   p.second=_order;
4143 }
4144
4145 /*!
4146  * Returns all types of spatial discretization of \a this field.
4147  *  \param [in,out] types - a sequence of types of \a this field.
4148  */
4149 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4150 {
4151   std::set<TypeOfField> types2;
4152   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4153     {
4154       (*it)->fillTypesOfFieldAvailable(types2);
4155     }
4156   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4157   std::copy(types2.begin(),types2.end(),bi);
4158 }
4159
4160 /*!
4161  * Returns all types of spatial discretization of \a this field.
4162  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4163  *          of \a this field.
4164  */
4165 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4166 {
4167   std::vector<TypeOfField> ret;
4168   fillTypesOfFieldAvailable(ret);
4169   return ret;
4170 }
4171
4172 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4173 {
4174   std::vector<std::string> ret;
4175   std::set<std::string> ret2;
4176   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4177     {
4178       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4179       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4180         if(ret2.find(*it2)==ret2.end())
4181           {
4182             ret.push_back(*it2);
4183             ret2.insert(*it2);
4184           }
4185     }
4186   return ret;
4187 }
4188
4189 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4190 {
4191   std::vector<std::string> ret;
4192   std::set<std::string> ret2;
4193   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4194     {
4195       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4196       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4197         if(ret2.find(*it2)==ret2.end())
4198           {
4199             ret.push_back(*it2);
4200             ret2.insert(*it2);
4201           }
4202     }
4203   return ret;
4204 }
4205
4206 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4207 {
4208   std::vector<std::string> ret;
4209   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4210     {
4211       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4212       ret.insert(ret.end(),tmp.begin(),tmp.end());
4213     }
4214   return ret;
4215 }
4216
4217 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4218 {
4219   std::vector<std::string> ret;
4220   std::set<std::string> ret2;
4221   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4222     {
4223       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4224       ret.insert(ret.end(),tmp.begin(),tmp.end());
4225     }
4226   return ret;
4227 }
4228
4229 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4230 {
4231   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4232     (*it)->changePflsRefsNamesGen(mapOfModif);
4233 }
4234
4235 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4236 {
4237   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4238     (*it)->changeLocsRefsNamesGen(mapOfModif);
4239 }
4240
4241 /*!
4242  * Returns all attributes of parts of \a this field lying on a given mesh.
4243  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4244  * item of every of returned sequences refers to the _i_-th part of \a this field.
4245  * Thus all sequences returned by this method are of the same length equal to number
4246  * of different types of supporting entities.<br>
4247  * A field part can include sub-parts with several different spatial discretizations,
4248  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4249  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4250  * of a nested sequence corresponds to a type of spatial discretization.<br>
4251  * This method allows for iteration over MEDFile DataStructure without any overhead.
4252  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4253  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4254  *          not checked if \a mname == \c NULL).
4255  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4256  *          a field part is returned. 
4257  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4258  *          This sequence is of the same length as \a types. 
4259  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4260  *          discretization. A profile name can be empty.
4261  *          Length of this and of nested sequences is the same as that of \a typesF.
4262  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4263  *          discretization. A localization name can be empty.
4264  *          Length of this and of nested sequences is the same as that of \a typesF.
4265  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4266  *          of ids of tuples within the data array, per each type of spatial
4267  *          discretization within one mesh entity type. 
4268  *          Length of this and of nested sequences is the same as that of \a typesF.
4269  *  \throw If no field is lying on \a mname.
4270  */
4271 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
4272 {
4273   int meshId=0;
4274   if(!mname.empty())
4275     meshId=getMeshIdFromMeshName(mname);
4276   else
4277     if(_field_per_mesh.empty())
4278       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4279   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4280 }
4281
4282 /*!
4283  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4284  * maximal absolute dimension and values returned via the out parameter \a levs are 
4285  * dimensions relative to the maximal absolute dimension. <br>
4286  * This method is designed for MEDFileField1TS instances that have a discretization
4287  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4288  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4289  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4290  * Only these 3 discretizations will be taken into account here. If \a this is
4291  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4292  * This method is useful to make the link between the dimension of the underlying mesh
4293  * and the levels of \a this, because it is possible that the highest dimension of \a this
4294  * field is not equal to the dimension of the underlying mesh.
4295  * 
4296  * Let's consider the following case:
4297  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4298  * TETRA4, HEXA8, TRI3 and SEG2.
4299  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4300  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4301  *
4302  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4303  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4304  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4305  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4306  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4307  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4308  * For example<br>
4309  * to retrieve the highest level of
4310  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4311  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4312  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4313  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4314  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4315  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4316  *          not checked if \a mname == \c NULL).
4317  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4318  *          absolute one. They are in decreasing order. This sequence is cleared before
4319  *          filling it in.
4320  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4321  *  \throw If no field is lying on \a mname.
4322  */
4323 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4324 {
4325   levs.clear();
4326   int meshId=getMeshIdFromMeshName(mname);
4327   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4328   std::vector< std::vector<TypeOfField> > typesF;
4329   std::vector< std::vector<std::string> > pfls, locs;
4330   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4331   if(types.empty())
4332     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4333   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4334   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4335     return -1;
4336   st.erase(INTERP_KERNEL::NORM_ERROR);
4337   std::set<int> ret1;
4338   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4339     {
4340       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4341       ret1.insert((int)cm.getDimension());
4342     }
4343   int ret=*std::max_element(ret1.begin(),ret1.end());
4344   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4345   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4346   return ret;
4347 }
4348
4349 /*!
4350  * \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.
4351  * \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.
4352  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4353  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4354  */
4355 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4356 {
4357   int mid=getMeshIdFromMeshName(mName);
4358   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4359 }
4360
4361 /*!
4362  * \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.
4363  * \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.
4364  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4365  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4366  */
4367 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4368 {
4369   int mid=getMeshIdFromMeshName(mName);
4370   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4371 }
4372
4373 /*!
4374  * \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.
4375  */
4376 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4377 {
4378   if(_field_per_mesh.empty())
4379     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4380   if(mName.empty())
4381     return 0;
4382   std::string mName2(mName);
4383   int ret=0;
4384   std::vector<std::string> msg;
4385   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4386     if(mName2==(*it)->getMeshName())
4387       return ret;
4388     else
4389       msg.push_back((*it)->getMeshName());
4390   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4391   oss << "Possible meshes are : ";
4392   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4393     oss << "\"" << (*it2) << "\" ";
4394   throw INTERP_KERNEL::Exception(oss.str());
4395 }
4396
4397 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4398 {
4399   if(!mesh)
4400     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4401   std::string tmp(mesh->getName());
4402   if(tmp.empty())
4403     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4404   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4405   int i=0;
4406   for(;it!=_field_per_mesh.end();it++,i++)
4407     {
4408       if((*it)->getMeshName()==tmp)
4409         return i;
4410     }
4411   int sz=_field_per_mesh.size();
4412   _field_per_mesh.resize(sz+1);
4413   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4414   return sz;
4415 }
4416
4417 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4418                                                                    MEDFileFieldGlobsReal& glob)
4419 {
4420   bool ret=false;
4421   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4422     {
4423       MEDFileFieldPerMesh *fpm(*it);
4424       if(fpm)
4425         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4426     }
4427   return ret;
4428 }
4429
4430 /*!
4431  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4432  * splitting that leads to single spatial discretization of this.
4433  *
4434  * \sa splitMultiDiscrPerGeoTypes
4435  */
4436 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4437 {
4438   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4439   std::vector< std::vector<TypeOfField> > typesF;
4440   std::vector< std::vector<std::string> > pfls,locs;
4441   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4442   std::set<TypeOfField> allEnt;
4443   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4444     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4445       allEnt.insert(*it2);
4446   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4447   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4448   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4449     {
4450       std::vector< std::pair<int,int> > its;
4451       ret[i]=shallowCpy();
4452       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4453       ret[i]->updateData(newLgth,its);
4454     }
4455   return ret;
4456 }
4457
4458 /*!
4459  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4460  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4461  *
4462  * \sa splitDiscretizations
4463  */
4464 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4465 {
4466   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4467   std::vector< std::vector<TypeOfField> > typesF;
4468   std::vector< std::vector<std::string> > pfls,locs;
4469   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4470   std::set<TypeOfField> allEnt;
4471   std::size_t nbOfMDPGT(0),ii(0);
4472   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4473     {
4474       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4475       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4476         allEnt.insert(*it2);
4477     }
4478   if(allEnt.size()!=1)
4479     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4480   if(nbOfMDPGT==0)
4481     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4482   if(nbOfMDPGT==1)
4483     {
4484       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4485       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4486       return ret0;
4487     }
4488   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4489   for(std::size_t i=0;i<nbOfMDPGT;i++)
4490     {
4491       std::vector< std::pair<int,int> > its;
4492       ret[i]=shallowCpy();
4493       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4494       ret[i]->updateData(newLgth,its);
4495     }
4496   return ret;
4497 }
4498
4499 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4500 {
4501   int globalCounter(0);
4502   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4503     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4504   return globalCounter;
4505 }
4506
4507 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4508 {
4509   int globalCounter(0);
4510   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4511     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4512   return globalCounter;
4513 }
4514
4515 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4516 {
4517   if(_nb_of_tuples_to_be_allocated>=0)
4518     {
4519       _nb_of_tuples_to_be_allocated=newLgth;
4520       const DataArray *oldArr(getUndergroundDataArray());
4521       if(oldArr)
4522         {
4523           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4524           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4525           setArray(newArr);
4526           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4527         }
4528       return ;
4529     }
4530   if(_nb_of_tuples_to_be_allocated==-1)
4531     return ;
4532   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4533     {
4534       const DataArray *oldArr(getUndergroundDataArray());
4535       if(!oldArr || !oldArr->isAllocated())
4536         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4537       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4538       newArr->alloc(newLgth,getNumberOfComponents());
4539       if(oldArr)
4540         newArr->copyStringInfoFrom(*oldArr);
4541       int pos=0;
4542       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4543         {
4544           if((*it).second<(*it).first)
4545             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4546           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4547           pos+=(*it).second-(*it).first;
4548         }
4549       setArray(newArr);
4550       return ;
4551     }
4552   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4553 }
4554
4555 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4556 {
4557   if(_field_per_mesh.empty())
4558     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4559   if(_field_per_mesh.size()>1)
4560     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4561   _field_per_mesh[0]->copyOptionsFrom(opts);
4562   _field_per_mesh[0]->writeLL(fid,nasc);
4563 }
4564
4565 /*!
4566  * 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.
4567  * If false is returned the memory allocation is not required.
4568  */
4569 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4570 {
4571   if(_nb_of_tuples_to_be_allocated>=0)
4572     {
4573       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4574       _nb_of_tuples_to_be_allocated=-2;
4575       return true;
4576     }
4577   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4578     return false;
4579   if(_nb_of_tuples_to_be_allocated==-1)
4580     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4581   if(_nb_of_tuples_to_be_allocated<-3)
4582     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4583   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4584 }
4585
4586 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4587 {
4588   med_int numdt,numit;
4589   med_float dt;
4590   med_int nmesh;
4591   med_bool localMesh;
4592   med_int meshnumdt,meshnumit;
4593   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4594   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4595   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4596   if(_iteration!=numdt || _order!=numit)
4597     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4598   _field_per_mesh.resize(nmesh);
4599   //
4600   MEDFileMesh *mm(0);
4601   if(ms)
4602     {
4603       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4604       mm=ms->getMeshWithName(meshNameCpp);
4605     }
4606   //
4607   for(int i=0;i<nmesh;i++)
4608     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4609   _nb_of_tuples_to_be_allocated=0;
4610   for(int i=0;i<nmesh;i++)
4611     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4612 }
4613
4614 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4615 {
4616   allocIfNecessaryTheArrayToReceiveDataFromFile();
4617   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4618     (*it)->loadBigArraysRecursively(fid,nasc);
4619 }
4620
4621 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4622 {
4623   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4624     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4625       (*it)->loadBigArraysRecursively(fid,nasc);
4626 }
4627
4628 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4629 {
4630   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4631   loadBigArraysRecursively(fid,nasc);
4632 }
4633
4634 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4635 {
4636   DataArray *thisArr(getUndergroundDataArray());
4637   if(thisArr && thisArr->isAllocated())
4638     {
4639       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4640       thisArr->desallocate();
4641     }
4642 }
4643
4644 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4645 {
4646   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4647 }
4648
4649 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4650 {
4651   std::vector<const BigMemoryObject *> ret;
4652   if(getUndergroundDataArray())
4653     ret.push_back(getUndergroundDataArray());
4654   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4655     ret.push_back((const MEDFileFieldPerMesh *)*it);
4656   return ret;
4657 }
4658
4659 /*!
4660  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4661  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4662  * "Sort By Type"), if not, an exception is thrown. 
4663  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4664  *  \param [in] arr - the array of values.
4665  *  \param [in,out] glob - the global data where profiles and localization present in
4666  *          \a field, if any, are added.
4667  *  \throw If the name of \a field is empty.
4668  *  \throw If the data array of \a field is not set.
4669  *  \throw If \a this->_arr is already allocated but has different number of components
4670  *         than \a field.
4671  *  \throw If the underlying mesh of \a field has no name.
4672  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4673  */
4674 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4675 {
4676   const MEDCouplingMesh *mesh=field->getMesh();
4677   //
4678   TypeOfField type=field->getTypeOfField();
4679   std::vector<DataArrayInt *> dummy;
4680   int start=copyTinyInfoFrom(field,arr);
4681   int pos=addNewEntryIfNecessary(mesh);
4682   if(type!=ON_NODES)
4683     {
4684       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4685       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4686     }
4687   else
4688     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4689 }
4690
4691 /*!
4692  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4693  * of a given mesh are used as the support of the given field (a real support is not used). 
4694  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4695  * Order of underlying mesh entities of the given field specified by \a profile parameter
4696  * is not prescribed; this method permutes field values to have them sorted by element
4697  * type as required for writing to MED file. A new profile is added only if no equal
4698  * profile is missing. 
4699  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4700  *  \param [in] arrOfVals - the values of the field \a field used.
4701  *  \param [in] mesh - the supporting mesh of \a field.
4702  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4703  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4704  *  \param [in,out] glob - the global data where profiles and localization present in
4705  *          \a field, if any, are added.
4706  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4707  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4708  *  \throw If the data array of \a field is not set.
4709  *  \throw If \a this->_arr is already allocated but has different number of components
4710  *         than \a field.
4711  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4712  *  \sa setFieldNoProfileSBT()
4713  */
4714 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4715 {
4716   if(!field)
4717     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4718   if(!arrOfVals || !arrOfVals->isAllocated())
4719     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4720   TypeOfField type=field->getTypeOfField();
4721   std::vector<DataArrayInt *> idsInPflPerType;
4722   std::vector<DataArrayInt *> idsPerType;
4723   std::vector<int> code,code2;
4724   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4725   if(type!=ON_NODES)
4726     {
4727       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4728       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4729       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4730       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4731       // start of check
4732       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4733       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4734       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4735         {
4736           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4737           throw INTERP_KERNEL::Exception(oss.str());
4738         }
4739       // end of check
4740       int start=copyTinyInfoFrom(field,arrOfVals);
4741       code2=m->getDistributionOfTypes();
4742       //
4743       int pos=addNewEntryIfNecessary(m);
4744       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4745     }
4746   else
4747     {
4748       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4749         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4750       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4751       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4752       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4753       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4754         {
4755           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4756           throw INTERP_KERNEL::Exception(oss.str());
4757         }
4758       int start=copyTinyInfoFrom(field,arrOfVals);
4759       int pos=addNewEntryIfNecessary(m);
4760       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4761     }
4762 }
4763
4764 /*!
4765  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4766  */
4767 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4768 {
4769   if(_nb_of_tuples_to_be_allocated>=0)
4770     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 !");
4771   DataArray *arr(getOrCreateAndGetArray());
4772   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4773   _nb_of_tuples_to_be_allocated=-3;
4774 }
4775
4776 /*!
4777  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4778  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4779  * larger by the size of \a field. Returns an id of the first not filled
4780  * tuple of \a this->_arr.
4781  *  \param [in] field - the field to copy the info on components and the name from.
4782  *  \return int - the id of first not initialized tuple of \a this->_arr.
4783  *  \throw If the name of \a field is empty.
4784  *  \throw If the data array of \a field is not set.
4785  *  \throw If \a this->_arr is already allocated but has different number of components
4786  *         than \a field.
4787  */
4788 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4789 {
4790   if(!field)
4791     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4792   std::string name(field->getName());
4793   setName(name.c_str());
4794   setDtUnit(field->getTimeUnit());
4795   if(name.empty())
4796     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4797   if(!arr)
4798     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4799   if(!arr->isAllocated())
4800     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4801   _dt=field->getTime(_iteration,_order);
4802   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4803   if(!getOrCreateAndGetArray()->isAllocated())
4804     {
4805       allocNotFromFile(arr->getNumberOfTuples());
4806       return 0;
4807     }
4808   else
4809     {
4810       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4811       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4812       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4813       _nb_of_tuples_to_be_allocated=-3;
4814       return oldNbOfTuples;
4815     }
4816 }
4817
4818 /*!
4819  * Returns number of components in \a this field
4820  *  \return int - the number of components.
4821  */
4822 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4823 {
4824   return getOrCreateAndGetArray()->getNumberOfComponents();
4825 }
4826
4827 /*!
4828  * Change info on components in \a this.
4829  * \throw If size of \a infos is not equal to the number of components already in \a this.
4830  */
4831 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4832 {
4833   DataArray *arr=getOrCreateAndGetArray();
4834   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4835 }
4836
4837 /*!
4838  * Returns info on components of \a this field.
4839  *  \return const std::vector<std::string>& - a sequence of strings each being an
4840  *          information on _i_-th component.
4841  */
4842 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4843 {
4844   const DataArray *arr=getOrCreateAndGetArray();
4845   return arr->getInfoOnComponents();
4846 }
4847
4848 /*!
4849  * Returns a mutable info on components of \a this field.
4850  *  \return std::vector<std::string>& - a sequence of strings each being an
4851  *          information on _i_-th component.
4852  */
4853 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4854 {
4855   DataArray *arr=getOrCreateAndGetArray();
4856   return arr->getInfoOnComponents();
4857 }
4858
4859 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4860 {
4861   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4862     {
4863       const MEDFileFieldPerMesh *fpm(*it);
4864       if(!fpm)
4865         continue;
4866       if(fpm->presenceOfMultiDiscPerGeoType())
4867         return true;
4868     }
4869   return false;
4870 }
4871
4872 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4873 {
4874   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 !";
4875   if(_field_per_mesh.empty())
4876     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4877   if(_field_per_mesh.size()>1)
4878     throw INTERP_KERNEL::Exception(MSG0);
4879   if(_field_per_mesh[0].isNull())
4880     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4881   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4882   std::set<TypeOfField> types;
4883   pm->fillTypesOfFieldAvailable(types);
4884   if(types.size()!=1)
4885     throw INTERP_KERNEL::Exception(MSG0);
4886   TypeOfField type(*types.begin());
4887   int meshDimRelToMax(0);
4888   if(type==ON_NODES)
4889     meshDimRelToMax=0;
4890   else
4891     {
4892       int myDim(std::numeric_limits<int>::max());
4893       bool isUnique(pm->isUniqueLevel(myDim));
4894       if(!isUnique)
4895         throw INTERP_KERNEL::Exception(MSG0);
4896       meshDimRelToMax=myDim-mesh->getMeshDimension();
4897       if(meshDimRelToMax>0)
4898         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4899     }
4900   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4901 }
4902
4903 /*!
4904  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4905  *  \param [in] type - a spatial discretization of the new field.
4906  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4907  *  \param [in] mName - a name of the supporting mesh.
4908  *  \param [in] renumPol - specifies how to permute values of the result field according to
4909  *          the optional numbers of cells and nodes, if any. The valid values are
4910  *          - 0 - do not permute.
4911  *          - 1 - permute cells.
4912  *          - 2 - permute nodes.
4913  *          - 3 - permute cells and nodes.
4914  *
4915  *  \param [in] glob - the global data storing profiles and localization.
4916  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4917  *          caller is to delete this field using decrRef() as it is no more needed. 
4918  *  \throw If the MED file is not readable.
4919  *  \throw If there is no mesh named \a mName in the MED file.
4920  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4921  *  \throw If no field of \a this is lying on the mesh \a mName.
4922  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4923  */
4924 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4925 {
4926   MCAuto<MEDFileMesh> mm;
4927   if(mName.empty())
4928     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4929   else
4930     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4931   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4932 }
4933
4934 /*!
4935  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4936  *  \param [in] type - a spatial discretization of the new field.
4937  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4938  *  \param [in] renumPol - specifies how to permute values of the result field according to
4939  *          the optional numbers of cells and nodes, if any. The valid values are
4940  *          - 0 - do not permute.
4941  *          - 1 - permute cells.
4942  *          - 2 - permute nodes.
4943  *          - 3 - permute cells and nodes.
4944  *
4945  *  \param [in] glob - the global data storing profiles and localization.
4946  *  \param [in] mesh - the supporting mesh.
4947  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4948  *          caller is to delete this field using decrRef() as it is no more needed. 
4949  *  \throw If the MED file is not readable.
4950  *  \throw If no field of \a this is lying on \a mesh.
4951  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4952  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4953  */
4954 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4955 {
4956   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4957   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4958   if(meshDimRelToMax==1)
4959     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4960   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4961 }
4962
4963 /*!
4964  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4965  * given mesh. 
4966  *  \param [in] type - a spatial discretization of the new field.
4967  *  \param [in] mName - a name of the supporting mesh.
4968  *  \param [in] renumPol - specifies how to permute values of the result field according to
4969  *          the optional numbers of cells and nodes, if any. The valid values are
4970  *          - 0 - do not permute.
4971  *          - 1 - permute cells.
4972  *          - 2 - permute nodes.
4973  *          - 3 - permute cells and nodes.
4974  *
4975  *  \param [in] glob - the global data storing profiles and localization.
4976  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4977  *          caller is to delete this field using decrRef() as it is no more needed. 
4978  *  \throw If the MED file is not readable.
4979  *  \throw If there is no mesh named \a mName in the MED file.
4980  *  \throw If there are no mesh entities in the mesh.
4981  *  \throw If no field values of the given \a type are available.
4982  */
4983 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4984 {
4985   MCAuto<MEDFileMesh> mm;
4986   if(mName.empty())
4987     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4988   else
4989     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4990   int absDim=getDimension();
4991   int meshDimRelToMax=absDim-mm->getMeshDimension();
4992   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4993 }
4994
4995 /*!
4996  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4997  *  \param [in] type - a spatial discretization of the new field.
4998  *  \param [in] renumPol - specifies how to permute values of the result field according to
4999  *          the optional numbers of cells and nodes, if any. The valid values are
5000  *          - 0 - do not permute.
5001  *          - 1 - permute cells.
5002  *          - 2 - permute nodes.
5003  *          - 3 - permute cells and nodes.
5004  *
5005  *  \param [in] glob - the global data storing profiles and localization.
5006  *  \param [in] mesh - the supporting mesh.
5007  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5008  *         field according to \a renumPol.
5009  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5010  *         field according to \a renumPol.
5011  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5012  *          caller is to delete this field using decrRef() as it is no more needed. 
5013  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5014  *  \throw If no field of \a this is lying on \a mesh.
5015  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5016  */
5017 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
5018 {
5019   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5020   int meshId=getMeshIdFromMeshName(mesh->getName());
5021   bool isPfl=false;
5022   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5023   switch(renumPol)
5024   {
5025     case 0:
5026       {
5027         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5028         return ret.retn();
5029       }
5030     case 3:
5031     case 1:
5032       {
5033         if(isPfl)
5034           throw INTERP_KERNEL::Exception(msg1);
5035         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5036         if(cellRenum)
5037           {
5038             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5039               {
5040                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5041                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5042                 throw INTERP_KERNEL::Exception(oss.str());
5043               }
5044             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5045             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5046             std::vector<DataArray *> arrOut2(1,arrOut);
5047             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5048             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5049             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5050           }
5051         if(renumPol==1)
5052           return ret.retn();
5053       }
5054     case 2:
5055       {
5056         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5057         if(isPfl)
5058           throw INTERP_KERNEL::Exception(msg1);
5059         if(nodeRenum)
5060           {
5061             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5062               {
5063                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5064                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5065                 throw INTERP_KERNEL::Exception(oss.str());
5066               }
5067             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5068             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5069               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5070             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5071           }
5072         return ret.retn();
5073       }
5074     default:
5075       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5076   }
5077 }
5078
5079 /*!
5080  * Returns values and a profile of the field of a given type lying on a given support.
5081  *  \param [in] type - a spatial discretization of the field.
5082  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5083  *  \param [in] mesh - the supporting mesh.
5084  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5085  *          field of interest lies on. If the field lies on all entities of the given
5086  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5087  *          using decrRef() as it is no more needed.  
5088  *  \param [in] glob - the global data storing profiles and localization.
5089  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5090  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5091  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5092  *  \throw If no field of \a this is lying on \a mesh.
5093  *  \throw If no field values of the given \a type are available.
5094  */
5095 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5096 {
5097   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5098   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5099   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5100   ret->setName(nasc.getName().c_str());
5101   return ret.retn();
5102 }
5103
5104 //= MEDFileField1TSWithoutSDA
5105
5106 /*!
5107  * Throws if a given value is not a valid (non-extended) relative dimension.
5108  *  \param [in] meshDimRelToMax - the relative dimension value.
5109  *  \throw If \a meshDimRelToMax > 0.
5110  */
5111 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5112 {
5113   if(meshDimRelToMax>0)
5114     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5115 }
5116
5117 /*!
5118  * Checks if elements of a given mesh are in the order suitable for writing 
5119  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5120  * vector describing types of elements and their number.
5121  *  \param [in] mesh - the mesh to check.
5122  *  \return std::vector<int> - a vector holding for each element type (1) item of
5123  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5124  *          These values are in full-interlace mode.
5125  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5126  */
5127 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5128 {
5129   if(!mesh)
5130     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5131   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5132   int nbOfTypes=geoTypes.size();
5133   std::vector<int> code(3*nbOfTypes);
5134   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5135   arr1->alloc(nbOfTypes,1);
5136   int *arrPtr=arr1->getPointer();
5137   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5138   for(int i=0;i<nbOfTypes;i++,it++)
5139     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5140   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5141   const int *arrPtr2=arr2->getConstPointer();
5142   int i=0;
5143   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5144     {
5145       int pos=arrPtr2[i];
5146       int nbCells=mesh->getNumberOfCellsWithType(*it);
5147       code[3*pos]=(int)(*it);
5148       code[3*pos+1]=nbCells;
5149       code[3*pos+2]=-1;//no profiles
5150     }
5151   std::vector<const DataArrayInt *> idsPerType;//no profiles
5152   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5153   if(da)
5154     {
5155       da->decrRef();
5156       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5157     }
5158   return code;
5159 }
5160
5161 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5162 {
5163   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5164 }
5165
5166 /*!
5167  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5168  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5169  * item of every of returned sequences refers to the _i_-th part of \a this field.
5170  * Thus all sequences returned by this method are of the same length equal to number
5171  * of different types of supporting entities.<br>
5172  * A field part can include sub-parts with several different spatial discretizations,
5173  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5174  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5175  * of a nested sequence corresponds to a type of spatial discretization.<br>
5176  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5177  * The overhead is due to selecting values into new instances of DataArrayDouble.
5178  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5179  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5180  *          not checked if \a mname == \c NULL).
5181  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5182  *          a field part is returned. 
5183  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5184  *          A field part can include sub-parts with several different spatial discretizations,
5185  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5186  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5187  *          This sequence is of the same length as \a types. 
5188  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5189  *          discretization. A profile name can be empty.
5190  *          Length of this and of nested sequences is the same as that of \a typesF.
5191  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5192  *          discretization. A localization name can be empty.
5193  *          Length of this and of nested sequences is the same as that of \a typesF.
5194  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5195  *          per each type of spatial discretization within one mesh entity type.
5196  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5197  *          Length of this and of nested sequences is the same as that of \a typesF.
5198  *  \throw If no field is lying on \a mname.
5199  */
5200 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
5201 {
5202   int meshId=0;
5203   if(!mname.empty())
5204     meshId=getMeshIdFromMeshName(mname);
5205   else
5206     if(_field_per_mesh.empty())
5207       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5208   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5209   int nbOfRet=ret0.size();
5210   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5211   for(int i=0;i<nbOfRet;i++)
5212     {
5213       const std::vector< std::pair<int,int> >& p=ret0[i];
5214       int nbOfRet1=p.size();
5215       ret[i].resize(nbOfRet1);
5216       for(int j=0;j<nbOfRet1;j++)
5217         {
5218           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5219           ret[i][j]=tmp;
5220         }
5221     }
5222   return ret;
5223 }
5224
5225 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5226 {
5227   return TYPE_STR;
5228 }
5229
5230 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5231 {
5232   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5233   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5234   ret->deepCpyLeavesFrom(*this);
5235   const DataArrayDouble *arr(_arr);
5236   if(arr)
5237     {
5238       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5239       ret->setArray(arr2);
5240     }
5241   return ret.retn();
5242 }
5243
5244 /*!
5245  * Returns a pointer to the underground DataArrayDouble instance and a
5246  * sequence describing parameters of a support of each part of \a this field. The
5247  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5248  * direct access to the field values. This method is intended for the field lying on one
5249  * mesh only.
5250  *  \param [in,out] entries - the sequence describing parameters of a support of each
5251  *         part of \a this field. Each item of this sequence consists of two parts. The
5252  *         first part describes a type of mesh entity and an id of discretization of a
5253  *         current field part. The second part describes a range of values [begin,end)
5254  *         within the returned array relating to the current field part.
5255  *  \return DataArrayDouble * - the pointer to the field values array.
5256  *  \throw If the number of underlying meshes is not equal to 1.
5257  *  \throw If no field values are available.
5258  *  \sa getUndergroundDataArray()
5259  */
5260 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5261 {
5262   if(_field_per_mesh.size()!=1)
5263     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5264   if(_field_per_mesh[0]==0)
5265     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5266   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5267   return getUndergroundDataArrayTemplate();
5268 }
5269
5270 /*!
5271  * Returns a pointer to the underground DataArrayDouble instance and a
5272  * sequence describing parameters of a support of each part of \a this field. The
5273  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5274  * direct access to the field values. This method is intended for the field lying on one
5275  * mesh only.
5276  *  \param [in,out] entries - the sequence describing parameters of a support of each
5277  *         part of \a this field. Each item of this sequence consists of two parts. The
5278  *         first part describes a type of mesh entity and an id of discretization of a
5279  *         current field part. The second part describes a range of values [begin,end)
5280  *         within the returned array relating to the current field part.
5281  *  \return DataArrayDouble * - the pointer to the field values array.
5282  *  \throw If the number of underlying meshes is not equal to 1.
5283  *  \throw If no field values are available.
5284  *  \sa getUndergroundDataArray()
5285  */
5286 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5287 {
5288   return getUndergroundDataArrayDoubleExt(entries);
5289 }
5290
5291 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5292 {
5293   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5294   arr->setInfoAndChangeNbOfCompo(infos);
5295 }
5296
5297 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5298 {
5299 }
5300
5301 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5302 {
5303   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5304   ret->deepCpyLeavesFrom(*this);
5305   return ret.retn();
5306 }
5307
5308 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5309 {
5310   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5311   if((const DataArrayDouble *)_arr)
5312     ret->_arr=_arr->deepCopy();
5313   return ret.retn();
5314 }
5315
5316 //= MEDFileIntField1TSWithoutSDA
5317
5318 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5319 {
5320   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5321 }
5322
5323 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5324 {
5325 }
5326
5327 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5328                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5329 {
5330   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5331   arr->setInfoAndChangeNbOfCompo(infos);
5332 }
5333
5334 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5335 {
5336   return TYPE_STR;
5337 }
5338
5339 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5340 {
5341   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5342   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5343   ret->deepCpyLeavesFrom(*this);
5344   const DataArrayInt *arr(_arr);
5345   if(arr)
5346     {
5347       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5348       ret->setArray(arr2);
5349     }
5350   return ret.retn();
5351 }
5352
5353 /*!
5354  * Returns a pointer to the underground DataArrayInt instance and a
5355  * sequence describing parameters of a support of each part of \a this field. The
5356  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5357  * direct access to the field values. This method is intended for the field lying on one
5358  * mesh only.
5359  *  \param [in,out] entries - the sequence describing parameters of a support of each
5360  *         part of \a this field. Each item of this sequence consists of two parts. The
5361  *         first part describes a type of mesh entity and an id of discretization of a
5362  *         current field part. The second part describes a range of values [begin,end)
5363  *         within the returned array relating to the current field part.
5364  *  \return DataArrayInt * - the pointer to the field values array.
5365  *  \throw If the number of underlying meshes is not equal to 1.
5366  *  \throw If no field values are available.
5367  *  \sa getUndergroundDataArray()
5368  */
5369 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5370 {
5371   return getUndergroundDataArrayIntExt(entries);
5372 }
5373
5374 /*!
5375  * Returns a pointer to the underground DataArrayInt instance and a
5376  * sequence describing parameters of a support of each part of \a this field. The
5377  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5378  * direct access to the field values. This method is intended for the field lying on one
5379  * mesh only.
5380  *  \param [in,out] entries - the sequence describing parameters of a support of each
5381  *         part of \a this field. Each item of this sequence consists of two parts. The
5382  *         first part describes a type of mesh entity and an id of discretization of a
5383  *         current field part. The second part describes a range of values [begin,end)
5384  *         within the returned array relating to the current field part.
5385  *  \return DataArrayInt * - the pointer to the field values array.
5386  *  \throw If the number of underlying meshes is not equal to 1.
5387  *  \throw If no field values are available.
5388  *  \sa getUndergroundDataArray()
5389  */
5390 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5391 {
5392   if(_field_per_mesh.size()!=1)
5393     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5394   if(_field_per_mesh[0]==0)
5395     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5396   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5397   return getUndergroundDataArrayTemplate();
5398 }
5399
5400 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5401 {
5402   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5403   ret->deepCpyLeavesFrom(*this);
5404   return ret.retn();
5405 }
5406
5407 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5408 {
5409   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5410   if((const DataArrayInt *)_arr)
5411     ret->_arr=_arr->deepCopy();
5412   return ret.retn();
5413 }
5414
5415 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5416 {
5417 }
5418
5419 //= MEDFileAnyTypeField1TS
5420
5421 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5422 {
5423   med_field_type typcha;
5424   //
5425   std::vector<std::string> infos;
5426   std::string dtunit,fieldName;
5427   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5428   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5429   switch(typcha)
5430   {
5431     case MED_FLOAT64:
5432       {
5433         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5434         break;
5435       }
5436     case MED_INT32:
5437       {
5438         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5439         break;
5440       }
5441     default:
5442       {
5443         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] !";
5444         throw INTERP_KERNEL::Exception(oss.str());
5445       }
5446   }
5447   ret->setDtUnit(dtunit.c_str());
5448   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5449   //
5450   med_int numdt,numit;
5451   med_float dt;
5452   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5453   ret->setTime(numdt,numit,dt);
5454   ret->_csit=1;
5455   if(loadAll)
5456     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5457   else
5458     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5459   return ret.retn();
5460 }
5461
5462 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5463 try:MEDFileFieldGlobsReal(fid)
5464 {
5465   _content=BuildContentFrom(fid,loadAll,ms);
5466   loadGlobals(fid);
5467 }
5468 catch(INTERP_KERNEL::Exception& e)
5469 {
5470     throw e;
5471 }
5472
5473 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5474 {
5475   med_field_type typcha;
5476   std::vector<std::string> infos;
5477   std::string dtunit;
5478   int iii=-1;
5479   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5480   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5481   switch(typcha)
5482   {
5483     case MED_FLOAT64:
5484       {
5485         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5486         break;
5487       }
5488     case MED_INT32:
5489       {
5490         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5491         break;
5492       }
5493     default:
5494       {
5495         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] !";
5496         throw INTERP_KERNEL::Exception(oss.str());
5497       }
5498   }
5499   ret->setDtUnit(dtunit.c_str());
5500   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5501   //
5502   if(nbSteps<1)
5503     {
5504       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5505       throw INTERP_KERNEL::Exception(oss.str());
5506     }
5507   //
5508   med_int numdt,numit;
5509   med_float dt;
5510   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5511   ret->setTime(numdt,numit,dt);
5512   ret->_csit=1;
5513   if(loadAll)
5514     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5515   else
5516     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5517   return ret.retn();
5518 }
5519
5520 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5521 try:MEDFileFieldGlobsReal(fid)
5522 {
5523   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5524   loadGlobals(fid);
5525 }
5526 catch(INTERP_KERNEL::Exception& e)
5527 {
5528     throw e;
5529 }
5530
5531 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5532 {
5533   if(!c)
5534     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5535   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5536     {
5537       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5538       ret->_content=c; c->incrRef();
5539       return ret.retn();
5540     }
5541   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5542     {
5543       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5544       ret->_content=c; c->incrRef();
5545       return ret.retn();
5546     }
5547   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5548 }
5549
5550 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5551 {
5552   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5553   ret->setFileName(FileNameFromFID(fid));
5554   return ret;
5555 }
5556
5557 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5558 {
5559   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5560   return New(fid,loadAll);
5561 }
5562
5563 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5564 {
5565   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5566   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5567   ret->loadGlobals(fid);
5568   return ret.retn();
5569 }
5570
5571 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5572 {
5573   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5574   return New(fid,fieldName,loadAll);
5575 }
5576
5577 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5578 {
5579   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5580   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5581   ret->loadGlobals(fid);
5582   return ret.retn();
5583 }
5584
5585 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5586 {
5587   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5588   return New(fid,fieldName,iteration,order,loadAll);
5589 }
5590
5591 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5592 {
5593   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5594   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5595   ret->loadGlobals(fid);
5596   return ret.retn();
5597 }
5598
5599 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5600 {
5601   med_field_type typcha;
5602   std::vector<std::string> infos;
5603   std::string dtunit;
5604   int iii(-1);
5605   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5606   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5607   switch(typcha)
5608   {
5609     case MED_FLOAT64:
5610       {
5611         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5612         break;
5613       }
5614     case MED_INT32:
5615       {
5616         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5617         break;
5618       }
5619     default:
5620       {
5621         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] !";
5622         throw INTERP_KERNEL::Exception(oss.str());
5623       }
5624   }
5625   ret->setDtUnit(dtunit.c_str());
5626   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5627   //
5628   bool found=false;
5629   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5630   for(int i=0;i<nbOfStep2 && !found;i++)
5631     {
5632       med_int numdt,numit;
5633       med_float dt;
5634       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5635       if(numdt==iteration && numit==order)
5636         {
5637           found=true;
5638           ret->_csit=i+1;
5639         }
5640       else
5641         dtits[i]=std::pair<int,int>(numdt,numit);
5642     }
5643   if(!found)
5644     {
5645       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5646       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5647         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5648       throw INTERP_KERNEL::Exception(oss.str());
5649     }
5650   if(loadAll)
5651     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5652   else
5653     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5654   return ret.retn();
5655 }
5656
5657 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5658 try:MEDFileFieldGlobsReal(fid)
5659 {
5660   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5661   loadGlobals(fid);
5662 }
5663 catch(INTERP_KERNEL::Exception& e)
5664 {
5665     throw e;
5666 }
5667
5668 /*!
5669  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5670  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5671  *
5672  * \warning this is a shallow copy constructor
5673  */
5674 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5675 {
5676   if(!shallowCopyOfContent)
5677     {
5678       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5679       otherPtr->incrRef();
5680       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5681     }
5682   else
5683     {
5684       _content=other.shallowCpy();
5685     }
5686 }
5687
5688 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)
5689 {
5690   if(checkFieldId)
5691     {
5692       int nbFields=MEDnField(fid);
5693       if(fieldIdCFormat>=nbFields)
5694         {
5695           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5696           throw INTERP_KERNEL::Exception(oss.str());
5697         }
5698     }
5699   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5700   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5701   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5702   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5703   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5704   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5705   med_bool localMesh;
5706   int nbOfStep;
5707   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5708   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5709   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5710   infos.clear(); infos.resize(ncomp);
5711   for(int j=0;j<ncomp;j++)
5712     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5713   return nbOfStep;
5714 }
5715
5716 /*!
5717  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5718  * 
5719  * \param [out]
5720  * \return in case of success the number of time steps available for the field with name \a fieldName.
5721  */
5722 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5723 {
5724   int nbFields=MEDnField(fid);
5725   bool found=false;
5726   std::vector<std::string> fns(nbFields);
5727   int nbOfStep2(-1);
5728   for(int i=0;i<nbFields && !found;i++)
5729     {
5730       std::string tmp;
5731       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5732       fns[i]=tmp;
5733       found=(tmp==fieldName);
5734       if(found)
5735         posCFormat=i;
5736     }
5737   if(!found)
5738     {
5739       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5740       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5741         oss << "\"" << *it << "\" ";
5742       throw INTERP_KERNEL::Exception(oss.str());
5743     }
5744   return nbOfStep2;
5745 }
5746
5747 /*!
5748  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5749  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5750  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5751  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5752  * to keep a valid instance.
5753  * 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.
5754  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5755  * 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.
5756  *
5757  * \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.
5758  * \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.
5759  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5760  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5761  * \param [in] newLocName is the new localization name.
5762  * \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.
5763  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5764  */
5765 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5766 {
5767   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5768   std::string oldPflName=disc->getProfile();
5769   std::vector<std::string> vv=getPflsReallyUsedMulti();
5770   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5771   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5772     {
5773       disc->setProfile(newPflName);
5774       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5775       pfl->setName(newPflName);
5776     }
5777   else
5778     {
5779       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5780       throw INTERP_KERNEL::Exception(oss.str());
5781     }
5782 }
5783
5784 /*!
5785  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5786  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5787  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5788  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5789  * to keep a valid instance.
5790  * 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.
5791  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5792  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5793  * 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.
5794  *
5795  * \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.
5796  * \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.
5797  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5798  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5799  * \param [in] newLocName is the new localization name.
5800  * \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.
5801  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5802  */
5803 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5804 {
5805   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5806   std::string oldLocName=disc->getLocalization();
5807   std::vector<std::string> vv=getLocsReallyUsedMulti();
5808   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5809   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5810     {
5811       disc->setLocalization(newLocName);
5812       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5813       loc.setName(newLocName);
5814     }
5815   else
5816     {
5817       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5818       throw INTERP_KERNEL::Exception(oss.str());
5819     }
5820 }
5821
5822 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5823 {
5824   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5825   if(!ret)
5826     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5827   return ret;
5828 }
5829
5830 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5831 {
5832   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5833   if(!ret)
5834     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5835   return ret;
5836 }
5837
5838 /*!
5839  * This method alloc the arrays and load potentially huge arrays contained in this field.
5840  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5841  * This method can be also called to refresh or reinit values from a file.
5842  * 
5843  * \throw If the fileName is not set or points to a non readable MED file.
5844  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5845  */
5846 void MEDFileAnyTypeField1TS::loadArrays()
5847 {
5848   if(getFileName().empty())
5849     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5850   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5851   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5852 }
5853
5854 /*!
5855  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5856  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5857  * this method does not throw if \a this does not come from file read.
5858  * 
5859  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5860  */
5861 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5862 {
5863   if(!getFileName().empty())
5864     {
5865       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5866       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5867     }
5868 }
5869
5870 /*!
5871  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5872  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5873  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5874  * 
5875  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5876  */
5877 void MEDFileAnyTypeField1TS::unloadArrays()
5878 {
5879   contentNotNullBase()->unloadArrays();
5880 }
5881
5882 /*!
5883  * 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.
5884  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5885  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5886  * 
5887  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5888  */
5889 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5890 {
5891   if(!getFileName().empty())
5892     contentNotNullBase()->unloadArrays();
5893 }
5894
5895 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5896 {
5897   int nbComp(getNumberOfComponents());
5898   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5899   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5900   for(int i=0;i<nbComp;i++)
5901     {
5902       std::string info=getInfo()[i];
5903       std::string c,u;
5904       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5905       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5906       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5907     }
5908   if(getName().empty())
5909     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5910   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5911   writeGlobals(fid,*this);
5912   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5913 }
5914
5915 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5916 {
5917   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5918 }
5919
5920 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5921 {
5922   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5923   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5924   return ret;
5925 }
5926
5927 /*!
5928  * Returns a string describing \a this field. This string is outputted 
5929  * by \c print Python command.
5930  */
5931 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5932 {
5933   std::ostringstream oss;
5934   contentNotNullBase()->simpleRepr(0,oss,-1);
5935   simpleReprGlobs(oss);
5936   return oss.str();
5937 }
5938
5939 /*!
5940  * This method returns all profiles whose name is non empty used.
5941  * \b WARNING If profile is used several times it will be reported \b only \b once.
5942  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5943  */
5944 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5945 {
5946   return contentNotNullBase()->getPflsReallyUsed2();
5947 }
5948
5949 /*!
5950  * This method returns all localizations whose name is non empty used.
5951  * \b WARNING If localization is used several times it will be reported \b only \b once.
5952  */
5953 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5954 {
5955   return contentNotNullBase()->getLocsReallyUsed2();
5956 }
5957
5958 /*!
5959  * This method returns all profiles whose name is non empty used.
5960  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5961  */
5962 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5963 {
5964   return contentNotNullBase()->getPflsReallyUsedMulti2();
5965 }
5966
5967 /*!
5968  * This method returns all localizations whose name is non empty used.
5969  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5970  */
5971 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5972 {
5973   return contentNotNullBase()->getLocsReallyUsedMulti2();
5974 }
5975
5976 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5977 {
5978   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5979 }
5980
5981 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5982 {
5983   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5984 }
5985
5986 int MEDFileAnyTypeField1TS::getDimension() const
5987 {
5988   return contentNotNullBase()->getDimension();
5989 }
5990
5991 int MEDFileAnyTypeField1TS::getIteration() const
5992 {
5993   return contentNotNullBase()->getIteration();
5994 }
5995
5996 int MEDFileAnyTypeField1TS::getOrder() const
5997 {
5998   return contentNotNullBase()->getOrder();
5999 }
6000
6001 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6002 {
6003   return contentNotNullBase()->getTime(iteration,order);
6004 }
6005
6006 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6007 {
6008   contentNotNullBase()->setTime(iteration,order,val);
6009 }
6010
6011 std::string MEDFileAnyTypeField1TS::getName() const
6012 {
6013   return contentNotNullBase()->getName();
6014 }
6015
6016 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6017 {
6018   contentNotNullBase()->setName(name);
6019 }
6020
6021 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6022 {
6023   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6024 }
6025
6026 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6027 {
6028   return contentNotNullBase()->getDtUnit();
6029 }
6030
6031 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6032 {
6033   contentNotNullBase()->setDtUnit(dtUnit);
6034 }
6035
6036 std::string MEDFileAnyTypeField1TS::getMeshName() const
6037 {
6038   return contentNotNullBase()->getMeshName();
6039 }
6040
6041 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6042 {
6043   contentNotNullBase()->setMeshName(newMeshName);
6044 }
6045
6046 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6047 {
6048   return contentNotNullBase()->changeMeshNames(modifTab);
6049 }
6050
6051 int MEDFileAnyTypeField1TS::getMeshIteration() const
6052 {
6053   return contentNotNullBase()->getMeshIteration();
6054 }
6055
6056 int MEDFileAnyTypeField1TS::getMeshOrder() const
6057 {
6058   return contentNotNullBase()->getMeshOrder();
6059 }
6060
6061 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6062 {
6063   return contentNotNullBase()->getNumberOfComponents();
6064 }
6065
6066 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6067 {
6068   return contentNotNullBase()->isDealingTS(iteration,order);
6069 }
6070
6071 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6072 {
6073   return contentNotNullBase()->getDtIt();
6074 }
6075
6076 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6077 {
6078   contentNotNullBase()->fillIteration(p);
6079 }
6080
6081 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6082 {
6083   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6084 }
6085
6086 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6087 {
6088   contentNotNullBase()->setInfo(infos);
6089 }
6090
6091 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6092 {
6093   return contentNotNullBase()->getInfo();
6094 }
6095 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6096 {
6097   return contentNotNullBase()->getInfo();
6098 }
6099
6100 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6101 {
6102   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6103 }
6104
6105 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6106 {
6107   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6108 }
6109
6110 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6111 {
6112   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6113 }
6114
6115 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6116 {
6117   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6118 }
6119
6120 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6121 {
6122   return contentNotNullBase()->getTypesOfFieldAvailable();
6123 }
6124
6125 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,
6126                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6127 {
6128   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6129 }
6130
6131 /*!
6132  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6133  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6134  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6135  */
6136 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6137 {
6138   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6139   if(!content)
6140     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6141   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6142   std::size_t sz(contentsSplit.size());
6143   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6144   for(std::size_t i=0;i<sz;i++)
6145     {
6146       ret[i]=shallowCpy();
6147       ret[i]->_content=contentsSplit[i];
6148     }
6149   return ret;
6150 }
6151
6152 /*!
6153  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6154  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6155  */
6156 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6157 {
6158   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6159   if(!content)
6160     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6161   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6162   std::size_t sz(contentsSplit.size());
6163   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6164   for(std::size_t i=0;i<sz;i++)
6165     {
6166       ret[i]=shallowCpy();
6167       ret[i]->_content=contentsSplit[i];
6168     }
6169   return ret;
6170 }
6171
6172 /*!
6173  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6174  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6175  */
6176 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6177 {
6178   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6179   if(!content)
6180     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6181   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6182   std::size_t sz(contentsSplit.size());
6183   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6184   for(std::size_t i=0;i<sz;i++)
6185     {
6186       ret[i]=shallowCpy();
6187       ret[i]->_content=contentsSplit[i];
6188     }
6189   return ret;
6190 }
6191
6192 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6193 {
6194   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6195   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6196     ret->_content=_content->deepCopy();
6197   ret->deepCpyGlobs(*this);
6198   return ret.retn();
6199 }
6200
6201 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6202 {
6203   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6204 }
6205
6206 //= MEDFileField1TS
6207
6208 /*!
6209  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6210  * the first field that has been read from a specified MED file.
6211  *  \param [in] fileName - the name of the MED file to read.
6212  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6213  *          is to delete this field using decrRef() as it is no more needed.
6214  *  \throw If reading the file fails.
6215  */
6216 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6217 {
6218   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6219   return New(fid,loadAll);
6220 }
6221
6222 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6223 {
6224   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6225   ret->contentNotNull();
6226   return ret.retn();
6227 }
6228
6229 /*!
6230  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6231  * a given field that has been read from a specified MED file.
6232  *  \param [in] fileName - the name of the MED file to read.
6233  *  \param [in] fieldName - the name of the field to read.
6234  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6235  *          is to delete this field using decrRef() as it is no more needed.
6236  *  \throw If reading the file fails.
6237  *  \throw If there is no field named \a fieldName in the file.
6238  */
6239 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6240 {
6241   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6242   return New(fid,fieldName,loadAll);
6243 }
6244
6245 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6246 {
6247   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6248   ret->contentNotNull();
6249   return ret.retn();
6250 }
6251
6252 /*!
6253  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6254  * a given field that has been read from a specified MED file.
6255  *  \param [in] fileName - the name of the MED file to read.
6256  *  \param [in] fieldName - the name of the field to read.
6257  *  \param [in] iteration - the iteration number of a required time step.
6258  *  \param [in] order - the iteration order number of required time step.
6259  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6260  *          is to delete this field using decrRef() as it is no more needed.
6261  *  \throw If reading the file fails.
6262  *  \throw If there is no field named \a fieldName in the file.
6263  *  \throw If the required time step is missing from the file.
6264  */
6265 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6266 {
6267   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6268   return New(fid,fieldName,iteration,order,loadAll);
6269 }
6270
6271 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6272 {
6273   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6274   ret->contentNotNull();
6275   return ret.retn();
6276 }
6277
6278 /*!
6279  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6280  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6281  *
6282  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6283  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6284  * \warning this is a shallow copy constructor
6285  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6286  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6287  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6288  *          is to delete this field using decrRef() as it is no more needed.
6289  */
6290 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6291 {
6292   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6293   ret->contentNotNull();
6294   return ret.retn();
6295 }
6296
6297 /*!
6298  * Returns a new empty instance of MEDFileField1TS.
6299  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6300  *          is to delete this field using decrRef() as it is no more needed.
6301  */
6302 MEDFileField1TS *MEDFileField1TS::New()
6303 {
6304   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6305   ret->contentNotNull();
6306   return ret.retn();
6307 }
6308
6309 /*!
6310  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6311  * following the given input policy.
6312  *
6313  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6314  *                            By default (true) the globals are deeply copied.
6315  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6316  */
6317 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6318 {
6319   MCAuto<MEDFileIntField1TS> ret;
6320   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6321   if(content)
6322     {
6323       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6324       if(!contc)
6325         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6326       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6327       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6328     }
6329   else
6330     ret=MEDFileIntField1TS::New();
6331   if(isDeepCpyGlobs)
6332     ret->deepCpyGlobs(*this);
6333   else
6334     ret->shallowCpyGlobs(*this);
6335   return ret.retn();
6336 }
6337
6338 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6339 {
6340   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6341   if(!pt)
6342     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6343   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6344   if(!ret)
6345     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 !");
6346   return ret;
6347 }
6348
6349 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6350 {
6351   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6352   if(!pt)
6353     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6354   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6355   if(!ret)
6356     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 !");
6357   return ret;
6358 }
6359
6360 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6361 {
6362   if(!f)
6363     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6364   if(arr.isNull())
6365     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6366   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6367   if(!arrOutC)
6368     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6369   f->setArray(arrOutC);
6370 }
6371
6372 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6373 {
6374   if(arr.isNull())
6375     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6376   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6377   if(!arrOutC)
6378     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6379   arrOutC->incrRef();
6380   return arrOutC;
6381 }
6382
6383 /*!
6384  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6385  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6386  *
6387  * \return A new object that the caller is responsible to deallocate.
6388  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6389  */
6390 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6391 {
6392   if(!mm)
6393     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6394   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6395   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6396   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6397     {
6398       if((*it0)!=ON_NODES)
6399         {
6400           std::vector<int> levs;
6401           getNonEmptyLevels(mm->getName(),levs);
6402           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6403             {
6404               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6405               if(it2!=extractDef.end())
6406                 {
6407                   MCAuto<DataArrayInt> t((*it2).second);
6408                   if(t.isNull())
6409                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6410                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6411                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6412                   ret->setFieldNoProfileSBT(fOut);
6413                 }
6414             }
6415         }
6416       else
6417         {
6418           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6419           if(it2==extractDef.end())
6420             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6421           MCAuto<DataArrayInt> t((*it2).second);
6422           if(t.isNull())
6423             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6424           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6425           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6426           DataArrayDouble *arr(f->getArray());
6427           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6428           fOut->setArray(newArr);
6429           ret->setFieldNoProfileSBT(fOut);
6430         }
6431     }
6432   return ret.retn();
6433 }
6434
6435 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6436 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6437 {
6438 }
6439 catch(INTERP_KERNEL::Exception& e)
6440 { throw e; }
6441
6442 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6443 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6444 {
6445 }
6446 catch(INTERP_KERNEL::Exception& e)
6447 { throw e; }
6448
6449 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6450 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6451 {
6452 }
6453 catch(INTERP_KERNEL::Exception& e)
6454 { throw e; }
6455
6456 /*!
6457  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6458  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6459  *
6460  * \warning this is a shallow copy constructor
6461  */
6462 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6463 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6464 {
6465 }
6466 catch(INTERP_KERNEL::Exception& e)
6467 { throw e; }
6468
6469 MEDFileField1TS::MEDFileField1TS()
6470 {
6471   _content=new MEDFileField1TSWithoutSDA;
6472 }
6473
6474 /*!
6475  * 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
6476  * method should be called (getFieldOnMeshAtLevel for example).
6477  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6478  *
6479  * \param [in] mesh - the mesh the field is lying on
6480  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6481  *          caller is to delete this field using decrRef() as it is no more needed. 
6482  */
6483 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6484 {
6485   MCAuto<DataArray> arrOut;
6486   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6487   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6488   return ret.retn();
6489 }
6490
6491 /*!
6492  * Returns a new MEDCouplingFieldDouble of a given type lying on
6493  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6494  * has not been constructed via file reading, an exception is thrown.
6495  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6496  *  \param [in] type - a spatial discretization of interest.
6497  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6498  *  \param [in] renumPol - specifies how to permute values of the result field according to
6499  *          the optional numbers of cells and nodes, if any. The valid values are
6500  *          - 0 - do not permute.
6501  *          - 1 - permute cells.
6502  *          - 2 - permute nodes.
6503  *          - 3 - permute cells and nodes.
6504  *
6505  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6506  *          caller is to delete this field using decrRef() as it is no more needed. 
6507  *  \throw If \a this field has not been constructed via file reading.
6508  *  \throw If the MED file is not readable.
6509  *  \throw If there is no mesh in the MED file.
6510  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6511  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6512  *  \sa getFieldOnMeshAtLevel()
6513  */
6514 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6515 {
6516   if(getFileName().empty())
6517     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6518   MCAuto<DataArray> arrOut;
6519   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6520   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6521   return ret.retn();
6522 }
6523
6524 /*!
6525  * Returns a new MEDCouplingFieldDouble of a given type lying on
6526  * the top level cells of the first mesh in MED file. If \a this field 
6527  * has not been constructed via file reading, an exception is thrown.
6528  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6529  *  \param [in] type - a spatial discretization of interest.
6530  *  \param [in] renumPol - specifies how to permute values of the result field according to
6531  *          the optional numbers of cells and nodes, if any. The valid values are
6532  *          - 0 - do not permute.
6533  *          - 1 - permute cells.
6534  *          - 2 - permute nodes.
6535  *          - 3 - permute cells and nodes.
6536  *
6537  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6538  *          caller is to delete this field using decrRef() as it is no more needed. 
6539  *  \throw If \a this field has not been constructed via file reading.
6540  *  \throw If the MED file is not readable.
6541  *  \throw If there is no mesh in the MED file.
6542  *  \throw If no field values of the given \a type.
6543  *  \throw If no field values lying on the top level support.
6544  *  \sa getFieldAtLevel()
6545  */
6546 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6547 {
6548   if(getFileName().empty())
6549     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6550   MCAuto<DataArray> arrOut;
6551   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6552   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6553   return ret.retn();
6554 }
6555
6556 /*!
6557  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6558  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6559  *  \param [in] type - a spatial discretization of the new field.
6560  *  \param [in] mesh - the supporting mesh.
6561  *  \param [in] renumPol - specifies how to permute values of the result field according to
6562  *          the optional numbers of cells and nodes, if any. The valid values are
6563  *          - 0 - do not permute.
6564  *          - 1 - permute cells.
6565  *          - 2 - permute nodes.
6566  *          - 3 - permute cells and nodes.
6567  *
6568  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6569  *          caller is to delete this field using decrRef() as it is no more needed. 
6570  *  \throw If no field of \a this is lying on \a mesh.
6571  *  \throw If the mesh is empty.
6572  *  \throw If no field values of the given \a type are available.
6573  *  \sa getFieldAtLevel()
6574  *  \sa getFieldOnMeshAtLevel() 
6575  */
6576 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6577 {
6578   MCAuto<DataArray> arrOut;
6579   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6580   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6581   return ret.retn();
6582 }
6583
6584 /*!
6585  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6586  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6587  *  \param [in] type - a spatial discretization of interest.
6588  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6589  *  \param [in] mesh - the supporting mesh.
6590  *  \param [in] renumPol - specifies how to permute values of the result field according to
6591  *          the optional numbers of cells and nodes, if any. The valid values are
6592  *          - 0 - do not permute.
6593  *          - 1 - permute cells.
6594  *          - 2 - permute nodes.
6595  *          - 3 - permute cells and nodes.
6596  *
6597  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6598  *          caller is to delete this field using decrRef() as it is no more needed. 
6599  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6600  *  \throw If no field of \a this is lying on \a mesh.
6601  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6602  *  \sa getFieldAtLevel()
6603  *  \sa getFieldOnMeshAtLevel() 
6604  */
6605 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6606 {
6607   MCAuto<DataArray> arrOut;
6608   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6609   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6610   return ret.retn();
6611 }
6612
6613 /*!
6614  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6615  * This method is called "Old" because in MED3 norm a field has only one meshName
6616  * attached, so this method is for readers of MED2 files. If \a this field 
6617  * has not been constructed via file reading, an exception is thrown.
6618  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6619  *  \param [in] type - a spatial discretization of interest.
6620  *  \param [in] mName - a name of the supporting mesh.
6621  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6622  *  \param [in] renumPol - specifies how to permute values of the result field according to
6623  *          the optional numbers of cells and nodes, if any. The valid values are
6624  *          - 0 - do not permute.
6625  *          - 1 - permute cells.
6626  *          - 2 - permute nodes.
6627  *          - 3 - permute cells and nodes.
6628  *
6629  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6630  *          caller is to delete this field using decrRef() as it is no more needed. 
6631  *  \throw If the MED file is not readable.
6632  *  \throw If there is no mesh named \a mName in the MED file.
6633  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6634  *  \throw If \a this field has not been constructed via file reading.
6635  *  \throw If no field of \a this is lying on the mesh named \a mName.
6636  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6637  *  \sa getFieldAtLevel()
6638  */
6639 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6640 {
6641   if(getFileName().empty())
6642     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6643   MCAuto<DataArray> arrOut;
6644   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6645   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6646   return ret.retn();
6647 }
6648
6649 /*!
6650  * Returns values and a profile of the field of a given type lying on a given support.
6651  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6652  *  \param [in] type - a spatial discretization of the field.
6653  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6654  *  \param [in] mesh - the supporting mesh.
6655  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6656  *          field of interest lies on. If the field lies on all entities of the given
6657  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6658  *          using decrRef() as it is no more needed.  
6659  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6660  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6661  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6662  *  \throw If no field of \a this is lying on \a mesh.
6663  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6664  */
6665 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6666 {
6667   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6668   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6669 }
6670
6671 /*!
6672  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6673  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6674  * "Sort By Type"), if not, an exception is thrown. 
6675  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6676  *  \param [in] field - the field to add to \a this.
6677  *  \throw If the name of \a field is empty.
6678  *  \throw If the data array of \a field is not set.
6679  *  \throw If the data array is already allocated but has different number of components
6680  *         than \a field.
6681  *  \throw If the underlying mesh of \a field has no name.
6682  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6683  */
6684 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6685 {
6686   setFileName("");
6687   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6688 }
6689
6690 /*!
6691  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6692  * can be an aggregation of several MEDCouplingFieldDouble instances.
6693  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6694  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6695  * and \a profile.
6696  *
6697  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6698  * A new profile is added only if no equal profile is missing.
6699  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6700  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6701  *  \param [in] mesh - the supporting mesh of \a field.
6702  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6703  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6704  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6705  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6706  *  \throw If the data array of \a field is not set.
6707  *  \throw If the data array of \a this is already allocated but has different number of
6708  *         components than \a field.
6709  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6710  *  \sa setFieldNoProfileSBT()
6711  */
6712 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6713 {
6714   setFileName("");
6715   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6716 }
6717
6718 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6719 {
6720   return new MEDFileField1TS(*this);
6721 }
6722
6723 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6724 {
6725   return contentNotNull()->getUndergroundDataArrayTemplate();
6726 }
6727
6728 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6729 {
6730   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6731 }
6732
6733 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6734                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6735 {
6736   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6737 }
6738
6739 //= MEDFileIntField1TS
6740
6741 MEDFileIntField1TS *MEDFileIntField1TS::New()
6742 {
6743   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6744   ret->contentNotNull();
6745   return ret.retn();
6746 }
6747
6748 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6749 {
6750   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6751   return MEDFileIntField1TS::New(fid,loadAll);
6752 }
6753
6754 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6755 {
6756   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6757   ret->contentNotNull();
6758   return ret.retn();
6759 }
6760
6761 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6762 {
6763   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6764   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6765 }
6766
6767 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6768 {
6769   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6770   ret->contentNotNull();
6771   return ret.retn();
6772 }
6773
6774 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6775 {
6776   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6777   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6778 }
6779
6780 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6781 {
6782   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6783   ret->contentNotNull();
6784   return ret.retn();
6785 }
6786
6787 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6788 {
6789   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6790   ret->contentNotNull();
6791   return ret.retn();
6792 }
6793
6794 MEDFileIntField1TS::MEDFileIntField1TS()
6795 {
6796   _content=new MEDFileIntField1TSWithoutSDA;
6797 }
6798
6799 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6800 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6801 {
6802 }
6803 catch(INTERP_KERNEL::Exception& e)
6804 { throw e; }
6805
6806 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6807 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6808 {
6809 }
6810 catch(INTERP_KERNEL::Exception& e)
6811 { throw e; }
6812
6813 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6814 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6815 {
6816 }
6817 catch(INTERP_KERNEL::Exception& e)
6818 { throw e; }
6819
6820 /*!
6821  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6822  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6823  *
6824  * \warning this is a shallow copy constructor
6825  */
6826 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6827 {
6828 }
6829
6830 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6831 {
6832   return new MEDFileIntField1TS(*this);
6833 }
6834
6835 /*!
6836  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6837  * following the given input policy.
6838  *
6839  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6840  *                            By default (true) the globals are deeply copied.
6841  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6842  */
6843 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6844 {
6845   MCAuto<MEDFileField1TS> ret;
6846   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6847   if(content)
6848     {
6849       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6850       if(!contc)
6851         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6852       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6853       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6854     }
6855   else
6856     ret=MEDFileField1TS::New();
6857   if(isDeepCpyGlobs)
6858     ret->deepCpyGlobs(*this);
6859   else
6860     ret->shallowCpyGlobs(*this);
6861   return ret.retn();
6862 }
6863
6864 /*!
6865  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6866  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6867  * "Sort By Type"), if not, an exception is thrown. 
6868  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6869  *  \param [in] field - the field to add to \a this.
6870  *  \throw If the name of \a field is empty.
6871  *  \throw If the data array of \a field is not set.
6872  *  \throw If the data array is already allocated but has different number of components
6873  *         than \a field.
6874  *  \throw If the underlying mesh of \a field has no name.
6875  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6876  */
6877 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6878 {
6879   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6880   setFileName("");
6881   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6882 }
6883
6884 /*!
6885  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6886  * can be an aggregation of several MEDCouplingFieldDouble instances.
6887  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6888  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6889  * and \a profile.
6890  *
6891  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6892  * A new profile is added only if no equal profile is missing.
6893  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6894  *  \param [in] field - the field to add to \a this.
6895  *  \param [in] mesh - the supporting mesh of \a field.
6896  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6897  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6898  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6899  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6900  *  \throw If the data array of \a field is not set.
6901  *  \throw If the data array of \a this is already allocated but has different number of
6902  *         components than \a field.
6903  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6904  *  \sa setFieldNoProfileSBT()
6905  */
6906 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6907 {
6908   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6909   setFileName("");
6910   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6911 }
6912
6913 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6914 {
6915   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6916   if(!pt)
6917     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6918   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6919   if(!ret)
6920     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 !");
6921   return ret;
6922 }
6923
6924 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6925 {
6926   if(getFileName().empty())
6927     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6928   MCAuto<DataArray> arrOut;
6929   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6930   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6931   return ret2.retn();
6932 }
6933
6934 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6935 {
6936   if(arr.isNull())
6937     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6938   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6939   if(!arrC)
6940     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6941   arrC->incrRef();
6942   return arrC;
6943 }
6944
6945 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6946 {
6947   int t1,t2;
6948   double t0(f->getTime(t1,t2));
6949   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6950   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6951   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6952   ret->setTime(t0,t1,t2); ret->setArray(arr2);
6953   return ret.retn();
6954 }
6955
6956 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6957 {
6958   if(!f)
6959     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6960   int t1,t2;
6961   double t0(f->getTime(t1,t2));
6962   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6963   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6964   ret->setTime(t0,t1,t2);
6965   return ret;
6966 }
6967
6968 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6969 {
6970   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6971 }
6972
6973 /*!
6974  * 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
6975  * method should be called (getFieldOnMeshAtLevel for example).
6976  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6977  *
6978  * \param [in] mesh - the mesh the field is lying on
6979  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6980  *          caller is to delete this field using decrRef() as it is no more needed. 
6981  */
6982 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6983 {
6984   MCAuto<DataArray> arrOut;
6985   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6986   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6987   return ret2.retn();
6988 }
6989
6990 /*!
6991  * Returns a new MEDCouplingFieldInt of a given type lying on
6992  * the top level cells of the first mesh in MED file. If \a this field 
6993  * has not been constructed via file reading, an exception is thrown.
6994  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6995  *  \param [in] type - a spatial discretization of interest.
6996  *  \param [in] renumPol - specifies how to permute values of the result field according to
6997  *          the optional numbers of cells and nodes, if any. The valid values are
6998  *          - 0 - do not permute.
6999  *          - 1 - permute cells.
7000  *          - 2 - permute nodes.
7001  *          - 3 - permute cells and nodes.
7002  *
7003  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7004  *          caller is to delete this field using decrRef() as it is no more needed. 
7005  *  \throw If \a this field has not been constructed via file reading.
7006  *  \throw If the MED file is not readable.
7007  *  \throw If there is no mesh in the MED file.
7008  *  \throw If no field values of the given \a type.
7009  *  \throw If no field values lying on the top level support.
7010  *  \sa getFieldAtLevel()
7011  */
7012 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7013 {
7014   if(getFileName().empty())
7015     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7016   MCAuto<DataArray> arrOut;
7017   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7018   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7019   return ret2.retn();
7020 }
7021
7022 /*!
7023  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7024  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7025  *  \param [in] type - a spatial discretization of the new field.
7026  *  \param [in] mesh - the supporting mesh.
7027  *  \param [in] renumPol - specifies how to permute values of the result field according to
7028  *          the optional numbers of cells and nodes, if any. The valid values are
7029  *          - 0 - do not permute.
7030  *          - 1 - permute cells.
7031  *          - 2 - permute nodes.
7032  *          - 3 - permute cells and nodes.
7033  *
7034  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7035  *          caller is to delete this field using decrRef() as it is no more needed. 
7036  *  \throw If no field of \a this is lying on \a mesh.
7037  *  \throw If the mesh is empty.
7038  *  \throw If no field values of the given \a type are available.
7039  *  \sa getFieldAtLevel()
7040  *  \sa getFieldOnMeshAtLevel() 
7041  */
7042 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7043 {
7044   MCAuto<DataArray> arrOut;
7045   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7046   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7047   return ret2.retn();
7048 }
7049
7050 /*!
7051  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7052  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7053  *  \param [in] type - a spatial discretization of interest.
7054  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7055  *  \param [in] mesh - the supporting mesh.
7056  *  \param [in] renumPol - specifies how to permute values of the result field according to
7057  *          the optional numbers of cells and nodes, if any. The valid values are
7058  *          - 0 - do not permute.
7059  *          - 1 - permute cells.
7060  *          - 2 - permute nodes.
7061  *          - 3 - permute cells and nodes.
7062  *
7063  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7064  *          caller is to delete this field using decrRef() as it is no more needed. 
7065  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7066  *  \throw If no field of \a this is lying on \a mesh.
7067  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7068  *  \sa getFieldAtLevel()
7069  *  \sa getFieldOnMeshAtLevel() 
7070  */
7071 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7072 {
7073   MCAuto<DataArray> arrOut;
7074   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7075   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7076   return ret2.retn();
7077 }
7078
7079 /*!
7080  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7081  * This method is called "Old" because in MED3 norm a field has only one meshName
7082  * attached, so this method is for readers of MED2 files. If \a this field 
7083  * has not been constructed via file reading, an exception is thrown.
7084  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7085  *  \param [in] type - a spatial discretization of interest.
7086  *  \param [in] mName - a name of the supporting mesh.
7087  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7088  *  \param [in] renumPol - specifies how to permute values of the result field according to
7089  *          the optional numbers of cells and nodes, if any. The valid values are
7090  *          - 0 - do not permute.
7091  *          - 1 - permute cells.
7092  *          - 2 - permute nodes.
7093  *          - 3 - permute cells and nodes.
7094  *
7095  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7096  *          caller is to delete this field using decrRef() as it is no more needed. 
7097  *  \throw If the MED file is not readable.
7098  *  \throw If there is no mesh named \a mName in the MED file.
7099  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7100  *  \throw If \a this field has not been constructed via file reading.
7101  *  \throw If no field of \a this is lying on the mesh named \a mName.
7102  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7103  *  \sa getFieldAtLevel()
7104  */
7105 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7106 {
7107   if(getFileName().empty())
7108     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7109   MCAuto<DataArray> arrOut;
7110   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7111   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7112   return ret2.retn();
7113 }
7114
7115 /*!
7116  * Returns values and a profile of the field of a given type lying on a given support.
7117  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7118  *  \param [in] type - a spatial discretization of the field.
7119  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7120  *  \param [in] mesh - the supporting mesh.
7121  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7122  *          field of interest lies on. If the field lies on all entities of the given
7123  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7124  *          using decrRef() as it is no more needed.  
7125  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7126  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7127  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7128  *  \throw If no field of \a this is lying on \a mesh.
7129  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7130  */
7131 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7132 {
7133   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7134   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7135 }
7136
7137 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7138 {
7139   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7140   if(!pt)
7141     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7142   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7143   if(!ret)
7144     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 !");
7145   return ret;
7146 }
7147
7148 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7149 {
7150   return contentNotNull()->getUndergroundDataArrayTemplate();
7151 }
7152
7153 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7154
7155 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7156 {
7157 }
7158
7159 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7160 {
7161 }
7162
7163 /*!
7164  * \param [in] fieldId field id in C mode
7165  */
7166 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7167 {
7168   med_field_type typcha;
7169   std::string dtunitOut;
7170   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7171   setDtUnit(dtunitOut.c_str());
7172   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7173 }
7174
7175 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)
7176 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7177 {
7178   setDtUnit(dtunit.c_str());
7179   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7180 }
7181 catch(INTERP_KERNEL::Exception& e)
7182 {
7183     throw e;
7184 }
7185
7186 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7187 {
7188   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7189   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7190     ret+=(*it).capacity();
7191   return ret;
7192 }
7193
7194 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7195 {
7196   std::vector<const BigMemoryObject *> ret;
7197   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7198     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7199   return ret;
7200 }
7201
7202 /*!
7203  * 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
7204  * NULL.
7205  */
7206 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7207 {
7208   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7209   ret->setInfo(_infos);
7210   int sz=(int)_time_steps.size();
7211   for(const int *id=startIds;id!=endIds;id++)
7212     {
7213       if(*id>=0 && *id<sz)
7214         {
7215           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7216           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7217           if(tse)
7218             {
7219               tse->incrRef();
7220               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7221             }
7222           ret->pushBackTimeStep(tse2);
7223         }
7224       else
7225         {
7226           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7227           oss << " ! Should be in [0," << sz << ") !";
7228           throw INTERP_KERNEL::Exception(oss.str());
7229         }
7230     }
7231   if(ret->getNumberOfTS()>0)
7232     ret->synchronizeNameScope();
7233   ret->copyNameScope(*this);
7234   return ret.retn();
7235 }
7236
7237 /*!
7238  * 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
7239  * NULL.
7240  */
7241 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7242 {
7243   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7244   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7245   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7246   ret->setInfo(_infos);
7247   int sz=(int)_time_steps.size();
7248   int j=bg;
7249   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7250     {
7251       if(j>=0 && j<sz)
7252         {
7253           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7254           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7255           if(tse)
7256             {
7257               tse->incrRef();
7258               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7259             }
7260           ret->pushBackTimeStep(tse2);
7261         }
7262       else
7263         {
7264           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7265           oss << " ! Should be in [0," << sz << ") !";
7266           throw INTERP_KERNEL::Exception(oss.str());
7267         }
7268     }
7269   if(ret->getNumberOfTS()>0)
7270     ret->synchronizeNameScope();
7271   ret->copyNameScope(*this);
7272   return ret.retn();
7273 }
7274
7275 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7276 {
7277   int id=0;
7278   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7279   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7280     {
7281       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7282       if(!cur)
7283         continue;
7284       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7285       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7286         ids->pushBackSilent(id);
7287     }
7288   return buildFromTimeStepIds(ids->begin(),ids->end());
7289 }
7290
7291 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7292 {
7293   int id=0;
7294   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7295   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7296     {
7297       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7298       if(!cur)
7299         continue;
7300       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7301       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7302         ids->pushBackSilent(id);
7303     }
7304   return buildFromTimeStepIds(ids->begin(),ids->end());
7305 }
7306
7307 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7308 {
7309   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7310     {
7311       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7312       if(!cur)
7313         continue;
7314       if(cur->presenceOfMultiDiscPerGeoType())
7315         return true;
7316     }
7317   return false;
7318 }
7319
7320 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7321 {
7322   return _infos;
7323 }
7324
7325 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7326 {
7327   _infos=info;
7328 }
7329
7330 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7331 {
7332   int ret=0;
7333   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7334     {
7335       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7336       if(pt->isDealingTS(iteration,order))
7337         return ret;
7338     }
7339   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7340   std::vector< std::pair<int,int> > vp=getIterations();
7341   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7342     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7343   throw INTERP_KERNEL::Exception(oss.str());
7344 }
7345
7346 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7347 {
7348   return *_time_steps[getTimeStepPos(iteration,order)];
7349 }
7350
7351 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7352 {
7353   return *_time_steps[getTimeStepPos(iteration,order)];
7354 }
7355
7356 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7357 {
7358   if(_time_steps.empty())
7359     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7360   return _time_steps[0]->getMeshName();
7361 }
7362
7363 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7364 {
7365   std::string oldName(getMeshName());
7366   std::vector< std::pair<std::string,std::string> > v(1);
7367   v[0].first=oldName; v[0].second=newMeshName;
7368   changeMeshNames(v);
7369 }
7370
7371 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7372 {
7373   bool ret=false;
7374   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7375     {
7376       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7377       if(cur)
7378         ret=cur->changeMeshNames(modifTab) || ret;
7379     }
7380   return ret;
7381 }
7382
7383 /*!
7384  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7385  */
7386 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7387 {
7388   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7389 }
7390
7391 /*!
7392  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7393  */
7394 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7395 {
7396   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7397 }
7398
7399 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7400                                                                        MEDFileFieldGlobsReal& glob)
7401 {
7402   bool ret=false;
7403   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7404     {
7405       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7406       if(f1ts)
7407         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7408     }
7409   return ret;
7410 }
7411
7412 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7413 {
7414   std::string startLine(bkOffset,' ');
7415   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7416   if(fmtsId>=0)
7417     oss << " (" << fmtsId << ")";
7418   oss << " has the following name: \"" << _name << "\"." << std::endl;
7419   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7420   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7421     {
7422       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7423     }
7424   int i=0;
7425   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7426     {
7427       std::string chapter(17,'0'+i);
7428       oss << startLine << chapter << std::endl;
7429       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7430       if(cur)
7431         cur->simpleRepr(bkOffset+2,oss,i);
7432       else
7433         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7434       oss << startLine << chapter << std::endl;
7435     }
7436 }
7437
7438 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7439 {
7440   std::size_t sz=_time_steps.size();
7441   std::vector< std::pair<int,int> > ret(sz);
7442   ret1.resize(sz);
7443   for(std::size_t i=0;i<sz;i++)
7444     {
7445       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7446       if(f1ts)
7447         {
7448           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7449         }
7450       else
7451         {
7452           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7453           throw INTERP_KERNEL::Exception(oss.str());
7454         }
7455     }
7456   return ret;
7457 }
7458
7459 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7460 {
7461   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7462   if(!tse2)
7463     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7464   checkCoherencyOfType(tse2);
7465   if(_time_steps.empty())
7466     {
7467       setName(tse2->getName().c_str());
7468       setInfo(tse2->getInfo());
7469     }
7470   checkThatComponentsMatch(tse2->getInfo());
7471   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7472     setDtUnit(tse->getDtUnit());
7473   _time_steps.push_back(tse);
7474 }
7475
7476 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7477 {
7478   std::size_t nbOfCompo=_infos.size();
7479   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7480     {
7481       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7482       if(cur)
7483         {
7484           if((cur->getInfo()).size()!=nbOfCompo)
7485             {
7486               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7487               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7488               throw INTERP_KERNEL::Exception(oss.str());
7489             }
7490           cur->copyNameScope(*this);
7491         }
7492     }
7493 }
7494
7495 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7496 {
7497   _time_steps.resize(nbPdt);
7498   for(int i=0;i<nbPdt;i++)
7499     {
7500       std::vector< std::pair<int,int> > ts;
7501       med_int numdt=0,numo=0;
7502       med_float dt=0.0;
7503       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7504       switch(fieldTyp)
7505       {
7506         case MED_FLOAT64:
7507           {
7508             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7509             break;
7510           }
7511         case MED_INT32:
7512           {
7513             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7514             break;
7515           }
7516         default:
7517           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7518       }
7519       if(loadAll)
7520         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7521       else
7522         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7523       synchronizeNameScope();
7524     }
7525 }
7526
7527 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7528 {
7529   if(_time_steps.empty())
7530     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7531   checkThatNbOfCompoOfTSMatchThis();
7532   std::vector<std::string> infos(getInfo());
7533   int nbComp=infos.size();
7534   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7535   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7536   for(int i=0;i<nbComp;i++)
7537     {
7538       std::string info=infos[i];
7539       std::string c,u;
7540       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7541       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7542       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7543     }
7544   if(_name.empty())
7545     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7546   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7547   int nbOfTS=_time_steps.size();
7548   for(int i=0;i<nbOfTS;i++)
7549     _time_steps[i]->writeLL(fid,opts,*this);
7550 }
7551
7552 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7553 {
7554   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7555     {
7556       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7557       if(elt)
7558         elt->loadBigArraysRecursively(fid,nasc);
7559     }
7560 }
7561
7562 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7563 {
7564   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7565     {
7566       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7567       if(elt)
7568         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7569     }
7570 }
7571
7572 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7573 {
7574   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7575     {
7576       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7577       if(elt)
7578         elt->unloadArrays();
7579     }
7580 }
7581
7582 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7583 {
7584   return _time_steps.size();
7585 }
7586
7587 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7588 {
7589   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7590   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7591     {
7592       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7593       if(tmp)
7594         newTS.push_back(*it);
7595     }
7596   _time_steps=newTS;
7597 }
7598
7599 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7600 {
7601   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7602   int maxId=(int)_time_steps.size();
7603   int ii=0;
7604   std::set<int> idsToDel;
7605   for(const int *id=startIds;id!=endIds;id++,ii++)
7606     {
7607       if(*id>=0 && *id<maxId)
7608         {
7609           idsToDel.insert(*id);
7610         }
7611       else
7612         {
7613           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7614           throw INTERP_KERNEL::Exception(oss.str());
7615         }
7616     }
7617   for(int iii=0;iii<maxId;iii++)
7618     if(idsToDel.find(iii)==idsToDel.end())
7619       newTS.push_back(_time_steps[iii]);
7620   _time_steps=newTS;
7621 }
7622
7623 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7624 {
7625   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7626   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7627   if(nbOfEntriesToKill==0)
7628     return ;
7629   std::size_t sz=_time_steps.size();
7630   std::vector<bool> b(sz,true);
7631   int j=bg;
7632   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7633     b[j]=false;
7634   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7635   for(std::size_t i=0;i<sz;i++)
7636     if(b[i])
7637       newTS.push_back(_time_steps[i]);
7638   _time_steps=newTS;
7639 }
7640
7641 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7642 {
7643   int ret=0;
7644   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7645   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7646     {
7647       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7648       if(tmp)
7649         {
7650           int it2,ord;
7651           tmp->getTime(it2,ord);
7652           if(it2==iteration && order==ord)
7653             return ret;
7654           else
7655             oss << "(" << it2 << ","  << ord << "), ";
7656         }
7657     }
7658   throw INTERP_KERNEL::Exception(oss.str());
7659 }
7660
7661 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7662 {
7663   int ret=0;
7664   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7665   oss.precision(15);
7666   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7667     {
7668       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7669       if(tmp)
7670         {
7671           int it2,ord;
7672           double ti=tmp->getTime(it2,ord);
7673           if(fabs(time-ti)<eps)
7674             return ret;
7675           else
7676             oss << ti << ", ";
7677         }
7678     }
7679   throw INTERP_KERNEL::Exception(oss.str());
7680 }
7681
7682 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7683 {
7684   int lgth=_time_steps.size();
7685   std::vector< std::pair<int,int> > ret(lgth);
7686   for(int i=0;i<lgth;i++)
7687     _time_steps[i]->fillIteration(ret[i]);
7688   return ret;
7689 }
7690
7691 /*!
7692  * 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'
7693  * This method returns two things.
7694  * - The absolute dimension of 'this' in first parameter. 
7695  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7696  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7697  *
7698  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7699  * Only these 3 discretizations will be taken into account here.
7700  *
7701  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7702  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7703  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7704  *
7705  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7706  * 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'.
7707  * 
7708  * Let's consider the typical following case :
7709  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7710  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7711  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7712  *   TETRA4 and SEG2
7713  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7714  *
7715  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7716  * 
7717  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7718  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7719  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7720  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7721  */
7722 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7723 {
7724   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7725 }
7726
7727 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7728 {
7729   if(pos<0 || pos>=(int)_time_steps.size())
7730     {
7731       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7732       throw INTERP_KERNEL::Exception(oss.str());
7733     }
7734   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7735   if(item==0)
7736     {
7737       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7738       oss << "\nTry to use following method eraseEmptyTS !";
7739       throw INTERP_KERNEL::Exception(oss.str());
7740     }
7741   return item;
7742 }
7743
7744 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7745 {
7746   if(pos<0 || pos>=(int)_time_steps.size())
7747     {
7748       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7749       throw INTERP_KERNEL::Exception(oss.str());
7750     }
7751   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7752   if(item==0)
7753     {
7754       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7755       oss << "\nTry to use following method eraseEmptyTS !";
7756       throw INTERP_KERNEL::Exception(oss.str());
7757     }
7758   return item;
7759 }
7760
7761 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7762 {
7763   std::vector<std::string> ret;
7764   std::set<std::string> ret2;
7765   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7766     {
7767       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7768       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7769         if(ret2.find(*it2)==ret2.end())
7770           {
7771             ret.push_back(*it2);
7772             ret2.insert(*it2);
7773           }
7774     }
7775   return ret;
7776 }
7777
7778 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7779 {
7780   std::vector<std::string> ret;
7781   std::set<std::string> ret2;
7782   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7783     {
7784       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7785       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7786         if(ret2.find(*it2)==ret2.end())
7787           {
7788             ret.push_back(*it2);
7789             ret2.insert(*it2);
7790           }
7791     }
7792   return ret;
7793 }
7794
7795 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7796 {
7797   std::vector<std::string> ret;
7798   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7799     {
7800       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7801       ret.insert(ret.end(),tmp.begin(),tmp.end());
7802     }
7803   return ret;
7804 }
7805
7806 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7807 {
7808   std::vector<std::string> ret;
7809   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7810     {
7811       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7812       ret.insert(ret.end(),tmp.begin(),tmp.end());
7813     }
7814   return ret;
7815 }
7816
7817 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7818 {
7819   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7820     (*it)->changePflsRefsNamesGen2(mapOfModif);
7821 }
7822
7823 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7824 {
7825   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7826     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7827 }
7828
7829 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7830 {
7831   int lgth=_time_steps.size();
7832   std::vector< std::vector<TypeOfField> > ret(lgth);
7833   for(int i=0;i<lgth;i++)
7834     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7835   return ret;
7836 }
7837
7838 /*!
7839  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7840  */
7841 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
7842 {
7843   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7844 }
7845
7846 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7847 {
7848   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7849   std::size_t i=0;
7850   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7851     {
7852       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7853         ret->_time_steps[i]=(*it)->deepCopy();
7854     }
7855   return ret.retn();
7856 }
7857
7858 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7859 {
7860   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7861   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7862   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7863   for(std::size_t i=0;i<sz;i++)
7864     {
7865       ret[i]=shallowCpy();
7866       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7867     }
7868   for(std::size_t i=0;i<sz2;i++)
7869     {
7870       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7871       if(ret1.size()!=sz)
7872         {
7873           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7874           throw INTERP_KERNEL::Exception(oss.str());
7875         }
7876       ts[i]=ret1;
7877     }
7878   for(std::size_t i=0;i<sz;i++)
7879     for(std::size_t j=0;j<sz2;j++)
7880       ret[i]->_time_steps[j]=ts[j][i];
7881   return ret;
7882 }
7883
7884 /*!
7885  * This method splits into discretization each time steps in \a this.
7886  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7887  */
7888 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7889 {
7890   std::size_t sz(_time_steps.size());
7891   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7892   for(std::size_t i=0;i<sz;i++)
7893     {
7894       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7895       if(!timeStep)
7896         {
7897           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7898           throw INTERP_KERNEL::Exception(oss.str());
7899         }
7900       items[i]=timeStep->splitDiscretizations();  
7901     }
7902   //
7903   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7904   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7905   std::vector< TypeOfField > types;
7906   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7907     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7908       {
7909         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7910         if(ts.size()!=1)
7911           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7912         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7913         if(it2==types.end())
7914           types.push_back(ts[0]);
7915       }
7916   ret.resize(types.size()); ret2.resize(types.size());
7917   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7918     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7919       {
7920         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7921         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7922         ret2[pos].push_back(*it1);
7923       }
7924   for(std::size_t i=0;i<types.size();i++)
7925     {
7926       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7927       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7928         elt->pushBackTimeStep(*it1);//also updates infos in elt
7929       ret[i]=elt;
7930       elt->MEDFileFieldNameScope::operator=(*this);
7931     }
7932   return ret;
7933 }
7934
7935 /*!
7936  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7937  */
7938 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7939 {
7940   std::size_t sz(_time_steps.size());
7941   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7942   std::size_t szOut(std::numeric_limits<std::size_t>::max());
7943   for(std::size_t i=0;i<sz;i++)
7944     {
7945       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7946       if(!timeStep)
7947         {
7948           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7949           throw INTERP_KERNEL::Exception(oss.str());
7950         }
7951       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7952       if(szOut==std::numeric_limits<std::size_t>::max())
7953         szOut=items[i].size();
7954       else
7955         if(items[i].size()!=szOut)
7956           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7957     }
7958   if(szOut==std::numeric_limits<std::size_t>::max())
7959     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7960   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7961   for(std::size_t i=0;i<szOut;i++)
7962     {
7963       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7964       for(std::size_t j=0;j<sz;j++)
7965         elt->pushBackTimeStep(items[j][i]);
7966       ret[i]=elt;
7967       elt->MEDFileFieldNameScope::operator=(*this);
7968     }
7969   return ret;
7970 }
7971
7972 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7973 {
7974   _name=field->getName();
7975   if(_name.empty())
7976     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7977   if(!arr)
7978     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7979   _infos=arr->getInfoOnComponents();
7980 }
7981
7982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7983 {
7984   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7985   if(_name!=field->getName())
7986     {
7987       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7988       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7989       throw INTERP_KERNEL::Exception(oss.str());
7990     }
7991   if(!arr)
7992     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7993   checkThatComponentsMatch(arr->getInfoOnComponents());
7994 }
7995
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7997 {
7998   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7999   if(getInfo().size()!=compos.size())
8000     {
8001       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8002       oss << " number of components of element to append (" << compos.size() << ") !";
8003       throw INTERP_KERNEL::Exception(oss.str());
8004     }
8005   if(_infos!=compos)
8006     {
8007       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8008       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8009       oss << " But compo in input fields are : ";
8010       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8011       oss << " !";
8012       throw INTERP_KERNEL::Exception(oss.str());
8013     }
8014 }
8015
8016 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8017 {
8018   std::size_t sz=_infos.size();
8019   int j=0;
8020   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8021     {
8022       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8023       if(elt)
8024         if(elt->getInfo().size()!=sz)
8025           {
8026             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8027             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8028             throw INTERP_KERNEL::Exception(oss.str());
8029           }
8030     }
8031 }
8032
8033 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8034 {
8035   if(!field)
8036     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8037   if(!_time_steps.empty())
8038     checkCoherencyOfTinyInfo(field,arr);
8039   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8040   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8041   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8042   copyTinyInfoFrom(field,arr);
8043   _time_steps.push_back(obj);
8044 }
8045
8046 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8047 {
8048   if(!field)
8049     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8050   if(!_time_steps.empty())
8051     checkCoherencyOfTinyInfo(field,arr);
8052   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8053   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8054   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8055   copyTinyInfoFrom(field,arr);
8056   _time_steps.push_back(obj);
8057 }
8058
8059 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8060 {
8061   int sz=(int)_time_steps.size();
8062   if(i<0 || i>=sz)
8063     {
8064       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8065       throw INTERP_KERNEL::Exception(oss.str());
8066     }
8067   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8068   if(tsPtr)
8069     {
8070       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8071         {
8072           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8073           throw INTERP_KERNEL::Exception(oss.str());
8074         }
8075     }
8076   _time_steps[i]=ts;
8077 }
8078
8079 //= MEDFileFieldMultiTSWithoutSDA
8080
8081 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)
8082 {
8083   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8084 }
8085
8086 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8087 {
8088 }
8089
8090 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8091 {
8092 }
8093
8094 /*!
8095  * \param [in] fieldId field id in C mode
8096  */
8097 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8098 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8099 {
8100 }
8101 catch(INTERP_KERNEL::Exception& e)
8102 { throw e; }
8103
8104 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)
8105 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8106 {
8107 }
8108 catch(INTERP_KERNEL::Exception& e)
8109 { throw e; }
8110
8111 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8112 {
8113   return new MEDFileField1TSWithoutSDA;
8114 }
8115
8116 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8117 {
8118   if(!f1ts)
8119     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8120   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8121   if(!f1tsC)
8122     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8123 }
8124
8125 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8126 {
8127   return MEDFileField1TSWithoutSDA::TYPE_STR;
8128 }
8129
8130 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8131 {
8132   return new MEDFileFieldMultiTSWithoutSDA(*this);
8133 }
8134
8135 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8136 {
8137   return new MEDFileFieldMultiTSWithoutSDA;
8138 }
8139
8140 /*!
8141  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8142  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8143  */
8144 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
8145 {
8146   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8147   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8148   if(!myF1TSC)
8149     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8150   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8151 }
8152
8153 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8154 {
8155   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8156   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8157   int i=0;
8158   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8159     {
8160       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8161       if(eltToConv)
8162         {
8163           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8164           if(!eltToConvC)
8165             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8166           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8167           ret->setIteration(i,elt);
8168         }
8169     }
8170   return ret.retn();
8171 }
8172
8173 //= MEDFileAnyTypeFieldMultiTS
8174
8175 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8176 {
8177 }
8178
8179 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8180 try:MEDFileFieldGlobsReal(fid)
8181 {
8182   _content=BuildContentFrom(fid,loadAll,ms);
8183   loadGlobals(fid);
8184 }
8185 catch(INTERP_KERNEL::Exception& e)
8186 {
8187     throw e;
8188 }
8189
8190 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8191 {
8192   med_field_type typcha;
8193   std::vector<std::string> infos;
8194   std::string dtunit;
8195   int i(-1);
8196   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8197   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8198   switch(typcha)
8199   {
8200     case MED_FLOAT64:
8201       {
8202         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8203         break;
8204       }
8205     case MED_INT32:
8206       {
8207         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8208         break;
8209       }
8210     default:
8211       {
8212         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] !";
8213         throw INTERP_KERNEL::Exception(oss.str());
8214       }
8215   }
8216   ret->setDtUnit(dtunit.c_str());
8217   return ret.retn();
8218 }
8219
8220 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8221 {
8222   med_field_type typcha;
8223   //
8224   std::vector<std::string> infos;
8225   std::string dtunit,fieldName;
8226   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8227   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8228   switch(typcha)
8229   {
8230     case MED_FLOAT64:
8231       {
8232         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8233         break;
8234       }
8235     case MED_INT32:
8236       {
8237         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8238         break;
8239       }
8240     default:
8241       {
8242         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] !";
8243         throw INTERP_KERNEL::Exception(oss.str());
8244       }
8245   }
8246   ret->setDtUnit(dtunit.c_str());
8247   return ret.retn();
8248 }
8249
8250 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8251 {
8252   if(!c)
8253     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8254   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8255     {
8256       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8257       ret->_content=c;  c->incrRef();
8258       return ret.retn();
8259     }
8260   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8261     {
8262       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8263       ret->_content=c;  c->incrRef();
8264       return ret.retn();
8265     }
8266   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8267 }
8268
8269 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8270 {
8271   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8272   std::string fileName(FileNameFromFID(fid));
8273   ret->setFileName(fileName);
8274   return ret;
8275 }
8276
8277 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8278 try:MEDFileFieldGlobsReal(fid)
8279 {
8280   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8281   loadGlobals(fid);
8282 }
8283 catch(INTERP_KERNEL::Exception& e)
8284 {
8285     throw e;
8286 }
8287
8288 //= MEDFileIntFieldMultiTSWithoutSDA
8289
8290 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)
8291 {
8292   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8293 }
8294
8295 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8296 {
8297 }
8298
8299 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8300 {
8301 }
8302
8303 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)
8304 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8305 {
8306 }
8307 catch(INTERP_KERNEL::Exception& e)
8308 { throw e; }
8309
8310 /*!
8311  * \param [in] fieldId field id in C mode
8312  */
8313 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8314 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8315 {
8316 }
8317 catch(INTERP_KERNEL::Exception& e)
8318 { throw e; }
8319
8320 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8321 {
8322   return new MEDFileIntField1TSWithoutSDA;
8323 }
8324
8325 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8326 {
8327   if(!f1ts)
8328     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8329   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8330   if(!f1tsC)
8331     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8332 }
8333
8334 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8335 {
8336   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8337 }
8338
8339 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8340 {
8341   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8342 }
8343
8344 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8345 {
8346   return new MEDFileIntFieldMultiTSWithoutSDA;
8347 }
8348
8349 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8350 {
8351   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8352   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8353   int i=0;
8354   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8355     {
8356       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8357       if(eltToConv)
8358         {
8359           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8360           if(!eltToConvC)
8361             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8362           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8363           ret->setIteration(i,elt);
8364         }
8365     }
8366   return ret.retn();
8367 }
8368
8369 //= MEDFileAnyTypeFieldMultiTS
8370
8371 /*!
8372  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8373  * that has been read from a specified MED file.
8374  *  \param [in] fileName - the name of the MED file to read.
8375  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8376  *          is to delete this field using decrRef() as it is no more needed.
8377  *  \throw If reading the file fails.
8378  */
8379 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8380 {
8381   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8382   return New(fid,loadAll);
8383 }
8384
8385 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8386 {
8387   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8388   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8389   ret->loadGlobals(fid);
8390   return ret.retn();
8391 }
8392
8393 /*!
8394  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8395  * that has been read from a specified MED file.
8396  *  \param [in] fileName - the name of the MED file to read.
8397  *  \param [in] fieldName - the name of the field to read.
8398  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8399  *          is to delete this field using decrRef() as it is no more needed.
8400  *  \throw If reading the file fails.
8401  *  \throw If there is no field named \a fieldName in the file.
8402  */
8403 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8404 {
8405   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8406   return New(fid,fieldName,loadAll);
8407 }
8408
8409 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8410 {
8411   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8412   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8413   ret->loadGlobals(fid);
8414   return ret.retn();
8415 }
8416
8417 /*!
8418  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8419  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8420  *
8421  * \warning this is a shallow copy constructor
8422  */
8423 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8424 {
8425   if(!shallowCopyOfContent)
8426     {
8427       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8428       otherPtr->incrRef();
8429       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8430     }
8431   else
8432     {
8433       _content=other.shallowCpy();
8434     }
8435 }
8436
8437 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8438 {
8439   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8440   if(!ret)
8441     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8442   return ret;
8443 }
8444
8445 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8446 {
8447   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8448   if(!ret)
8449     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8450   return ret;
8451 }
8452
8453 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8454 {
8455   return contentNotNullBase()->getPflsReallyUsed2();
8456 }
8457
8458 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8459 {
8460   return contentNotNullBase()->getLocsReallyUsed2();
8461 }
8462
8463 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8464 {
8465   return contentNotNullBase()->getPflsReallyUsedMulti2();
8466 }
8467
8468 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8469 {
8470   return contentNotNullBase()->getLocsReallyUsedMulti2();
8471 }
8472
8473 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8474 {
8475   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8476 }
8477
8478 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8479 {
8480   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8481 }
8482
8483 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8484 {
8485   return contentNotNullBase()->getNumberOfTS();
8486 }
8487
8488 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8489 {
8490   contentNotNullBase()->eraseEmptyTS();
8491 }
8492
8493 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8494 {
8495   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8496 }
8497
8498 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8499 {
8500   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8501 }
8502
8503 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8504 {
8505   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8506   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8507   ret->_content=c;
8508   return ret.retn();
8509 }
8510
8511 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8512 {
8513   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8514   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8515   ret->_content=c;
8516   return ret.retn();
8517 }
8518
8519 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8520 {
8521   return contentNotNullBase()->getIterations();
8522 }
8523
8524 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8525 {
8526   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8527     pushBackTimeStep(*it);
8528 }
8529
8530 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8531 {
8532   if(!fmts)
8533     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8534   int nbOfTS(fmts->getNumberOfTS());
8535   for(int i=0;i<nbOfTS;i++)
8536     {
8537       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8538       pushBackTimeStep(elt);
8539     }
8540 }
8541
8542 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8543 {
8544   if(!f1ts)
8545     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8546   checkCoherencyOfType(f1ts);
8547   f1ts->incrRef();
8548   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8549   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8550   c->incrRef();
8551   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8552   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8553     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8554   _content->pushBackTimeStep(cSafe);
8555   appendGlobs(*f1ts,1e-12);
8556 }
8557
8558 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8559 {
8560   contentNotNullBase()->synchronizeNameScope();
8561 }
8562
8563 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8564 {
8565   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8566 }
8567
8568 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8569 {
8570   return contentNotNullBase()->getPosGivenTime(time,eps);
8571 }
8572
8573 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8574 {
8575   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8576 }
8577
8578 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8579 {
8580   return contentNotNullBase()->getTypesOfFieldAvailable();
8581 }
8582
8583 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
8584 {
8585   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8586 }
8587
8588 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8589 {
8590   return contentNotNullBase()->getName();
8591 }
8592
8593 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8594 {
8595   contentNotNullBase()->setName(name);
8596 }
8597
8598 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8599 {
8600   return contentNotNullBase()->getDtUnit();
8601 }
8602
8603 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8604 {
8605   contentNotNullBase()->setDtUnit(dtUnit);
8606 }
8607
8608 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8609 {
8610   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8611 }
8612
8613 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8614 {
8615   return contentNotNullBase()->getTimeSteps(ret1);
8616 }
8617
8618 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8619 {
8620   return contentNotNullBase()->getMeshName();
8621 }
8622
8623 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8624 {
8625   contentNotNullBase()->setMeshName(newMeshName);
8626 }
8627
8628 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8629 {
8630   return contentNotNullBase()->changeMeshNames(modifTab);
8631 }
8632
8633 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8634 {
8635   return contentNotNullBase()->getInfo();
8636 }
8637
8638 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8639 {
8640   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8641 }
8642
8643 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8644 {
8645   return contentNotNullBase()->setInfo(info);
8646 }
8647
8648 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8649 {
8650   const std::vector<std::string> ret=getInfo();
8651   return (int)ret.size();
8652 }
8653
8654 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8655 {
8656   writeGlobals(fid,*this);
8657   contentNotNullBase()->writeLL(fid,*this);
8658 }
8659
8660 /*!
8661  * This method alloc the arrays and load potentially huge arrays contained in this field.
8662  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8663  * This method can be also called to refresh or reinit values from a file.
8664  * 
8665  * \throw If the fileName is not set or points to a non readable MED file.
8666  */
8667 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8668 {
8669   if(getFileName().empty())
8670     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8671   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8672   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8673 }
8674
8675 /*!
8676  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8677  * But once data loaded once, this method does nothing.
8678  * 
8679  * \throw If the fileName is not set or points to a non readable MED file.
8680  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8681  */
8682 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8683 {
8684   if(!getFileName().empty())
8685     {
8686       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8687       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8688     }
8689 }
8690
8691 /*!
8692  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8693  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8694  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8695  * 
8696  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8697  */
8698 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8699 {
8700   contentNotNullBase()->unloadArrays();
8701 }
8702
8703 /*!
8704  * 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.
8705  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8706  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8707  * 
8708  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8709  */
8710 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8711 {
8712   if(!getFileName().empty())
8713     contentNotNullBase()->unloadArrays();
8714 }
8715
8716 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8717 {
8718   std::ostringstream oss;
8719   contentNotNullBase()->simpleRepr(0,oss,-1);
8720   simpleReprGlobs(oss);
8721   return oss.str();
8722 }
8723
8724 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8725 {
8726   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8727 }
8728
8729 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8730 {
8731   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8732   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8733   return ret;
8734 }
8735
8736 /*!
8737  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8738  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8739  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8740  */
8741 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8742 {
8743   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8744   if(!content)
8745     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8746   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8747   std::size_t sz(contentsSplit.size());
8748   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8749   for(std::size_t i=0;i<sz;i++)
8750     {
8751       ret[i]=shallowCpy();
8752       ret[i]->_content=contentsSplit[i];
8753     }
8754   return ret;
8755 }
8756
8757 /*!
8758  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8759  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8760  */
8761 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8762 {
8763   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8764   if(!content)
8765     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8766   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8767   std::size_t sz(contentsSplit.size());
8768   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8769   for(std::size_t i=0;i<sz;i++)
8770     {
8771       ret[i]=shallowCpy();
8772       ret[i]->_content=contentsSplit[i];
8773     }
8774   return ret;
8775 }
8776
8777 /*!
8778  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8779  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8780  */
8781 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8782 {
8783   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8784   if(!content)
8785     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8786   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8787   std::size_t sz(contentsSplit.size());
8788   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8789   for(std::size_t i=0;i<sz;i++)
8790     {
8791       ret[i]=shallowCpy();
8792       ret[i]->_content=contentsSplit[i];
8793     }
8794   return ret;
8795 }
8796
8797 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8798 {
8799   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8800   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8801     ret->_content=_content->deepCopy();
8802   ret->deepCpyGlobs(*this);
8803   return ret.retn();
8804 }
8805
8806 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8807 {
8808   return _content;
8809 }
8810
8811 /*!
8812  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8813  *  \param [in] iteration - the iteration number of a required time step.
8814  *  \param [in] order - the iteration order number of required time step.
8815  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8816  *          delete this field using decrRef() as it is no more needed.
8817  *  \throw If there is no required time step in \a this field.
8818  */
8819 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8820 {
8821   int pos=getPosOfTimeStep(iteration,order);
8822   return getTimeStepAtPos(pos);
8823 }
8824
8825 /*!
8826  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8827  *  \param [in] time - the time of the time step of interest.
8828  *  \param [in] eps - a precision used to compare time values.
8829  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8830  *          delete this field using decrRef() as it is no more needed.
8831  *  \throw If there is no required time step in \a this field.
8832  */
8833 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8834 {
8835   int pos=getPosGivenTime(time,eps);
8836   return getTimeStepAtPos(pos);
8837 }
8838
8839 /*!
8840  * 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.
8841  * The float64 value of time attached to the pair of integers are not considered here.
8842  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8843  *
8844  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8845  * \throw If there is a null pointer in \a vectFMTS.
8846  */
8847 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8848 {
8849   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8850   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8851   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8852   while(!lstFMTS.empty())
8853     {
8854       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8855       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8856       if(!curIt)
8857         throw INTERP_KERNEL::Exception(msg);
8858       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8859       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8860       elt.push_back(curIt); it=lstFMTS.erase(it);
8861       while(it!=lstFMTS.end())
8862         {
8863           curIt=*it;
8864           if(!curIt)
8865             throw INTERP_KERNEL::Exception(msg);
8866           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8867           if(refIts==curIts)
8868             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8869           else
8870             it++;
8871         }
8872       ret.push_back(elt);
8873     }
8874   return ret;
8875 }
8876
8877 /*!
8878  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8879  * All returned instances in a subvector can be safely loaded, rendered along time
8880  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8881  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8882  * 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).
8883  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8884  * 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.
8885  *
8886  * \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().
8887  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8888  * \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.
8889  * \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.
8890  *
8891  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8892  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8893  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8894  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8895  * \throw If mesh is null.
8896  * \throw If an element in \a vectFMTS is null.
8897  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8898  */
8899 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8900 {
8901   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8902   if(!mesh)
8903     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8904   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8905   if(vectFMTS.empty())
8906     return ret;
8907   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8908   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8909   if(!frstElt)
8910     throw INTERP_KERNEL::Exception(msg);
8911   std::size_t i=0;
8912   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8913   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8914   for(;it!=vectFMTS.end();it++,i++)
8915     {
8916       if(!(*it))
8917         throw INTERP_KERNEL::Exception(msg);
8918       TypeOfField tof0,tof1;
8919       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8920         {
8921           if(tof1!=ON_NODES)
8922             vectFMTSNotNodes.push_back(*it);
8923           else
8924             vectFMTSNodes.push_back(*it);
8925         }
8926       else
8927         vectFMTSNotNodes.push_back(*it);
8928     }
8929   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8930   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8931   ret=retCell;
8932   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8933     {
8934       i=0;
8935       bool isFetched(false);
8936       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8937         {
8938           if((*it0).empty())
8939             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8940           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8941             { ret[i].push_back(*it2); isFetched=true; }
8942         }
8943       if(!isFetched)
8944         {
8945           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8946           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8947           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8948         }
8949     }
8950   fsc=cmps;
8951   return ret;
8952 }
8953
8954 /*!
8955  * 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.
8956  * \param [out] cmps - same size than the returned vector.
8957  */
8958 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8959 {
8960   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8961   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8962   while(!lstFMTS.empty())
8963     {
8964       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8965       MEDFileAnyTypeFieldMultiTS *ref(*it);
8966       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8967       elt.push_back(ref); it=lstFMTS.erase(it);
8968       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8969       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8970       while(it!=lstFMTS.end())
8971         {
8972           MEDFileAnyTypeFieldMultiTS *curIt(*it);
8973           if(cmp->isEqual(curIt))
8974             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8975           else
8976             it++;
8977         }
8978       ret.push_back(elt); cmps.push_back(cmp);
8979     }
8980   return ret;
8981 }
8982
8983 /*!
8984  * 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.
8985  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8986  *
8987  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8988  * \throw If \a f0 or \a f1 change of spatial discretization along time.
8989  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8990  * \thorw If \a f0 and \a f1 do not have the same times steps.
8991  * \throw If mesh is null.
8992  * \throw If \a f0 or \a f1 is null.
8993  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8994  */
8995 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8996 {
8997   if(!mesh)
8998     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8999   if(!f0 || !f1)
9000     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9001   if(f0->getMeshName()!=mesh->getName())
9002     {
9003       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9004       throw INTERP_KERNEL::Exception(oss.str());
9005     }
9006   if(f1->getMeshName()!=mesh->getName())
9007     {
9008       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9009       throw INTERP_KERNEL::Exception(oss.str());
9010     }
9011   int nts=f0->getNumberOfTS();
9012   if(nts!=f1->getNumberOfTS())
9013     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9014   if(nts==0)
9015     return nts;
9016   for(int i=0;i<nts;i++)
9017     {
9018       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9019       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9020       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9021       if(tofs0.size()!=1 || tofs1.size()!=1)
9022         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9023       if(i!=0)
9024         {
9025           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9026             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9027         }
9028       else
9029         { tof0=tofs0[0]; tof1=tofs1[0]; }
9030       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9031         {
9032           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() << ") !";
9033           throw INTERP_KERNEL::Exception(oss.str());
9034         }
9035       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9036         {
9037           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() << ") !";
9038           throw INTERP_KERNEL::Exception(oss.str());
9039         }
9040       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9041         {
9042           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() << ") !";
9043           throw INTERP_KERNEL::Exception(oss.str());
9044         }
9045     }
9046   return nts;
9047 }
9048
9049 /*!
9050  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9051  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9052  *
9053  * \return A new object that the caller is responsible to deallocate.
9054  */
9055 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9056 {
9057   if(!mm)
9058     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9059   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9060   int nbTS(getNumberOfTS());
9061   for(int i=0;i<nbTS;i++)
9062     {
9063       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9064       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9065       fmtsOut->pushBackTimeStep(f1tsOut);
9066     }
9067   return fmtsOut.retn();
9068 }
9069
9070 template<class T>
9071 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9072 {
9073   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9074   if(f1tss.empty())
9075     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9076   std::size_t sz(f1tss.size()),i(0);
9077   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9078   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9079     {
9080       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9081       if(!elt)
9082         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9083       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9084     }
9085   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9086   if(!retc)
9087     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9088   retc->aggregate(f1tsw,dts);
9089   ret->setDtUnit(f1tss[0]->getDtUnit());
9090   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9091 }
9092
9093 template<class T>
9094 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9095 {
9096   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9097   if(fmtss.empty())
9098     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9099   std::size_t sz(fmtss.size());
9100   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9101     {
9102       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9103       if(!elt)
9104         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9105     }
9106   int nbTS(fmtss[0]->getNumberOfTS());
9107   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9108     if((*it)->getNumberOfTS()!=nbTS)
9109       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9110   for(int iterTS=0;iterTS<nbTS;iterTS++)
9111     {
9112       std::size_t i(0);
9113       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9114       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9115       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9116         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9117       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9118       ret->pushBackTimeStep(f1ts);
9119       ret->setDtUnit(f1ts->getDtUnit());
9120     }
9121   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9122 }
9123
9124 /*!
9125  * \a dts and \a ftmss are expected to have same size.
9126  */
9127 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9128 {
9129   if(fmtss.empty())
9130     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9131   std::size_t sz(fmtss.size());
9132   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9133   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9134   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9135     {
9136       if(!(*it))
9137         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9138       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9139       if(elt1)
9140         {
9141           fmtss1.push_back(elt1);
9142           continue;
9143         }
9144       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9145       if(elt2)
9146         {
9147           fmtss2.push_back(elt2);
9148           continue;
9149         }
9150       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9151     }
9152   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9153     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9154   if(fmtss1.size()==sz)
9155     return AggregateHelperFMTS<double>(fmtss1,dts);
9156   if(fmtss2.size()!=sz)
9157     return AggregateHelperFMTS<int>(fmtss2,dts);
9158   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9159 }
9160
9161 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9162 {
9163   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9164 }
9165
9166 //= MEDFileFieldMultiTS
9167
9168 /*!
9169  * Returns a new empty instance of MEDFileFieldMultiTS.
9170  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9171  *          is to delete this field using decrRef() as it is no more needed.
9172  */
9173 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9174 {
9175   return new MEDFileFieldMultiTS;
9176 }
9177
9178 /*!
9179  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9180  * that has been read from a specified MED file.
9181  *  \param [in] fileName - the name of the MED file to read.
9182  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9183  *          is to delete this field using decrRef() as it is no more needed.
9184  *  \throw If reading the file fails.
9185  */
9186 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9187 {
9188   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9189   return New(fid,loadAll);
9190 }
9191
9192 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9193 {
9194   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9195   ret->contentNotNull();//to check that content type matches with \a this type.
9196   return ret.retn();
9197 }
9198
9199 /*!
9200  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9201  * that has been read from a specified MED file.
9202  *  \param [in] fileName - the name of the MED file to read.
9203  *  \param [in] fieldName - the name of the field to read.
9204  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9205  *          is to delete this field using decrRef() as it is no more needed.
9206  *  \throw If reading the file fails.
9207  *  \throw If there is no field named \a fieldName in the file.
9208  */
9209 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9210 {
9211   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9212   return New(fid,fieldName,loadAll);
9213 }
9214
9215 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9216 {
9217   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9218   ret->contentNotNull();//to check that content type matches with \a this type.
9219   return ret.retn();
9220 }
9221
9222 /*!
9223  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9224  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9225  *
9226  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9227  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9228  * \warning this is a shallow copy constructor
9229  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9230  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9231  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9232  *          is to delete this field using decrRef() as it is no more needed.
9233  */
9234 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9235 {
9236   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9237 }
9238
9239 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9240 {
9241   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9242   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9243   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9244   ret->contentNotNull();//to check that content type matches with \a this type.
9245   return ret.retn();
9246 }
9247
9248 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9249 {
9250   return new MEDFileFieldMultiTS(*this);
9251 }
9252
9253 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9254 {
9255   if(!f1ts)
9256     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9257   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9258   if(!f1tsC)
9259     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9260 }
9261
9262 /*!
9263  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9264  * following the given input policy.
9265  *
9266  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9267  *                            By default (true) the globals are deeply copied.
9268  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9269  */
9270 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9271 {
9272   MCAuto<MEDFileIntFieldMultiTS> ret;
9273   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9274   if(content)
9275     {
9276       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9277       if(!contc)
9278         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9279       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9280       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9281     }
9282   else
9283     ret=MEDFileIntFieldMultiTS::New();
9284   if(isDeepCpyGlobs)
9285     ret->deepCpyGlobs(*this);
9286   else
9287     ret->shallowCpyGlobs(*this);
9288   return ret.retn();
9289 }
9290
9291 /*!
9292  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9293  *  \param [in] pos - a time step id.
9294  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9295  *          delete this field using decrRef() as it is no more needed.
9296  *  \throw If \a pos is not a valid time step id.
9297  */
9298 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9299 {
9300   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9301   if(!item)
9302     {
9303       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9304       throw INTERP_KERNEL::Exception(oss.str());
9305     }
9306   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9307   if(itemC)
9308     {
9309       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9310       ret->shallowCpyGlobs(*this);
9311       return ret.retn();
9312     }
9313   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9314   throw INTERP_KERNEL::Exception(oss.str());
9315 }
9316
9317 /*!
9318  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9319  * mesh entities of a given dimension of the first mesh in MED file.
9320  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9321  *  \param [in] type - a spatial discretization of interest.
9322  *  \param [in] iteration - the iteration number of a required time step.
9323  *  \param [in] order - the iteration order number of required time step.
9324  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9325  *  \param [in] renumPol - specifies how to permute values of the result field according to
9326  *          the optional numbers of cells and nodes, if any. The valid values are
9327  *          - 0 - do not permute.
9328  *          - 1 - permute cells.
9329  *          - 2 - permute nodes.
9330  *          - 3 - permute cells and nodes.
9331  *
9332  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9333  *          caller is to delete this field using decrRef() as it is no more needed. 
9334  *  \throw If the MED file is not readable.
9335  *  \throw If there is no mesh in the MED file.
9336  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9337  *  \throw If no field values of the required parameters are available.
9338  */
9339 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9340 {
9341   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9342   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9343   if(!myF1TSC)
9344     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9345   MCAuto<DataArray> arrOut;
9346   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9347   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9348   return ret.retn();
9349 }
9350
9351 /*!
9352  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9353  * the top level cells of the first mesh in MED file.
9354  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9355  *  \param [in] type - a spatial discretization of interest.
9356  *  \param [in] iteration - the iteration number of a required time step.
9357  *  \param [in] order - the iteration order number of required time step.
9358  *  \param [in] renumPol - specifies how to permute values of the result field according to
9359  *          the optional numbers of cells and nodes, if any. The valid values are
9360  *          - 0 - do not permute.
9361  *          - 1 - permute cells.
9362  *          - 2 - permute nodes.
9363  *          - 3 - permute cells and nodes.
9364  *
9365  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9366  *          caller is to delete this field using decrRef() as it is no more needed. 
9367  *  \throw If the MED file is not readable.
9368  *  \throw If there is no mesh in the MED file.
9369  *  \throw If no field values of the required parameters are available.
9370  */
9371 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9372 {
9373   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9374   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9375   if(!myF1TSC)
9376     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9377   MCAuto<DataArray> arrOut;
9378   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9379   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9380   return ret.retn();
9381 }
9382
9383 /*!
9384  * 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
9385  * method should be called (getFieldOnMeshAtLevel for example).
9386  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9387  *
9388  * \param [in] iteration - the iteration number of a required time step.
9389  * \param [in] order - the iteration order number of required time step.
9390  * \param [in] mesh - the mesh the field is lying on
9391  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9392  *          caller is to delete this field using decrRef() as it is no more needed. 
9393  */
9394 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9395 {
9396   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9397   MCAuto<DataArray> arrOut;
9398   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9399   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9400   return ret.retn();
9401 }
9402
9403 /*!
9404  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9405  * a given support.
9406  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9407  *  \param [in] type - a spatial discretization of interest.
9408  *  \param [in] iteration - the iteration number of a required time step.
9409  *  \param [in] order - the iteration order number of required time step.
9410  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9411  *  \param [in] mesh - the supporting mesh.
9412  *  \param [in] renumPol - specifies how to permute values of the result field according to
9413  *          the optional numbers of cells and nodes, if any. The valid values are
9414  *          - 0 - do not permute.
9415  *          - 1 - permute cells.
9416  *          - 2 - permute nodes.
9417  *          - 3 - permute cells and nodes.
9418  *
9419  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9420  *          caller is to delete this field using decrRef() as it is no more needed. 
9421  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9422  *  \throw If no field of \a this is lying on \a mesh.
9423  *  \throw If no field values of the required parameters are available.
9424  */
9425 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9426 {
9427   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9428   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9429   if(!myF1TSC)
9430     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9431   MCAuto<DataArray> arrOut;
9432   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9433   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9434   return ret.retn();
9435 }
9436
9437 /*!
9438  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9439  * given support. 
9440  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9441  *  \param [in] type - a spatial discretization of the new field.
9442  *  \param [in] iteration - the iteration number of a required time step.
9443  *  \param [in] order - the iteration order number of required time step.
9444  *  \param [in] mesh - the supporting mesh.
9445  *  \param [in] renumPol - specifies how to permute values of the result field according to
9446  *          the optional numbers of cells and nodes, if any. The valid values are
9447  *          - 0 - do not permute.
9448  *          - 1 - permute cells.
9449  *          - 2 - permute nodes.
9450  *          - 3 - permute cells and nodes.
9451  *
9452  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9453  *          caller is to delete this field using decrRef() as it is no more needed. 
9454  *  \throw If no field of \a this is lying on \a mesh.
9455  *  \throw If no field values of the required parameters are available.
9456  */
9457 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9458 {
9459   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9460   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9461   if(!myF1TSC)
9462     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9463   MCAuto<DataArray> arrOut;
9464   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9465   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9466   return ret.retn();
9467 }
9468
9469 /*!
9470  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9471  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9472  * This method is useful for MED2 file format when field on different mesh was autorized.
9473  */
9474 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9475 {
9476   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9477   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9478   if(!myF1TSC)
9479     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9480   MCAuto<DataArray> arrOut;
9481   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9482   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9483   return ret.retn();
9484 }
9485
9486 /*!
9487  * Returns values and a profile of the field of a given type, of a given time step,
9488  * lying on a given support.
9489  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9490  *  \param [in] type - a spatial discretization of the field.
9491  *  \param [in] iteration - the iteration number of a required time step.
9492  *  \param [in] order - the iteration order number of required time step.
9493  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9494  *  \param [in] mesh - the supporting mesh.
9495  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9496  *          field of interest lies on. If the field lies on all entities of the given
9497  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9498  *          using decrRef() as it is no more needed.  
9499  *  \param [in] glob - the global data storing profiles and localization.
9500  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9501  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9502  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9503  *  \throw If no field of \a this is lying on \a mesh.
9504  *  \throw If no field values of the required parameters are available.
9505  */
9506 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9507 {
9508   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9509   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9510   if(!myF1TSC)
9511     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9512   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9513   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9514 }
9515
9516 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9517 {
9518   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9519   if(!pt)
9520     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9521   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9522   if(!ret)
9523     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 !");
9524   return ret;
9525 }
9526
9527 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9528 {
9529   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9530   if(!pt)
9531     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9532   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9533   if(!ret)
9534     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 !");
9535   return ret;
9536 }
9537
9538 /*!
9539  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9540  * the given field is checked if its elements are sorted suitable for writing to MED file
9541  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9542  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9543  *  \param [in] field - the field to add to \a this.
9544  *  \throw If the name of \a field is empty.
9545  *  \throw If the data array of \a field is not set.
9546  *  \throw If existing time steps have different name or number of components than \a field.
9547  *  \throw If the underlying mesh of \a field has no name.
9548  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9549  */
9550 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9551 {
9552   const DataArrayDouble *arr=0;
9553   if(field)
9554     arr=field->getArray();
9555   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9556 }
9557
9558 /*!
9559  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9560  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9561  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9562  * and \a profile.
9563  *
9564  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9565  * A new profile is added only if no equal profile is missing.
9566  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9567  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9568  *  \param [in] mesh - the supporting mesh of \a field.
9569  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9570  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9571  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9572  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9573  *  \throw If the data array of \a field is not set.
9574  *  \throw If the data array of \a this is already allocated but has different number of
9575  *         components than \a field.
9576  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9577  *  \sa setFieldNoProfileSBT()
9578  */
9579 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9580 {
9581   const DataArrayDouble *arr=0;
9582   if(field)
9583     arr=field->getArray();
9584   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9585 }
9586
9587 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9588 {
9589   _content=new MEDFileFieldMultiTSWithoutSDA;
9590 }
9591
9592 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9593 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9594 {
9595 }
9596 catch(INTERP_KERNEL::Exception& e)
9597 { throw e; }
9598
9599 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9600 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9601 {
9602 }
9603 catch(INTERP_KERNEL::Exception& e)
9604 { throw e; }
9605
9606 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9607 {
9608 }
9609
9610 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
9611 {
9612   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9613 }
9614
9615 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9616 {
9617   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9618 }
9619
9620 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9621 {
9622   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9623 }
9624
9625 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9626 {
9627   return MEDFileFieldMultiTS::New();
9628 }
9629
9630 //= MEDFileAnyTypeFieldMultiTSIterator
9631
9632 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9633 {
9634   if(fmts)
9635     {
9636       fmts->incrRef();
9637       _nb_iter=fmts->getNumberOfTS();
9638     }
9639 }
9640
9641 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9642 {
9643 }
9644
9645 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9646 {
9647   if(_iter_id<_nb_iter)
9648     {
9649       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9650       if(fmts)
9651         return fmts->getTimeStepAtPos(_iter_id++);
9652       else
9653         return 0;
9654     }
9655   else
9656     return 0;
9657 }
9658
9659 //= MEDFileIntFieldMultiTS
9660
9661 /*!
9662  * Returns a new empty instance of MEDFileFieldMultiTS.
9663  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9664  *          is to delete this field using decrRef() as it is no more needed.
9665  */
9666 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9667 {
9668   return new MEDFileIntFieldMultiTS;
9669 }
9670
9671 /*!
9672  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9673  * that has been read from a specified MED file.
9674  *  \param [in] fileName - the name of the MED file to read.
9675  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9676  *          is to delete this field using decrRef() as it is no more needed.
9677  *  \throw If reading the file fails.
9678  */
9679 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9680 {
9681   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9682   return New(fid,loadAll);
9683 }
9684
9685 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9686 {
9687   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9688   ret->contentNotNull();//to check that content type matches with \a this type.
9689   return ret.retn();
9690 }
9691
9692 /*!
9693  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9694  * that has been read from a specified MED file.
9695  *  \param [in] fileName - the name of the MED file to read.
9696  *  \param [in] fieldName - the name of the field to read.
9697  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9698  *          is to delete this field using decrRef() as it is no more needed.
9699  *  \throw If reading the file fails.
9700  *  \throw If there is no field named \a fieldName in the file.
9701  */
9702 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9703 {
9704   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9705   return New(fid,fieldName,loadAll);
9706 }
9707
9708 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9709 {
9710   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9711   ret->contentNotNull();//to check that content type matches with \a this type.
9712   return ret.retn();
9713 }
9714
9715 /*!
9716  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9717  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9718  *
9719  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9720  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9721  * \warning this is a shallow copy constructor
9722  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9723  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9724  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9725  *          is to delete this field using decrRef() as it is no more needed.
9726  */
9727 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9728 {
9729   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9730 }
9731
9732 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9733 {
9734   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9735   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9736   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9737   ret->contentNotNull();//to check that content type matches with \a this type.
9738   return ret.retn();
9739 }
9740
9741 /*!
9742  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9743  * following the given input policy.
9744  *
9745  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9746  *                            By default (true) the globals are deeply copied.
9747  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9748  */
9749 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9750 {
9751   MCAuto<MEDFileFieldMultiTS> ret;
9752   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9753   if(content)
9754     {
9755       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9756       if(!contc)
9757         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9758       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9759       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9760     }
9761   else
9762     ret=MEDFileFieldMultiTS::New();
9763   if(isDeepCpyGlobs)
9764     ret->deepCpyGlobs(*this);
9765   else
9766     ret->shallowCpyGlobs(*this);
9767   return ret.retn();
9768 }
9769
9770 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9771 {
9772   return new MEDFileIntFieldMultiTS(*this);
9773 }
9774
9775 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9776 {
9777   if(!f1ts)
9778     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9779   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9780   if(!f1tsC)
9781     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9782 }
9783
9784 /*!
9785  * 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
9786  * method should be called (getFieldOnMeshAtLevel for example).
9787  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9788  *
9789  * \param [in] iteration - the iteration number of a required time step.
9790  * \param [in] order - the iteration order number of required time step.
9791  * \param [in] mesh - the mesh the field is lying on
9792  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9793  *          caller is to delete this field using decrRef() as it is no more needed. 
9794  */
9795 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9796 {
9797   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9798   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9799   if(!myF1TSC)
9800     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9801   MCAuto<DataArray> arrOut;
9802   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9803   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9804   return ret2.retn();
9805 }
9806
9807 /*!
9808  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9809  * mesh entities of a given dimension of the first mesh in MED file.
9810  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9811  *  \param [in] type - a spatial discretization of interest.
9812  *  \param [in] iteration - the iteration number of a required time step.
9813  *  \param [in] order - the iteration order number of required time step.
9814  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9815  *  \param [in] renumPol - specifies how to permute values of the result field according to
9816  *          the optional numbers of cells and nodes, if any. The valid values are
9817  *          - 0 - do not permute.
9818  *          - 1 - permute cells.
9819  *          - 2 - permute nodes.
9820  *          - 3 - permute cells and nodes.
9821  *
9822  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9823  *          caller is to delete this field using decrRef() as it is no more needed. 
9824  *  \throw If the MED file is not readable.
9825  *  \throw If there is no mesh in the MED file.
9826  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9827  *  \throw If no field values of the required parameters are available.
9828  */
9829 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9830 {
9831   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9832   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9833   if(!myF1TSC)
9834     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9835   MCAuto<DataArray> arr;
9836   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9837   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9838   return ret2.retn();
9839 }
9840
9841 /*!
9842  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9843  * the top level cells of the first mesh in MED file.
9844  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9845  *  \param [in] type - a spatial discretization of interest.
9846  *  \param [in] iteration - the iteration number of a required time step.
9847  *  \param [in] order - the iteration order number of required time step.
9848  *  \param [in] renumPol - specifies how to permute values of the result field according to
9849  *          the optional numbers of cells and nodes, if any. The valid values are
9850  *          - 0 - do not permute.
9851  *          - 1 - permute cells.
9852  *          - 2 - permute nodes.
9853  *          - 3 - permute cells and nodes.
9854  *
9855  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9856  *          caller is to delete this field using decrRef() as it is no more needed. 
9857  *  \throw If the MED file is not readable.
9858  *  \throw If there is no mesh in the MED file.
9859  *  \throw If no field values of the required parameters are available.
9860  */
9861 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9862 {
9863   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9864   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9865   if(!myF1TSC)
9866     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9867   MCAuto<DataArray> arr;
9868   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9869   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9870   return ret2.retn();
9871 }
9872
9873 /*!
9874  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9875  * a given support.
9876  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9877  *  \param [in] type - a spatial discretization of interest.
9878  *  \param [in] iteration - the iteration number of a required time step.
9879  *  \param [in] order - the iteration order number of required time step.
9880  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9881  *  \param [in] mesh - the supporting mesh.
9882  *  \param [in] renumPol - specifies how to permute values of the result field according to
9883  *          the optional numbers of cells and nodes, if any. The valid values are
9884  *          - 0 - do not permute.
9885  *          - 1 - permute cells.
9886  *          - 2 - permute nodes.
9887  *          - 3 - permute cells and nodes.
9888  *
9889  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9890  *          caller is to delete this field using decrRef() as it is no more needed. 
9891  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9892  *  \throw If no field of \a this is lying on \a mesh.
9893  *  \throw If no field values of the required parameters are available.
9894  */
9895 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9896 {
9897   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9898   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9899   if(!myF1TSC)
9900     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9901   MCAuto<DataArray> arr;
9902   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9903   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9904   return ret2.retn();
9905 }
9906
9907 /*!
9908  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9909  * given support. 
9910  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9911  *  \param [in] type - a spatial discretization of the new field.
9912  *  \param [in] iteration - the iteration number of a required time step.
9913  *  \param [in] order - the iteration order number of required time step.
9914  *  \param [in] mesh - the supporting mesh.
9915  *  \param [out] arrOut - the DataArrayInt containing values of field.
9916  *  \param [in] renumPol - specifies how to permute values of the result field according to
9917  *          the optional numbers of cells and nodes, if any. The valid values are
9918  *          - 0 - do not permute.
9919  *          - 1 - permute cells.
9920  *          - 2 - permute nodes.
9921  *          - 3 - permute cells and nodes.
9922  *
9923  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9924  *          caller is to delete this field using decrRef() as it is no more needed. 
9925  *  \throw If no field of \a this is lying on \a mesh.
9926  *  \throw If no field values of the required parameters are available.
9927  */
9928 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9929 {
9930   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9931   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9932   if(!myF1TSC)
9933     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9934   MCAuto<DataArray> arr;
9935   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9936   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9937   return ret2.retn();
9938 }
9939
9940 /*!
9941  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9942  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9943  * This method is useful for MED2 file format when field on different mesh was autorized.
9944  */
9945 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9946 {
9947   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9948   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9949   if(!myF1TSC)
9950     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9951   MCAuto<DataArray> arr;
9952   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9953   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9954   return ret2.retn();
9955 }
9956
9957 /*!
9958  * Returns values and a profile of the field of a given type, of a given time step,
9959  * lying on a given support.
9960  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9961  *  \param [in] type - a spatial discretization of the field.
9962  *  \param [in] iteration - the iteration number of a required time step.
9963  *  \param [in] order - the iteration order number of required time step.
9964  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9965  *  \param [in] mesh - the supporting mesh.
9966  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9967  *          field of interest lies on. If the field lies on all entities of the given
9968  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9969  *          using decrRef() as it is no more needed.  
9970  *  \param [in] glob - the global data storing profiles and localization.
9971  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9972  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9973  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9974  *  \throw If no field of \a this is lying on \a mesh.
9975  *  \throw If no field values of the required parameters are available.
9976  */
9977 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9978 {
9979   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9980   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9981   if(!myF1TSC)
9982     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9983   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9984   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9985 }
9986
9987 /*!
9988  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9989  *  \param [in] pos - a time step id.
9990  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9991  *          delete this field using decrRef() as it is no more needed.
9992  *  \throw If \a pos is not a valid time step id.
9993  */
9994 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9995 {
9996   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9997   if(!item)
9998     {
9999       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10000       throw INTERP_KERNEL::Exception(oss.str());
10001     }
10002   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10003   if(itemC)
10004     {
10005       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10006       ret->shallowCpyGlobs(*this);
10007       return ret.retn();
10008     }
10009   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10010   throw INTERP_KERNEL::Exception(oss.str());
10011 }
10012
10013 /*!
10014  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10015  * the given field is checked if its elements are sorted suitable for writing to MED file
10016  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10017  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10018  *  \param [in] field - the field to add to \a this.
10019  *  \throw If the name of \a field is empty.
10020  *  \throw If the data array of \a field is not set.
10021  *  \throw If existing time steps have different name or number of components than \a field.
10022  *  \throw If the underlying mesh of \a field has no name.
10023  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10024  */
10025 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10026 {
10027   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10028   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10029 }
10030
10031 /*!
10032  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10033  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10034  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10035  * and \a profile.
10036  *
10037  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10038  * A new profile is added only if no equal profile is missing.
10039  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10040  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10041  *  \param [in] arrOfVals - the values of the field \a field used.
10042  *  \param [in] mesh - the supporting mesh of \a field.
10043  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10044  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10045  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10046  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10047  *  \throw If the data array of \a field is not set.
10048  *  \throw If the data array of \a this is already allocated but has different number of
10049  *         components than \a field.
10050  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10051  *  \sa setFieldNoProfileSBT()
10052  */
10053 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10054 {
10055   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10056   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10057 }
10058
10059 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10060 {
10061   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10062   if(!pt)
10063     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10064   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10065   if(!ret)
10066     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 !");
10067   return ret;
10068 }
10069
10070 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10071 {
10072   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10073   if(!pt)
10074     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10075   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10076   if(!ret)
10077     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 !");
10078   return ret;
10079 }
10080
10081 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10082 {
10083   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10084 }
10085
10086 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10087 {
10088 }
10089
10090 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10091 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10092 {
10093 }
10094 catch(INTERP_KERNEL::Exception& e)
10095 { throw e; }
10096
10097 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10098 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10099 {
10100 }
10101 catch(INTERP_KERNEL::Exception& e)
10102 { throw e; }
10103
10104 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10105 {
10106   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10107 }
10108
10109 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10110 {
10111   return MEDFileIntFieldMultiTS::New();
10112 }
10113
10114 //= MEDFileFields
10115
10116 MEDFileFields *MEDFileFields::New()
10117 {
10118   return new MEDFileFields;
10119 }
10120
10121 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10122 {
10123   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10124   return New(fid,loadAll);
10125 }
10126
10127 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10128 {
10129   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10130   if(!se)
10131     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10132   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10133   return new MEDFileFields(fid,loadAll,0,entities);
10134 }
10135
10136 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10137 {
10138   return new MEDFileFields(fid,loadAll,0,0);
10139 }
10140
10141 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10142 {
10143   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10144   return new MEDFileFields(fid,loadAll,ms,0);
10145 }
10146
10147 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10148 {
10149   MEDFileUtilities::CheckFileForRead(fileName);
10150   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10151   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10152   return new MEDFileFields(fid,loadAll,0,ent);
10153 }
10154
10155 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10156 {
10157   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10158   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10159   return ret;
10160 }
10161
10162 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10163 {
10164   std::vector<const BigMemoryObject *> ret;
10165   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10166     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10167   return ret;
10168 }
10169
10170 MEDFileFields *MEDFileFields::deepCopy() const
10171 {
10172   MCAuto<MEDFileFields> ret(shallowCpy());
10173   std::size_t i(0);
10174   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10175     {
10176       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10177         ret->_fields[i]=(*it)->deepCopy();
10178     }
10179   ret->deepCpyGlobs(*this);
10180   return ret.retn();
10181 }
10182
10183 MEDFileFields *MEDFileFields::shallowCpy() const
10184 {
10185   return new MEDFileFields(*this);
10186 }
10187
10188 /*!
10189  * 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
10190  * 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.
10191  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10192  *
10193  * \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.
10194  * \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.
10195  * 
10196  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10197  */
10198 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10199 {
10200   std::set< std::pair<int,int> > s;
10201   bool firstShot=true;
10202   areThereSomeForgottenTS=false;
10203   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10204     {
10205       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10206         continue;
10207       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10208       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10209       if(firstShot)
10210         { s=s1; firstShot=false; }
10211       else
10212         {
10213           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10214           if(s!=s2)
10215             areThereSomeForgottenTS=true;
10216           s=s2;
10217         }
10218     }
10219   std::vector< std::pair<int,int> > ret;
10220   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10221   return ret;
10222 }
10223
10224 int MEDFileFields::getNumberOfFields() const
10225 {
10226   return _fields.size();
10227 }
10228
10229 std::vector<std::string> MEDFileFields::getFieldsNames() const
10230 {
10231   std::vector<std::string> ret(_fields.size());
10232   int i(0);
10233   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10234     {
10235       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10236       if(f)
10237         {
10238           ret[i]=f->getName();
10239         }
10240       else
10241         {
10242           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10243           throw INTERP_KERNEL::Exception(oss.str());
10244         }
10245     }
10246   return ret;
10247 }
10248
10249 std::vector<std::string> MEDFileFields::getMeshesNames() const
10250 {
10251   std::vector<std::string> ret;
10252   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10253     {
10254       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10255       if(cur)
10256         ret.push_back(cur->getMeshName());
10257     }
10258   return ret;
10259 }
10260
10261 std::string MEDFileFields::simpleRepr() const
10262 {
10263   std::ostringstream oss;
10264   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10265   simpleRepr(0,oss);
10266   return oss.str();
10267 }
10268
10269 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10270 {
10271   int nbOfFields(getNumberOfFields());
10272   std::string startLine(bkOffset,' ');
10273   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10274   int i=0;
10275   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10276     {
10277       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10278       if(cur)
10279         {
10280           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10281         }
10282       else
10283         {
10284           oss << startLine << "  - not defined !" << std::endl;
10285         }
10286     }
10287   i=0;
10288   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10289     {
10290       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10291       std::string chapter(17,'0'+i);
10292       oss << startLine << chapter << std::endl;
10293       if(cur)
10294         {
10295           cur->simpleRepr(bkOffset+2,oss,i);
10296         }
10297       else
10298         {
10299           oss << startLine << "  - not defined !" << std::endl;
10300         }
10301       oss << startLine << chapter << std::endl;
10302     }
10303   simpleReprGlobs(oss);
10304 }
10305
10306 MEDFileFields::MEDFileFields()
10307 {
10308 }
10309
10310 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10311 try:MEDFileFieldGlobsReal(fid)
10312 {
10313   int nbFields(MEDnField(fid));
10314   _fields.resize(nbFields);
10315   med_field_type typcha;
10316   for(int i=0;i<nbFields;i++)
10317     {
10318       std::vector<std::string> infos;
10319       std::string fieldName,dtunit;
10320       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10321       switch(typcha)
10322       {
10323         case MED_FLOAT64:
10324           {
10325             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10326             break;
10327           }
10328         case MED_INT32:
10329           {
10330             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10331             break;
10332           }
10333         default:
10334           {
10335             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] !";
10336             throw INTERP_KERNEL::Exception(oss.str());
10337           }
10338       }
10339     }
10340   loadAllGlobals(fid);
10341 }
10342 catch(INTERP_KERNEL::Exception& e)
10343 {
10344     throw e;
10345 }
10346
10347 void MEDFileFields::writeLL(med_idt fid) const
10348 {
10349   int i=0;
10350   writeGlobals(fid,*this);
10351   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10352     {
10353       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10354       if(!elt)
10355         {
10356           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10357           throw INTERP_KERNEL::Exception(oss.str());
10358         }
10359       elt->writeLL(fid,*this);
10360     }
10361 }
10362
10363 /*!
10364  * This method alloc the arrays and load potentially huge arrays contained in this field.
10365  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10366  * This method can be also called to refresh or reinit values from a file.
10367  * 
10368  * \throw If the fileName is not set or points to a non readable MED file.
10369  */
10370 void MEDFileFields::loadArrays()
10371 {
10372   if(getFileName().empty())
10373     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10374   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10375   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10376     {
10377       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10378       if(elt)
10379         elt->loadBigArraysRecursively(fid,*elt);
10380     }
10381 }
10382
10383 /*!
10384  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10385  * But once data loaded once, this method does nothing.
10386  * 
10387  * \throw If the fileName is not set or points to a non readable MED file.
10388  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10389  */
10390 void MEDFileFields::loadArraysIfNecessary()
10391 {
10392   if(!getFileName().empty())
10393     {
10394       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10395       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10396         {
10397           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10398           if(elt)
10399             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10400         }
10401     }
10402 }
10403
10404 /*!
10405  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10406  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10407  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10408  * 
10409  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10410  */
10411 void MEDFileFields::unloadArrays()
10412 {
10413   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10414     {
10415       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10416       if(elt)
10417         elt->unloadArrays();
10418     }
10419 }
10420
10421 /*!
10422  * 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.
10423  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10424  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10425  * 
10426  * \sa MEDFileFields::loadArraysIfNecessary
10427  */
10428 void MEDFileFields::unloadArraysWithoutDataLoss()
10429 {
10430   if(!getFileName().empty())
10431     unloadArrays();
10432 }
10433
10434 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10435 {
10436   std::vector<std::string> ret;
10437   std::set<std::string> ret2;
10438   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10439     {
10440       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10441       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10442         if(ret2.find(*it2)==ret2.end())
10443           {
10444             ret.push_back(*it2);
10445             ret2.insert(*it2);
10446           }
10447     }
10448   return ret;
10449 }
10450
10451 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10452 {
10453   std::vector<std::string> ret;
10454   std::set<std::string> ret2;
10455   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10456     {
10457       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10458       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10459         if(ret2.find(*it2)==ret2.end())
10460           {
10461             ret.push_back(*it2);
10462             ret2.insert(*it2);
10463           }
10464     }
10465   return ret;
10466 }
10467
10468 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10469 {
10470   std::vector<std::string> ret;
10471   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10472     {
10473       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10474       ret.insert(ret.end(),tmp.begin(),tmp.end());
10475     }
10476   return ret;
10477 }
10478
10479 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10480 {
10481   std::vector<std::string> ret;
10482   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10483     {
10484       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10485       ret.insert(ret.end(),tmp.begin(),tmp.end());
10486     }
10487   return ret;
10488 }
10489
10490 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10491 {
10492   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10493     (*it)->changePflsRefsNamesGen2(mapOfModif);
10494 }
10495
10496 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10497 {
10498   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10499     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10500 }
10501
10502 void MEDFileFields::resize(int newSize)
10503 {
10504   _fields.resize(newSize);
10505 }
10506
10507 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10508 {
10509   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10510     pushField(*it);
10511 }
10512
10513 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10514 {
10515   if(!field)
10516     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10517   _fields.push_back(field->getContent());
10518   appendGlobs(*field,1e-12);
10519 }
10520
10521 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10522 {
10523   if(!field)
10524     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10525   if(i>=(int)_fields.size())
10526     _fields.resize(i+1);
10527   _fields[i]=field->getContent();
10528   appendGlobs(*field,1e-12);
10529 }
10530
10531 void MEDFileFields::destroyFieldAtPos(int i)
10532 {
10533   destroyFieldsAtPos(&i,&i+1);
10534 }
10535
10536 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10537 {
10538   std::vector<bool> b(_fields.size(),true);
10539   for(const int *i=startIds;i!=endIds;i++)
10540     {
10541       if(*i<0 || *i>=(int)_fields.size())
10542         {
10543           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10544           throw INTERP_KERNEL::Exception(oss.str());
10545         }
10546       b[*i]=false;
10547     }
10548   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10549   std::size_t j=0;
10550   for(std::size_t i=0;i<_fields.size();i++)
10551     if(b[i])
10552       fields[j++]=_fields[i];
10553   _fields=fields;
10554 }
10555
10556 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10557 {
10558   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10559   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10560   std::vector<bool> b(_fields.size(),true);
10561   int k=bg;
10562   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10563     {
10564       if(k<0 || k>=(int)_fields.size())
10565         {
10566           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10567           throw INTERP_KERNEL::Exception(oss.str());
10568         }
10569       b[k]=false;
10570     }
10571   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10572   std::size_t j(0);
10573   for(std::size_t i=0;i<_fields.size();i++)
10574     if(b[i])
10575       fields[j++]=_fields[i];
10576   _fields=fields;
10577 }
10578
10579 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10580 {
10581   bool ret(false);
10582   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10583     {
10584       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10585       if(cur)
10586         ret=cur->changeMeshNames(modifTab) || ret;
10587     }
10588   return ret;
10589 }
10590
10591 /*!
10592  * \param [in] meshName the name of the mesh that will be renumbered.
10593  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10594  *             This code corresponds to the distribution of types in the corresponding mesh.
10595  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10596  * \param [in] renumO2N the old to new renumber array.
10597  * \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 
10598  *         field in \a this.
10599  */
10600 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10601 {
10602   bool ret(false);
10603   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10604     {
10605       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10606       if(fmts)
10607         {
10608           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10609         }
10610     }
10611   return ret;
10612 }
10613
10614 /*!
10615  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10616  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10617  *
10618  * \return A new object that the caller is responsible to deallocate.
10619  */
10620 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10621 {
10622   if(!mm)
10623     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10624   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10625   int nbFields(getNumberOfFields());
10626   for(int i=0;i<nbFields;i++)
10627     {
10628       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10629       if(!fmts)
10630         {
10631           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10632           throw INTERP_KERNEL::Exception(oss.str());
10633         }
10634       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10635       fsOut->pushField(fmtsOut);
10636     }
10637   return fsOut.retn();
10638 }
10639
10640 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10641 {
10642   if(i<0 || i>=(int)_fields.size())
10643     {
10644       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10645       throw INTERP_KERNEL::Exception(oss.str());
10646     }
10647   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10648   if(!fmts)
10649     return 0;
10650   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10651   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10652   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10653   if(fmtsC)
10654     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10655   else if(fmtsC2)
10656     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10657   else
10658     {
10659       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10660       throw INTERP_KERNEL::Exception(oss.str());
10661     }
10662   ret->shallowCpyGlobs(*this);
10663   return ret.retn();
10664 }
10665
10666 /*!
10667  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10668  * This method is accessible in python using __getitem__ with a list in input.
10669  * \return a new object that the caller should deal with.
10670  */
10671 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10672 {
10673   MCAuto<MEDFileFields> ret=shallowCpy();
10674   std::size_t sz=std::distance(startIds,endIds);
10675   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10676   int j=0;
10677   for(const int *i=startIds;i!=endIds;i++,j++)
10678     {
10679       if(*i<0 || *i>=(int)_fields.size())
10680         {
10681           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10682           throw INTERP_KERNEL::Exception(oss.str());
10683         }
10684       fields[j]=_fields[*i];
10685     }
10686   ret->_fields=fields;
10687   return ret.retn();
10688 }
10689
10690 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10691 {
10692   return getFieldAtPos(getPosFromFieldName(fieldName));
10693 }
10694
10695 /*!
10696  * This method removes, if any, fields in \a this having no time steps.
10697  * 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.
10698  * 
10699  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10700  */
10701 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10702 {
10703   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10704   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10705     {
10706       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10707       if(elt)
10708         {
10709           if(elt->getNumberOfTS()>0)
10710             newFields.push_back(*it);
10711         }
10712     }
10713   if(_fields.size()==newFields.size())
10714     return false;
10715   _fields=newFields;
10716   return true;
10717 }
10718
10719 /*!
10720  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10721  * This method can be seen as a filter applied on \a this, that returns an object containing
10722  * 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
10723  * shallow copied from \a this.
10724  * 
10725  * \param [in] meshName - the name of the mesh on w
10726  * \return a new object that the caller should deal with.
10727  */
10728 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10729 {
10730   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10731   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10732     {
10733       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10734       if(!cur)
10735         continue;
10736       if(cur->getMeshName()==meshName)
10737         {
10738           cur->incrRef();
10739           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10740           ret->_fields.push_back(cur2);
10741         }
10742     }
10743   ret->shallowCpyOnlyUsedGlobs(*this);
10744   return ret.retn();
10745 }
10746
10747 /*!
10748  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10749  * Input time steps are specified using a pair of integer (iteration, order).
10750  * 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,
10751  * but for each multitimestep only the time steps in \a timeSteps are kept.
10752  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10753  * 
10754  * The returned object points to shallow copy of elements in \a this.
10755  * 
10756  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10757  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10758  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10759  */
10760 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10761 {
10762   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10763   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10764     {
10765       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10766       if(!cur)
10767         continue;
10768       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10769       ret->_fields.push_back(elt);
10770     }
10771   ret->shallowCpyOnlyUsedGlobs(*this);
10772   return ret.retn();
10773 }
10774
10775 /*!
10776  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10777  */
10778 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10779 {
10780   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10781   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10782     {
10783       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10784       if(!cur)
10785         continue;
10786       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10787       if(elt->getNumberOfTS()!=0)
10788         ret->_fields.push_back(elt);
10789     }
10790   ret->shallowCpyOnlyUsedGlobs(*this);
10791   return ret.retn();
10792 }
10793
10794 MEDFileFieldsIterator *MEDFileFields::iterator()
10795 {
10796   return new MEDFileFieldsIterator(this);
10797 }
10798
10799 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10800 {
10801   std::string tmp(fieldName);
10802   std::vector<std::string> poss;
10803   for(std::size_t i=0;i<_fields.size();i++)
10804     {
10805       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10806       if(f)
10807         {
10808           std::string fname(f->getName());
10809           if(tmp==fname)
10810             return i;
10811           else
10812             poss.push_back(fname);
10813         }
10814     }
10815   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10816   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10817   oss << " !";
10818   throw INTERP_KERNEL::Exception(oss.str());
10819 }
10820
10821 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10822 {
10823   if(fs)
10824     {
10825       fs->incrRef();
10826       _nb_iter=fs->getNumberOfFields();
10827     }
10828 }
10829
10830 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10831 {
10832 }
10833
10834 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10835 {
10836   if(_iter_id<_nb_iter)
10837     {
10838       MEDFileFields *fs(_fs);
10839       if(fs)
10840         return fs->getFieldAtPos(_iter_id++);
10841       else
10842         return 0;
10843     }
10844   else
10845     return 0;
10846 }