]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Merge 'agy/br810_1' branch.
[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.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.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 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
46 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
47
48 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
49 {
50   return new MEDFileFieldLoc(fid,locName);
51 }
52
53 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
54 {
55   return new MEDFileFieldLoc(fid,id);
56 }
57
58 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)
59 {
60   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 }
62
63 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
64 {
65   med_geometry_type geotype;
66   med_geometry_type sectiongeotype;
67   int nsectionmeshcell;
68   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
70   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
71   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
72   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
73   _nb_node_per_cell=cm.getNumberOfNodes();
74   _ref_coo.resize(_dim*_nb_node_per_cell);
75   _gs_coo.resize(_dim*_nb_gauss_pt);
76   _w.resize(_nb_gauss_pt);
77   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 }
79
80 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
81 {
82   med_geometry_type geotype;
83   med_geometry_type sectiongeotype;
84   int nsectionmeshcell;
85   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
88   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
89   _name=locName;
90   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
91   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
92   _nb_node_per_cell=cm.getNumberOfNodes();
93   _ref_coo.resize(_dim*_nb_node_per_cell);
94   _gs_coo.resize(_dim*_nb_gauss_pt);
95   _w.resize(_nb_gauss_pt);
96   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 }
98
99 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
100                                  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),
101                                      _w(w)
102 {
103   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
104   _dim=cm.getDimension();
105   _nb_node_per_cell=cm.getNumberOfNodes();
106   _nb_gauss_pt=_w.size();
107 }
108
109 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
110 {
111   return new MEDFileFieldLoc(*this);
112 }
113
114 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
115 {
116   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 }
118
119 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
120 {
121   return std::vector<const BigMemoryObject *>();
122 }
123
124 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
125 {
126   static const char OFF7[]="\n    ";
127   oss << "\"" << _name << "\"" << OFF7;
128   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
129   oss << "Dimension=" << _dim << OFF7;
130   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
131   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
132   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
134   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 }
136
137 void MEDFileFieldLoc::setName(const std::string& name)
138 {
139   _name=name;
140 }
141
142 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
143 {
144   if(_name!=other._name)
145     return false;
146   if(_dim!=other._dim)
147     return false;
148   if(_nb_gauss_pt!=other._nb_gauss_pt)
149     return false;
150   if(_nb_node_per_cell!=other._nb_node_per_cell)
151     return false;
152   if(_geo_type!=other._geo_type)
153     return false;
154   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
155     return false;
156   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
157     return false;
158   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
159     return false;
160
161   return true;
162 }
163
164 void MEDFileFieldLoc::writeLL(med_idt fid) const
165 {
166   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);
167 }
168
169 std::string MEDFileFieldLoc::repr() const
170 {
171   std::ostringstream oss; oss.precision(15);
172   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
173   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
174   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
175   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
176   oss << "\n  - Ref coords are : ";
177   int sz=_ref_coo.size();
178   if(sz%_dim==0)
179     {
180       int nbOfTuples=sz/_dim;
181       for(int i=0;i<nbOfTuples;i++)
182         {
183           oss << "(";
184           for(int j=0;j<_dim;j++)
185             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
186           oss << ") ";
187         }
188     }
189   else
190     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
191   oss << "\n  - Gauss coords in reference element : ";
192   sz=_gs_coo.size();
193   if(sz%_dim==0)
194     {
195       int nbOfTuples=sz/_dim;
196       for(int i=0;i<nbOfTuples;i++)
197         {
198           oss << "(";
199           for(int j=0;j<_dim;j++)
200             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
201           oss << ") ";
202         }
203     }
204   else
205     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
206   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
207   return oss.str();
208 }
209
210 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
211 {
212   _type=field->getTypeOfField();
213   _start=start;
214   switch(_type)
215   {
216     case ON_CELLS:
217       {
218         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
219         _end=_start+nbOfCells;
220         _nval=nbOfCells;
221         break;
222       }
223     case ON_GAUSS_NE:
224       {
225         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
226         const int *arrPtr=arr->getConstPointer();
227         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
228         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
229         _nval=nbOfCells;
230         break;
231       }
232     case ON_GAUSS_PT:
233       {
234         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
235         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
236         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
237         if(!disc2)
238           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
239         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
240         MCAuto<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
241         const int *dai2Ptr=dai2->getConstPointer();
242         int nbi=gsLoc.getWeights().size();
243         MCAuto<DataArrayInt> da2=dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
244         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
245         const int *da3Ptr=da3->getConstPointer();
246         if(da3->getNumberOfTuples()!=nbOfCells)
247           {//profile : for gauss even in NoProfile !!!
248             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
249             _profile=oss.str();
250             da3->setName(_profile.c_str());
251             glob.appendProfile(da3);
252           }
253         MCAuto<DataArrayInt> da4=DataArrayInt::New();
254         _nval=da3->getNbOfElems();
255         da4->alloc(_nval*nbi,1);
256         int *da4Ptr=da4->getPointer();
257         for(int i=0;i<_nval;i++)
258           {
259             int ref=dai2Ptr[offset+da3Ptr[i]];
260             for(int j=0;j<nbi;j++)
261               *da4Ptr++=ref+j;
262           }
263         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
264         _localization=oss2.str();
265         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
266         _end=_start+_nval*nbi;
267         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
268         break;
269       }
270     default:
271       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
272   }
273   start=_end;
274 }
275
276 /*!
277  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
278  * \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).
279  * \param [in] multiTypePfl is the end user profile specified in high level API
280  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
281  * \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.
282  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
283  * \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.
284  */
285 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)
286 {
287   _profile.clear();
288   _type=field->getTypeOfField();
289   std::string pflName(multiTypePfl->getName());
290   std::ostringstream oss; oss << pflName;
291   if(_type!=ON_NODES)
292     {
293       if(!isPflAlone)
294         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
295     }
296   else
297     { oss << "_NODE"; }
298   if(locIds)
299     {
300       if(pflName.empty())
301         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
302       if(_type!=ON_GAUSS_PT)
303         {
304           locIds->setName(oss.str());
305           glob.appendProfile(locIds);
306           _profile=oss.str();
307         }
308     }
309   _start=start;
310   switch(_type)
311   {
312     case ON_NODES:
313       {
314         _nval=idsInPfl->getNumberOfTuples();
315         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
316         _end=_start+_nval;
317         break;
318       }
319     case ON_CELLS:
320       {
321         _nval=idsInPfl->getNumberOfTuples();
322         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
323         _end=_start+_nval;
324         break;
325       }
326     case ON_GAUSS_NE:
327       {
328         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
329         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
330         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
331         arr3->computeOffsetsFull();
332         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
333         int trueNval=tmp->getNumberOfTuples();
334         _nval=idsInPfl->getNumberOfTuples();
335         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
336         _end=_start+trueNval;
337         break;
338       }
339     case ON_GAUSS_PT:
340       {
341         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
342         if(!disc2)
343           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
344         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
345         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
346         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
347         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
348         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
349         //
350         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
351         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
352         //
353         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
354         int trueNval=0;
355         for(const int *pt=da4->begin();pt!=da4->end();pt++)
356           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
357         tmp->alloc(trueNval,1);
358         int *tmpPtr=tmp->getPointer();
359         for(const int *pt=da4->begin();pt!=da4->end();pt++)
360           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
361             *tmpPtr++=j;
362         //
363         _nval=da4->getNumberOfTuples();
364         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
365         _end=_start+trueNval;
366         oss << "_loc_" << _loc_id;
367         if(locIds)
368           {
369             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
370             da5->setName(oss.str());
371             glob.appendProfile(da5);
372             _profile=oss.str();
373           }
374         else
375           {
376             if(!da3->isIota(nbOfEltsInWholeMesh))
377               {
378                 da3->setName(oss.str());
379                 glob.appendProfile(da3);
380                 _profile=oss.str();
381               }
382           }
383         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
384         _localization=oss2.str();
385         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
386         break;
387       }
388     default:
389       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
390   }
391   start=_end;
392 }
393
394 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
395 {
396   _start=start;
397   _nval=arrr->getNumberOfTuples();
398   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
399   _end=_start+_nval;
400   start=_end;
401 }
402
403 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
404 {
405   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
406 }
407
408 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
409 {
410   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
411 }
412
413 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
414 {
415   return new MEDFileFieldPerMeshPerTypePerDisc(other);
416 }
417
418 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
419 {
420   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
421 }
422
423 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
424 {
425   std::vector<const BigMemoryObject *> ret(1);
426   ret[0]=(const PartDefinition*)_pd;
427   return ret;
428 }
429
430 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
431 {
432   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
433   ret->_father=father;
434   return ret.retn();
435 }
436
437 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
438 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
439 {
440   if(pd)
441     pd->incrRef();
442 }
443 catch(INTERP_KERNEL::Exception& e)
444 {
445     throw e;
446 }
447
448 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
449 {
450 }
451
452 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)
453 {
454 }
455
456 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
457     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
458 {
459 }
460
461 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)
462 {
463   const PartDefinition *pd(_pd);
464   if(!pd)
465     {
466       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
467       int nbi,tmp1;
468       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
469       if(_end-_start!=nbValsInFile*nbi)
470         {
471           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 !";
472           throw INTERP_KERNEL::Exception(oss.str());
473         }
474       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
475     }
476   else
477     {
478       if(!_profile.empty())
479         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
480       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
481       int profilesize,nbi;
482       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
483       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
484       if(spd)
485         {
486           int start,stop,step;
487           spd->getSlice(start,stop,step);
488           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
489           med_filter filter=MED_FILTER_INIT;
490           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
491                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
492                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
493                                    /*lastblocksize=useless because count=1*/0,&filter);
494           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
495           MEDfilterClose(&filter);
496           return ;
497         }
498       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
499       if(dpd)
500         {
501           dpd->checkConsistencyLight();
502           MCAuto<DataArrayInt> myIds(dpd->toDAI());
503           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
504           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
505           myIds->applyLin(1,-a);
506           int nbOfEltsToLoad(b-a+1);
507           med_filter filter=MED_FILTER_INIT;
508           {//TODO : manage int32 !
509             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
510             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
511             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
512                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
513                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
514                                      /*lastblocksize=useless because count=1*/0,&filter);
515             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
516             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
517             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
518             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
519           }
520           MEDfilterClose(&filter);
521         }
522       else
523         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
524     }
525 }
526
527 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
528 {
529   return _father;
530 }
531
532 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
533 {
534   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
535   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
536   std::string fieldName(nasc.getName()),meshName(getMeshName());
537   int iteration(getIteration()),order(getOrder());
538   TypeOfField type(getType());
539   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
540   int profilesize,nbi;
541   med_geometry_type mgeoti;
542   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
543   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
544   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
545   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
546   const PartDefinition *pd(_pd);
547   if(!pd)
548     {
549       _nval=zeNVal;
550     }
551   else
552     {
553       if(!_profile.empty())
554         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
555       _nval=pd->getNumberOfElems();
556     }
557   _start=start;
558   _end=start+_nval*nbi;
559   start=_end;
560   if(type==ON_CELLS && !_localization.empty())
561     {
562       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
563         setType(ON_GAUSS_PT);
564       else
565         {
566           setType(ON_GAUSS_NE);
567           _localization.clear();
568         }
569     }
570 }
571
572 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
573 {
574   std::string fieldName(nasc.getName()),meshName(getMeshName());
575   int iteration(getIteration()),order(getOrder());
576   TypeOfField type(getType());
577   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
578   med_geometry_type mgeoti;
579   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
580   if(_start>_end)
581     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
582   if(_start==_end)
583     return ;
584   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
585   if(_start<0 || _start>=arr->getNumberOfTuples())
586     {
587       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
588       throw INTERP_KERNEL::Exception(oss.str());
589     }
590   if(_end<0 || _end>arr->getNumberOfTuples())
591     {
592       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
593       throw INTERP_KERNEL::Exception(oss.str());
594     }
595   int nbOfCompo(arr->getNumberOfComponents());
596   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
597   if(arrD)
598     {
599       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
600       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
601       return ;
602     }
603   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
604   if(arrI)
605     {
606       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
607       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
608       return ;
609     }
610   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
611 }
612
613 /*!
614  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
615  */
616 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
617 {
618   int delta=_end-_start;
619   _start=newValueOfStart;
620   _end=_start+delta;
621 }
622
623 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
624 {
625   return _father->getIteration();
626 }
627
628 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
629 {
630   return _father->getOrder();
631 }
632
633 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
634 {
635   return _father->getTime();
636 }
637
638 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
639 {
640   return _father->getMeshName();
641 }
642
643 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
644 {
645   const char startLine[]="    ## ";
646   std::string startLine2(bkOffset,' ');
647   startLine2+=startLine;
648   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
649   oss << startLine2 << "Localization #" << id << "." << std::endl;
650   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
651   delete tmp;
652   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
653   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
654   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
655 }
656
657 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
658 {
659   return _type;
660 }
661
662 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
663 {
664   types.insert(_type);
665 }
666
667 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
668 {
669   _type=newType;
670 }
671
672 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
673 {
674   return _father->getGeoType();
675 }
676
677 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
678 {
679   return _father->getNumberOfComponents();
680 }
681
682 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
683 {
684   return _end-_start;
685 }
686
687 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
688 {
689   return _father->getOrCreateAndGetArray();
690 }
691
692 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
693 {
694   const MEDFileFieldPerMeshPerType *fath=_father;
695   return fath->getOrCreateAndGetArray();
696 }
697
698 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
699 {
700   return _father->getInfo();
701 }
702
703 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
704 {
705   return _profile;
706 }
707
708 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
709 {
710   _profile=newPflName;
711 }
712
713 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
714 {
715   return _localization;
716 }
717
718 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
719 {
720   _localization=newLocName;
721 }
722
723 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
724 {
725   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
726     {
727       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
728         {
729           _profile=(*it2).second;
730           return;
731         }
732     }
733 }
734
735 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
736 {
737   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
738     {
739       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
740         {
741           _localization=(*it2).second;
742           return;
743         }
744     }
745 }
746
747 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
748 {
749   if(type!=_type)
750     return ;
751   dads.push_back(std::pair<int,int>(_start,_end));
752   geoTypes.push_back(getGeoType());
753   if(_profile.empty())
754     pfls.push_back(0);
755   else
756     {
757       pfls.push_back(glob->getProfile(_profile.c_str()));
758     }
759   if(_localization.empty())
760     locs.push_back(-1);
761   else
762     {
763       locs.push_back(glob->getLocalizationId(_localization.c_str()));
764     }
765 }
766
767 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
768 {
769   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));
770   startEntryId++;
771 }
772
773 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
774 {
775   TypeOfField type=getType();
776   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
777   med_geometry_type mgeoti;
778   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
779   const DataArray *arr=getOrCreateAndGetArray();
780   if(!arr)
781     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
782   if(!arr->isAllocated())
783     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
784   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
785   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
786   const unsigned char *locToWrite=0;
787   if(arrD)
788     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
789   else if(arrI)
790     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
791   else
792     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
793   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
794                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
795                                                    locToWrite));
796 }
797
798 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
799 {
800   type=_type;
801   pfl=_profile;
802   loc=_localization;
803   dad.first=_start; dad.second=_end;
804 }
805
806 /*!
807  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
808  *             This code corresponds to the distribution of types in the corresponding mesh.
809  * \param [out] ptToFill memory zone where the output will be stored.
810  * \return the size of data pushed into output param \a ptToFill
811  */
812 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
813 {
814   _loc_id=offset;
815   std::ostringstream oss;
816   std::size_t nbOfType=codeOfMesh.size()/3;
817   int found=-1;
818   for(std::size_t i=0;i<nbOfType && found==-1;i++)
819     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
820       found=(int)i;
821   if(found==-1)
822     {
823       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
824       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
825       throw INTERP_KERNEL::Exception(oss.str());
826     }
827   int *work=ptToFill;
828   if(_profile.empty())
829     {
830       if(_nval!=codeOfMesh[3*found+1])
831         {
832           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
833           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
834           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
835           throw INTERP_KERNEL::Exception(oss.str());
836         }
837       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
838         *work++=ii;
839     }
840   else
841     {
842       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
843       if(pfl->getNumberOfTuples()!=_nval)
844         {
845           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
846           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
847           oss << _nval;
848           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
849           throw INTERP_KERNEL::Exception(oss.str());
850         }
851       int offset2=codeOfMesh[3*found+2];
852       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
853         {
854           if(*pflId<codeOfMesh[3*found+1])
855             *work++=offset2+*pflId;
856         }
857     }
858   return _nval;
859 }
860
861 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
862 {
863   for(int i=_start;i<_end;i++)
864     *ptToFill++=i;
865   return _end-_start;
866 }
867
868 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
869 {
870   switch(type)
871   {
872     case ON_CELLS:
873       return -2;
874     case ON_GAUSS_NE:
875       return -1;
876     case ON_GAUSS_PT:
877       return locId;
878     default:
879       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
880   }
881 }
882
883 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
884 {
885   int id=0;
886   std::map<std::pair<std::string,TypeOfField>,int> m;
887   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
888   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
890       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
891   ret.resize(id);
892   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
893     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
894   return ret;
895 }
896
897 /*!
898  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
899  * 
900  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
901  * \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.
902  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
903  * \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)
904  * \param [in,out] glob if necessary by the method, new profiles can be added to it
905  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
906  * \param [out] result All new entries will be appended on it.
907  * \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 !)
908  */
909 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
910                                                        const DataArrayInt *explicitIdsInMesh,
911                                                        const std::vector<int>& newCode,
912                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
913                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
914 {
915   if(entriesOnSameDisc.empty())
916     return false;
917   TypeOfField type=entriesOnSameDisc[0]->getType();
918   int szEntities=0,szTuples=0;
919   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
920     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
921   int nbi=szTuples/szEntities;
922   if(szTuples%szEntities!=0)
923     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
924   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
925   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
926   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
927   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
928   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
929   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
930   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
931   int id=0;
932   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
933     {
934       int startOfEltIdOfChunk=(*it)->_start;
935       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
936       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
937       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
938       //
939       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
940       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
941       //
942       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
943       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
944     }
945   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
946   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
947   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
948   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
949   //
950   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
951   //
952   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
953   arrPart->renumberInPlace(renumTupleIds->begin());
954   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
955   bool ret=false;
956   const int *idIt=diffVals->begin();
957   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
958   int offset2=0;
959   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
960     {
961       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
962       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
963       int nbEntityElts=subIds->getNumberOfTuples();
964       bool ret2;
965       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
966           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
967                                       offset+offset2,
968                                       li,glob,ret2);
969       ret=ret || ret2;
970       result.push_back(eltToAdd);
971       offset2+=nbEntityElts*nbi;
972     }
973   ret=ret || li.empty();
974   return ret;
975 }
976
977 /*!
978  * \param [in] typeF type of field of new chunk
979  * \param [in] geoType the geometric type of the chunk
980  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
981  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
982  * \param [in] nbi number of integration points
983  * \param [in] offset The offset in the **global array of data**.
984  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
985  *                 to the new chunk to create.
986  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
987  * \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
988  *              and corresponding entry erased from \a entriesOnSameDisc.
989  * \return a newly allocated chunk
990  */
991 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
992                                                                                                   bool isPfl, int nbi, int offset,
993                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
994                                                                                                   MEDFileFieldGlobsReal& glob,
995                                                                                                   bool &notInExisting)
996 {
997   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
998   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
999   for(;it!=entriesOnSameDisc.end();it++)
1000     {
1001       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1002         {
1003           if(!isPfl)
1004             {
1005               if((*it)->_profile.empty())
1006                 break;
1007               else
1008                 if(!(*it)->_profile.empty())
1009                   {
1010                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1011                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1012                       break;
1013                   }
1014             }
1015         }
1016     }
1017   if(it==entriesOnSameDisc.end())
1018     {
1019       notInExisting=true;
1020       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1021       ret->_type=typeF;
1022       ret->_loc_id=(int)geoType;
1023       ret->_nval=nbMeshEntities;
1024       ret->_start=offset;
1025       ret->_end=ret->_start+ret->_nval*nbi;
1026       if(isPfl)
1027         {
1028           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1029           glob.appendProfile(idsOfMeshElt);
1030           ret->_profile=idsOfMeshElt->getName();
1031         }
1032       //tony treatment of localization
1033       return ret;
1034     }
1035   else
1036     {
1037       notInExisting=false;
1038       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1039       ret->_loc_id=(int)geoType;
1040       ret->setNewStart(offset);
1041       entriesOnSameDisc.erase(it);
1042       return ret;
1043     }
1044
1045 }
1046
1047 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1048 {
1049   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1050 }
1051
1052 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1053 {
1054   return new MEDFileFieldPerMeshPerType(fath,geoType);
1055 }
1056
1057 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1058 {
1059   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1060 }
1061
1062 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1063 {
1064   std::vector<const BigMemoryObject *> ret;
1065   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1066     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1067   return ret;
1068 }
1069
1070 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1071 {
1072   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1073   ret->_father=father;
1074   std::size_t i=0;
1075   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1076     {
1077       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1078         ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1079     }
1080   return ret.retn();
1081 }
1082
1083 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1084 {
1085   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1088 }
1089
1090 /*!
1091  * This method is the most general one. No optimization is done here.
1092  * \param [in] multiTypePfl is the end user profile specified in high level API
1093  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1095  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1098  */
1099 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1100 {
1101   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1104 }
1105
1106 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1107 {
1108   _field_pm_pt_pd.resize(1);
1109   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1111 }
1112
1113 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1114 {
1115   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116   if(!arr || !arr->isAllocated())
1117     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1118   _field_pm_pt_pd.resize(1);
1119   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120   _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1121 }
1122
1123 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1124 {
1125   TypeOfField type=field->getTypeOfField();
1126   if(type!=ON_GAUSS_PT)
1127     {
1128       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129       int sz=_field_pm_pt_pd.size();
1130       bool found=false;
1131       for(int j=0;j<sz && !found;j++)
1132         {
1133           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1134             {
1135               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136               found=true;
1137             }
1138         }
1139       if(!found)
1140         {
1141           _field_pm_pt_pd.resize(sz+1);
1142           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1143         }
1144       std::vector<int> ret(1,(int)sz);
1145       return ret;
1146     }
1147   else
1148     {
1149       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150       int sz2=ret2.size();
1151       std::vector<int> ret3(sz2);
1152       int k=0;
1153       for(int i=0;i<sz2;i++)
1154         {
1155           int sz=_field_pm_pt_pd.size();
1156           int locIdToFind=ret2[i];
1157           bool found=false;
1158           for(int j=0;j<sz && !found;j++)
1159             {
1160               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1161                 {
1162                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1163                   ret3[k++]=j;
1164                   found=true;
1165                 }
1166             }
1167           if(!found)
1168             {
1169               _field_pm_pt_pd.resize(sz+1);
1170               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1171               ret3[k++]=sz;
1172             }
1173         }
1174       return ret3;
1175     }
1176 }
1177
1178 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1179 {
1180   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1182   if(!disc2)
1183     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1185   if(!da)
1186     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189   if(retTmp->presenceOfValue(-1))
1190     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191   std::vector<int> ret(retTmp->begin(),retTmp->end());
1192   return ret;
1193 }
1194
1195 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1196 {
1197   TypeOfField type=field->getTypeOfField();
1198   if(type!=ON_GAUSS_PT)
1199     {
1200       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201       int sz=_field_pm_pt_pd.size();
1202       bool found=false;
1203       for(int j=0;j<sz && !found;j++)
1204         {
1205           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1206             {
1207               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1208               found=true;
1209             }
1210         }
1211       if(!found)
1212         {
1213           _field_pm_pt_pd.resize(sz+1);
1214           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1215         }
1216       std::vector<int> ret(1,0);
1217       return ret;
1218     }
1219   else
1220     {
1221       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222       int sz2=ret2.size();
1223       std::vector<int> ret3(sz2);
1224       int k=0;
1225       for(int i=0;i<sz2;i++)
1226         {
1227           int sz=_field_pm_pt_pd.size();
1228           int locIdToFind=ret2[i];
1229           bool found=false;
1230           for(int j=0;j<sz && !found;j++)
1231             {
1232               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1233                 {
1234                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1235                   ret3[k++]=j;
1236                   found=true;
1237                 }
1238             }
1239           if(!found)
1240             {
1241               _field_pm_pt_pd.resize(sz+1);
1242               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1243               ret3[k++]=sz;
1244             }
1245         }
1246       return ret3;
1247     }
1248 }
1249
1250 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1251 {
1252   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1254   if(!disc2)
1255     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1257   if(!da)
1258     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261   if(retTmp->presenceOfValue(-1))
1262     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263   std::vector<int> ret(retTmp->begin(),retTmp->end());
1264   return ret;
1265 }
1266
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1268 {
1269   return _father;
1270 }
1271
1272 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1273 {
1274   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1275   int curDim((int)cm.getDimension());
1276   dim=std::max(dim,curDim);
1277 }
1278
1279 bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
1280 {
1281   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1282   int curDim((int)cm.getDimension());
1283   if(dim!=std::numeric_limits<int>::max())
1284     {
1285       if(dim!=curDim)
1286         return false;
1287     }
1288   else
1289     dim=curDim;
1290   return true;
1291 }
1292
1293 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1294 {
1295   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1296     {
1297       (*it)->fillTypesOfFieldAvailable(types);
1298     }
1299 }
1300
1301 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1302 {
1303   int sz=_field_pm_pt_pd.size();
1304   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1305   for(int i=0;i<sz;i++)
1306     {
1307       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1308     }
1309 }
1310
1311 int MEDFileFieldPerMeshPerType::getIteration() const
1312 {
1313   return _father->getIteration();
1314 }
1315
1316 int MEDFileFieldPerMeshPerType::getOrder() const
1317 {
1318   return _father->getOrder();
1319 }
1320
1321 double MEDFileFieldPerMeshPerType::getTime() const
1322 {
1323   return _father->getTime();
1324 }
1325
1326 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1327 {
1328   return _father->getMeshName();
1329 }
1330
1331 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1332 {
1333   const char startLine[]="  ## ";
1334   std::string startLine2(bkOffset,' ');
1335   std::string startLine3(startLine2);
1336   startLine3+=startLine;
1337   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1338     {
1339       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1340       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1341     }
1342   else
1343     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1344   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1345   int i=0;
1346   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1347     {
1348       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1349       if(cur)
1350         cur->simpleRepr(bkOffset,oss,i);
1351       else
1352         {
1353           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1354         }
1355     }
1356 }
1357
1358 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1359 {
1360   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1361     {
1362       globalSz+=(*it)->getNumberOfTuples();
1363     }
1364   nbOfEntries+=(int)_field_pm_pt_pd.size();
1365 }
1366
1367 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1368 {
1369   return _geo_type;
1370 }
1371
1372
1373 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1374 {
1375   return _father->getNumberOfComponents();
1376 }
1377
1378 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1379 {
1380   std::size_t nb(0);
1381   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1382     {
1383       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1384       if(fmtd)
1385         nb++;
1386     }
1387   return nb>1;
1388 }
1389
1390 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1391 {
1392   return _father->getOrCreateAndGetArray();
1393 }
1394
1395 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1396 {
1397   const MEDFileFieldPerMesh *fath=_father;
1398   return fath->getOrCreateAndGetArray();
1399 }
1400
1401 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1402 {
1403   return _father->getInfo();
1404 }
1405
1406 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1407 {
1408   std::vector<std::string> ret;
1409   std::set<std::string> ret2;
1410   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1411     {
1412       std::string tmp=(*it1)->getProfile();
1413       if(!tmp.empty())
1414         if(ret2.find(tmp)==ret2.end())
1415           {
1416             ret.push_back(tmp);
1417             ret2.insert(tmp);
1418           }
1419     }
1420   return ret;
1421 }
1422
1423 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1424 {
1425   std::vector<std::string> ret;
1426   std::set<std::string> ret2;
1427   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428     {
1429       std::string tmp=(*it1)->getLocalization();
1430       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1431         if(ret2.find(tmp)==ret2.end())
1432           {
1433             ret.push_back(tmp);
1434             ret2.insert(tmp);
1435           }
1436     }
1437   return ret;
1438 }
1439
1440 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1441 {
1442   std::vector<std::string> ret;
1443   std::set<std::string> ret2;
1444   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1445     {
1446       std::string tmp=(*it1)->getProfile();
1447       if(!tmp.empty())
1448         ret.push_back(tmp);
1449     }
1450   return ret;
1451 }
1452
1453 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1454 {
1455   std::vector<std::string> ret;
1456   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1457     {
1458       std::string tmp=(*it1)->getLocalization();
1459       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1460         ret.push_back(tmp);
1461     }
1462   return ret;
1463 }
1464
1465 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1466 {
1467   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1468     (*it1)->changePflsRefsNamesGen(mapOfModif);
1469 }
1470
1471 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1472 {
1473   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1474     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1475 }
1476
1477 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1478 {
1479   if(_field_pm_pt_pd.empty())
1480     {
1481       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1482       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1483       throw INTERP_KERNEL::Exception(oss.str());
1484     }
1485   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1486     return _field_pm_pt_pd[locId];
1487   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1488   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1489   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1490   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1491   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1492 }
1493
1494 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1495 {
1496   if(_field_pm_pt_pd.empty())
1497     {
1498       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1499       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1500       throw INTERP_KERNEL::Exception(oss.str());
1501     }
1502   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1503     return _field_pm_pt_pd[locId];
1504   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1505   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1506   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1507   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1508   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1509 }
1510
1511 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1512 {
1513   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1514     {
1515       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1516       if(meshDim!=(int)cm.getDimension())
1517         return ;
1518     }
1519   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1520     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1521 }
1522
1523 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1524 {
1525   int i=0;
1526   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1527     {
1528       (*it)->fillValues(i,startEntryId,entries);
1529     }
1530 }
1531
1532 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1533 {
1534   _field_pm_pt_pd=leaves;
1535   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536     (*it)->setFather(this);
1537 }
1538
1539 /*!
1540  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1541  *  \param [out] its - list of pair (start,stop) kept
1542  *  \return bool - false if the type of field \a tof is not contained in \a this.
1543  */
1544 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1545 {
1546   bool ret(false);
1547   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1548   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1549     if((*it)->getType()==tof)
1550       {
1551         newPmPtPd.push_back(*it);
1552         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1553         (*it)->setNewStart(globalNum);
1554         globalNum=(*it)->getEnd();
1555         its.push_back(bgEnd);
1556         ret=true;
1557       }
1558   if(ret)
1559     _field_pm_pt_pd=newPmPtPd;
1560   return ret;
1561 }
1562
1563 /*!
1564  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1565  *  \param [out] its - list of pair (start,stop) kept
1566  *  \return bool - false if the type of field \a tof is not contained in \a this.
1567  */
1568 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1569 {
1570   if(_field_pm_pt_pd.size()<=idOfDisc)
1571     return false;
1572   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1573   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1574   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1575   elt->setNewStart(globalNum);
1576   globalNum=elt->getEnd();
1577   its.push_back(bgEnd);
1578   _field_pm_pt_pd=newPmPtPd;
1579   return true;
1580 }
1581
1582 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1583 {
1584 }
1585
1586 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1587 {
1588   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1589   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1590   med_geometry_type mgeoti;
1591   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1592   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1593   _field_pm_pt_pd.resize(nbProfiles);
1594   for(int i=0;i<nbProfiles;i++)
1595     {
1596       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1597     }
1598   if(type==ON_CELLS)
1599     {
1600       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1601       for(int i=0;i<nbProfiles2;i++)
1602         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1603     }
1604 }
1605
1606 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1607 {
1608   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1610 }
1611
1612 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1613 {
1614   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1615     (*it)->loadBigArray(fid,nasc);
1616 }
1617
1618 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1619 {
1620   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1621     {
1622       (*it)->copyOptionsFrom(*this);
1623       (*it)->writeLL(fid,nasc);
1624     }
1625 }
1626
1627 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1628 {
1629   switch(ikType)
1630   {
1631     case ON_CELLS:
1632       medfGeoType=typmai3[(int)ikGeoType];
1633       return MED_CELL;
1634     case ON_NODES:
1635       medfGeoType=MED_NONE;
1636       return MED_NODE;
1637     case ON_GAUSS_NE:
1638       medfGeoType=typmai3[(int)ikGeoType];
1639       return MED_NODE_ELEMENT;
1640     case ON_GAUSS_PT:
1641       medfGeoType=typmai3[(int)ikGeoType];
1642       return MED_CELL;
1643     default:
1644       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1645   }
1646   return MED_UNDEF_ENTITY_TYPE;
1647 }
1648
1649 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1650 {
1651   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1652 }
1653
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1655 {
1656   return new MEDFileFieldPerMesh(fath,mesh);
1657 }
1658
1659 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1660 {
1661   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1662 }
1663
1664 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1665 {
1666   std::vector<const BigMemoryObject *> ret;
1667   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1668     ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1669   return ret;
1670 }
1671
1672 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1673 {
1674   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1675   ret->_father=father;
1676   std::size_t i=0;
1677   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1678     {
1679       if((const MEDFileFieldPerMeshPerType *)*it)
1680         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1681     }
1682   return ret.retn();
1683 }
1684
1685 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1686 {
1687   std::string startLine(bkOffset,' ');
1688   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1689   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1690   int i=0;
1691   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1692     {
1693       const MEDFileFieldPerMeshPerType *cur=*it;
1694       if(cur)
1695         cur->simpleRepr(bkOffset,oss,i);
1696       else
1697         {
1698           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1699         }
1700     }
1701 }
1702
1703 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1704 {
1705   _mesh_name=mesh->getName();
1706   mesh->getTime(_mesh_iteration,_mesh_order);
1707 }
1708
1709 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1710 {
1711   int nbOfTypes=code.size()/3;
1712   int offset=0;
1713   for(int i=0;i<nbOfTypes;i++)
1714     {
1715       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1716       int nbOfCells=code[3*i+1];
1717       int pos=addNewEntryIfNecessary(type);
1718       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1719       offset+=nbOfCells;
1720     }
1721 }
1722
1723 /*!
1724  * This method is the most general one. No optimization is done here.
1725  * \param [in] multiTypePfl is the end user profile specified in high level API
1726  * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1727  * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1728  * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1729  * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1730  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1731  */
1732 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1733 {
1734   int nbOfTypes(code.size()/3);
1735   for(int i=0;i<nbOfTypes;i++)
1736     {
1737       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1738       int pos=addNewEntryIfNecessary(type);
1739       DataArrayInt *pfl=0;
1740       if(code[3*i+2]!=-1)
1741         pfl=idsPerType[code[3*i+2]];
1742       int nbOfTupes2=code2.size()/3;
1743       int found=0;
1744       for(;found<nbOfTupes2;found++)
1745         if(code[3*i]==code2[3*found])
1746           break;
1747       if(found==nbOfTupes2)
1748         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1749       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1750     }
1751 }
1752
1753 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1754 {
1755   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1756   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1757 }
1758
1759 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1760 {
1761   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1762   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1763 }
1764
1765 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1766 {
1767   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1768     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1769 }
1770
1771 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1772 {
1773   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1774     (*it)->loadBigArraysRecursively(fid,nasc);
1775 }
1776
1777 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1778 {
1779   int nbOfTypes=_field_pm_pt.size();
1780   for(int i=0;i<nbOfTypes;i++)
1781     {
1782       _field_pm_pt[i]->copyOptionsFrom(*this);
1783       _field_pm_pt[i]->writeLL(fid,nasc);
1784     }
1785 }
1786
1787 void MEDFileFieldPerMesh::getDimension(int& dim) const
1788 {
1789   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1790     (*it)->getDimension(dim);
1791 }
1792
1793 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1794 {
1795   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1796     if(!(*it)->isUniqueLevel(dim))
1797       return false;
1798   return true;
1799 }
1800
1801 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1802 {
1803   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1804     (*it)->fillTypesOfFieldAvailable(types);
1805 }
1806
1807 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
1808 {
1809   int sz=_field_pm_pt.size();
1810   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1811   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1812   for(int i=0;i<sz;i++)
1813     {
1814       types[i]=_field_pm_pt[i]->getGeoType();
1815       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1816     }
1817   return ret;
1818 }
1819
1820 double MEDFileFieldPerMesh::getTime() const
1821 {
1822   int tmp1,tmp2;
1823   return _father->getTime(tmp1,tmp2);
1824 }
1825
1826 int MEDFileFieldPerMesh::getIteration() const
1827 {
1828   return _father->getIteration();
1829 }
1830
1831 int MEDFileFieldPerMesh::getOrder() const
1832 {
1833   return _father->getOrder();
1834 }
1835
1836 int MEDFileFieldPerMesh::getNumberOfComponents() const
1837 {
1838   return _father->getNumberOfComponents();
1839 }
1840
1841 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1842 {
1843   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844     {
1845       const MEDFileFieldPerMeshPerType *fpmt(*it);
1846       if(!fpmt)
1847         continue;
1848       if(fpmt->presenceOfMultiDiscPerGeoType())
1849         return true;
1850     }
1851   return false;
1852 }
1853
1854 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1855 {
1856   if(!_father)
1857     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1858   return _father->getOrCreateAndGetArray();
1859 }
1860
1861 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1862 {
1863   if(!_father)
1864     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1865   return _father->getOrCreateAndGetArray();
1866 }
1867
1868 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1869 {
1870   return _father->getInfo();
1871 }
1872
1873 /*!
1874  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1875  * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1876  * It returns 2 output vectors :
1877  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1878  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1879  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1880  */
1881 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1882 {
1883   int notNullPflsSz=0;
1884   int nbOfArrs=geoTypes.size();
1885   for(int i=0;i<nbOfArrs;i++)
1886     if(pfls[i])
1887       notNullPflsSz++;
1888   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1889   int nbOfDiffGeoTypes=geoTypes3.size();
1890   code.resize(3*nbOfDiffGeoTypes);
1891   notNullPfls.resize(notNullPflsSz);
1892   notNullPflsSz=0;
1893   int j=0;
1894   for(int i=0;i<nbOfDiffGeoTypes;i++)
1895     {
1896       int startZone=j;
1897       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1898       std::vector<const DataArrayInt *> notNullTmp;
1899       if(pfls[j])
1900         notNullTmp.push_back(pfls[j]);
1901       j++;
1902       for(;j<nbOfArrs;j++)
1903         if(geoTypes[j]==refType)
1904           {
1905             if(pfls[j])
1906               notNullTmp.push_back(pfls[j]);
1907           }
1908         else
1909           break;
1910       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1911       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1912       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1913       code[3*i]=(int)refType;
1914       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1915       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1916       if(notNullTmp.empty())
1917         code[3*i+2]=-1;
1918       else
1919         {
1920           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1921           code[3*i+2]=notNullPflsSz++;
1922         }
1923     }
1924 }
1925
1926 /*!
1927  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1928  */
1929 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs)
1930 {
1931   int sz=dads.size();
1932   int ret=0;
1933   for(int i=0;i<sz;i++)
1934     {
1935       if(locs[i]==-1)
1936         {
1937           if(type!=ON_GAUSS_NE)
1938             ret+=dads[i].second-dads[i].first;
1939           else
1940             {
1941               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1942               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1943             }
1944         }
1945       else
1946         {
1947           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1948           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1949         }
1950     }
1951   return ret;
1952 }
1953
1954 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1955 {
1956   std::vector<std::string> ret;
1957   std::set<std::string> ret2;
1958   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1959     {
1960       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1961       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1962         if(ret2.find(*it2)==ret2.end())
1963           {
1964             ret.push_back(*it2);
1965             ret2.insert(*it2);
1966           }
1967     }
1968   return ret;
1969 }
1970
1971 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1972 {
1973   std::vector<std::string> ret;
1974   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1975     {
1976       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1977       ret.insert(ret.end(),tmp.begin(),tmp.end());
1978     }
1979   return ret;
1980 }
1981
1982 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1983 {
1984   std::vector<std::string> ret;
1985   std::set<std::string> ret2;
1986   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1987     {
1988       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1989       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1990         if(ret2.find(*it2)==ret2.end())
1991           {
1992             ret.push_back(*it2);
1993             ret2.insert(*it2);
1994           }
1995     }
1996   return ret;
1997 }
1998
1999 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2000 {
2001   std::vector<std::string> ret;
2002   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2003     {
2004       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2005       ret.insert(ret.end(),tmp.begin(),tmp.end());
2006     }
2007   return ret;
2008 }
2009
2010 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2011 {
2012   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2013     {
2014       if((*it).first==_mesh_name)
2015         {
2016           _mesh_name=(*it).second;
2017           return true;
2018         }
2019     }
2020   return false;
2021 }
2022
2023 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2024                                                       MEDFileFieldGlobsReal& glob)
2025 {
2026   if(_mesh_name!=meshName)
2027     return false;
2028   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2029   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2030   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2031   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2032   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2033   getUndergroundDataArrayExt(entries);
2034   DataArray *arr0=getOrCreateAndGetArray();//tony
2035   if(!arr0)
2036     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2037   DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2038   if(!arr0)
2039     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2040   int sz=0;
2041   if(!arr)
2042     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2043   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2044     {
2045       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2046         {
2047           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2048           sz+=(*it).second.second-(*it).second.first;
2049         }
2050       else
2051         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2052     }
2053   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2054   ////////////////////
2055   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2056   int *workI2=explicitIdsOldInMesh->getPointer();
2057   int sz1=0,sz2=0,sid=1;
2058   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2059   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2060   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2061     {
2062       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2063       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2064       int *workI=explicitIdsOldInArr->getPointer();
2065       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2066         {
2067           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2068           (*itL2)->setLocId(sz2);
2069           (*itL2)->_tmp_work1=(*itL2)->getStart();
2070           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2071         }
2072       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2073     }
2074   explicitIdsOldInMesh->reAlloc(sz2);
2075   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2076   ////////////////////
2077   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2078   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2079   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2080   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2081     {
2082       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2083       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2084       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2085     }
2086   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2087   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2088   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2089     {
2090       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2091       int newStart=elt->getLocId();
2092       elt->setLocId((*it)->getGeoType());
2093       elt->setNewStart(newStart);
2094       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2095       entriesKeptNew.push_back(elt);
2096       entriesKeptNew2.push_back(elt);
2097     }
2098   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2099   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2100   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2101   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2102   bool ret=false;
2103   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2104     {
2105       sid=0;
2106       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2107         {
2108           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2109           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2110           }*/
2111       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2112                                                             glob,arr2,otherEntriesNew) || ret;
2113     }
2114   if(!ret)
2115     return false;
2116   // Assign new dispatching
2117   assignNewLeaves(otherEntriesNew);
2118   arr->deepCopyFrom(*arr2);
2119   return true;
2120 }
2121
2122 /*!
2123  * \param [in,out] globalNum a global numbering counter for the renumbering.
2124  * \param [out] its - list of pair (start,stop) kept
2125  */
2126 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2127 {
2128   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2129   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2130     {
2131       std::vector< std::pair<int,int> > its2;
2132       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2133         {
2134           ret.push_back(*it);
2135           its.insert(its.end(),its2.begin(),its2.end());
2136         }
2137     }
2138   _field_pm_pt=ret;
2139 }
2140
2141 /*!
2142  * \param [in,out] globalNum a global numbering counter for the renumbering.
2143  * \param [out] its - list of pair (start,stop) kept
2144  */
2145 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2146 {
2147   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2148   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2149     {
2150       std::vector< std::pair<int,int> > its2;
2151       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2152         {
2153           ret.push_back(*it);
2154           its.insert(its.end(),its2.begin(),its2.end());
2155         }
2156     }
2157   _field_pm_pt=ret;
2158 }
2159
2160 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2161 {
2162   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2163   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2164     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2165   //
2166   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2167   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2168   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2169   for(;it1!=types.end();it1++,it2++)
2170     {
2171       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2172       elt->setLeaves((*it1).second);
2173       *it2=elt;
2174     }
2175   _field_pm_pt=fieldPmPt;
2176 }
2177
2178 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2179 {
2180   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2181     (*it)->changePflsRefsNamesGen(mapOfModif);
2182 }
2183
2184 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2185 {
2186   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2187     (*it)->changeLocsRefsNamesGen(mapOfModif);
2188 }
2189
2190 /*!
2191  * \param [in] mesh is the whole mesh
2192  */
2193 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2194 {
2195   if(_field_pm_pt.empty())
2196     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2197   //
2198   std::vector< std::pair<int,int> > dads;
2199   std::vector<const DataArrayInt *> pfls;
2200   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2201   std::vector<int> locs,code;
2202   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2203   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2205   // Sort by types
2206   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2207   if(code.empty())
2208     {
2209       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2210       throw INTERP_KERNEL::Exception(oss.str());
2211     }
2212   //
2213   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2214   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2215   if(type!=ON_NODES)
2216     {
2217       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2218       if(!arr)
2219         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2220       else
2221         {
2222           MCAuto<DataArrayInt> arr2(arr);
2223           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2224         }
2225     }
2226   else
2227     {
2228       if(code.size()!=3)
2229         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2230       int nb=code[1];
2231       if(code[2]==-1)
2232         {
2233           if(nb!=mesh->getNumberOfNodes())
2234             {
2235               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2236               oss << " nodes in mesh !";
2237               throw INTERP_KERNEL::Exception(oss.str());
2238             }
2239           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2240         }
2241       else
2242         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2243     }
2244 }
2245
2246 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2247 {
2248   if(_field_pm_pt.empty())
2249     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2250   //
2251   std::vector<std::pair<int,int> > dads;
2252   std::vector<const DataArrayInt *> pfls;
2253   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2254   std::vector<int> locs,code;
2255   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2256   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2257     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2258   // Sort by types
2259   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2260   if(code.empty())
2261     {
2262       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2263       throw INTERP_KERNEL::Exception(oss.str());
2264     }
2265   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2266   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2267   if(type!=ON_NODES)
2268     {
2269       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2270       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2271     }
2272   else
2273     {
2274       if(code.size()!=3)
2275         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2276       int nb=code[1];
2277       if(code[2]==-1)
2278         {
2279           if(nb!=mesh->getNumberOfNodes())
2280             {
2281               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2282               oss << " nodes in mesh !";
2283               throw INTERP_KERNEL::Exception(oss.str());
2284             }
2285         }
2286       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2287     }
2288   //
2289   return 0;
2290 }
2291
2292 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2293 {
2294   int globalSz=0;
2295   int nbOfEntries=0;
2296   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2297     {
2298       (*it)->getSizes(globalSz,nbOfEntries);
2299     }
2300   entries.resize(nbOfEntries);
2301   nbOfEntries=0;
2302   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303     {
2304       (*it)->fillValues(nbOfEntries,entries);
2305     }
2306 }
2307
2308 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2309 {
2310   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311     {
2312       if((*it)->getGeoType()==typ)
2313         return (*it)->getLeafGivenLocId(locId);
2314     }
2315   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2316   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2317   oss << "Possiblities are : ";
2318   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2319     {
2320       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2321       oss << "\"" << cm2.getRepr() << "\", ";
2322     }
2323   throw INTERP_KERNEL::Exception(oss.str());
2324 }
2325
2326 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2327 {
2328   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2329     {
2330       if((*it)->getGeoType()==typ)
2331         return (*it)->getLeafGivenLocId(locId);
2332     }
2333   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2334   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2335   oss << "Possiblities are : ";
2336   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2337     {
2338       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2339       oss << "\"" << cm2.getRepr() << "\", ";
2340     }
2341   throw INTERP_KERNEL::Exception(oss.str());
2342 }
2343
2344 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2345 {
2346   int i=0;
2347   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2348   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2349   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2350     {
2351       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2352       if(type==curType)
2353         return i;
2354       else
2355         {
2356           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2357           if(pos>pos2)
2358             it2=it+1;
2359         }
2360     }
2361   int ret=std::distance(_field_pm_pt.begin(),it2);
2362   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2363   return ret;
2364 }
2365
2366 /*!
2367  * 'dads' and 'locs' input parameters have the same number of elements
2368  * \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
2369  */
2370 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2371                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2372                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2373 {
2374   isPfl=false;
2375   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2376   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2377   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2378   const std::vector<std::string>& infos=getInfo();
2379   da->setInfoOnComponents(infos);
2380   da->setName("");
2381   if(type==ON_GAUSS_PT)
2382     {
2383       int offset=0;
2384       int nbOfArrs=dads.size();
2385       for(int i=0;i<nbOfArrs;i++)
2386         {
2387           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2388           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2389           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2390           MCAuto<DataArrayInt> di=DataArrayInt::New();
2391           di->alloc(nbOfElems,1);
2392           di->iota(offset);
2393           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2394           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2395           offset+=nbOfElems;
2396         }
2397     }
2398   arrOut=da;
2399   return ret.retn();
2400 }
2401
2402 /*!
2403  * 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.
2404  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2405  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2406  * The order of cells in the returned field is those imposed by the profile.
2407  * \param [in] mesh is the global mesh.
2408  */
2409 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2410                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2411                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2412                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2413 {
2414   if(da->isIota(mesh->getNumberOfCells()))
2415     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2416   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2417   m2->setName(mesh->getName().c_str());
2418   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2419   isPfl=true;
2420   return ret.retn();
2421 }
2422
2423 /*!
2424  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2425  */
2426 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2427                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2428                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2429 {
2430   if(da->isIota(mesh->getNumberOfNodes()))
2431     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2432   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2433   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2434   if(meshu)
2435     {
2436       if(meshu->getNodalConnectivity()==0)
2437         {
2438           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2439           int nb=da->getNbOfElems();
2440           const int *ptr=da->getConstPointer();
2441           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2442           meshuc->allocateCells(nb);
2443           for(int i=0;i<nb;i++)
2444             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2445           meshuc->finishInsertingCells();
2446           ret->setMesh(meshuc);
2447           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2448           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2449           disc->checkCoherencyBetween(meshuc,arrOut);
2450           return ret.retn();
2451         }
2452     }
2453   //
2454   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2455   isPfl=true;
2456   DataArrayInt *arr2=0;
2457   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2458   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2459   MCAuto<DataArrayInt> arr3(arr2);
2460   int nnodes=mesh2->getNumberOfNodes();
2461   if(nnodes==(int)da->getNbOfElems())
2462     {
2463       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2464       arrOut->renumberInPlace(da3->getConstPointer());
2465       mesh2->setName(mesh->getName().c_str());
2466       ret->setMesh(mesh2);
2467       return ret.retn();
2468     }
2469   else
2470     {
2471       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 !!!";
2472       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2473       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2474       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2475       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2476       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2477       throw INTERP_KERNEL::Exception(oss.str());
2478     }
2479   return 0;
2480 }
2481
2482 /*!
2483  * This method is the most light method of field retrieving.
2484  */
2485 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2486 {
2487   if(!pflIn)
2488     {
2489       pflOut=DataArrayInt::New();
2490       pflOut->alloc(nbOfElems,1);
2491       pflOut->iota(0);
2492     }
2493   else
2494     {
2495       pflOut=const_cast<DataArrayInt*>(pflIn);
2496       pflOut->incrRef();
2497     }
2498   MCAuto<DataArrayInt> safePfl(pflOut);
2499   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2500   const std::vector<std::string>& infos=getInfo();
2501   int nbOfComp=infos.size();
2502   for(int i=0;i<nbOfComp;i++)
2503     da->setInfoOnComponent(i,infos[i].c_str());
2504   safePfl->incrRef();
2505   return da.retn();
2506 }
2507
2508
2509 /// @cond INTERNAL
2510
2511 class MFFPMIter
2512 {
2513 public:
2514   static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2515   static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2516   virtual ~MFFPMIter() { }
2517   virtual void begin() = 0;
2518   virtual bool finished() const = 0;
2519   virtual void next() = 0;
2520   virtual int current() const = 0;
2521 };
2522
2523 class MFFPMIterSimple : public MFFPMIter
2524 {
2525 public:
2526   MFFPMIterSimple():_pos(0) { }
2527   void begin() { _pos=0; }
2528   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2529   void next() { _pos++; }
2530   int current() const { return _pos; }
2531 private:
2532   int _pos;
2533 };
2534
2535 class MFFPMIter2 : public MFFPMIter
2536 {
2537 public:
2538   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2539   void begin() { _it=_ids.begin(); }
2540   bool finished() const { return _it==_ids.end(); }
2541   void next() { _it++; }
2542   int current() const { return *_it; }
2543 private:
2544   std::vector<int> _ids;
2545   std::vector<int>::const_iterator _it;
2546 };
2547
2548 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2549 {
2550   if(!entities)
2551     return new MFFPMIterSimple;
2552   else
2553     {
2554       std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2555       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2556         {
2557           if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2558             tmp.push_back((*it).second);
2559         }
2560       return new MFFPMIter2(tmp);
2561     }
2562 }
2563
2564 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2565 {
2566   if(!entities)
2567     return true;
2568   else
2569     {
2570       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2571         if((*it).first==ON_NODES)
2572           return true;
2573       return false;
2574     }
2575 }
2576
2577 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2578 {
2579   std::size_t sz(cts.size());
2580   _ids.resize(sz);
2581   for(std::size_t i=0;i<sz;i++)
2582     {
2583       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2584       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2585         _ids[i]=(int)std::distance(typmai2,loc);
2586       else
2587         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2588     }
2589 }
2590
2591 /// @endcond
2592
2593 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2594     _father(fath)
2595 {
2596   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2597   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2598   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2599   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2600   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2601   for(iter0->begin();!iter0->finished();iter0->next())
2602     {
2603       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2604       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2605       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2606       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2607       if(nbProfile>0 || nbProfile2>0)
2608         {
2609           const PartDefinition *pd(0);
2610           if(mmu)
2611             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2612           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2613           if(nbProfile>0)
2614             _mesh_name=name0;
2615           else
2616             _mesh_name=name1;
2617         }
2618     }
2619   if(MFFPMIter::IsPresenceOfNode(entities))
2620     {
2621       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2622       if(nbProfile>0)
2623         {
2624           const PartDefinition *pd(0);
2625           if(mmu)
2626             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2627           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2628           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2629         }
2630     }
2631 }
2632
2633 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2634 {
2635   copyTinyInfoFrom(mesh);
2636 }
2637
2638 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2639 {
2640   if(id>=(int)_pfls.size())
2641     _pfls.resize(id+1);
2642   _pfls[id]=DataArrayInt::New();
2643   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2644   _pfls[id]->setName(pflName);
2645   _pfls[id]->alloc(lgth,1);
2646   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2647   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2648 }
2649
2650 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2651 {
2652   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2653   int sz;
2654   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2655   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2656   if(i>=(int)_pfls.size())
2657     _pfls.resize(i+1);
2658   _pfls[i]=DataArrayInt::New();
2659   _pfls[i]->alloc(sz,1);
2660   _pfls[i]->setName(pflCpp.c_str());
2661   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2662   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2663 }
2664
2665 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2666 {
2667   int nbOfPfls=_pfls.size();
2668   for(int i=0;i<nbOfPfls;i++)
2669     {
2670       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2671       cpy->applyLin(1,1,0);
2672       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2673       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2674       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2675     }
2676   //
2677   int nbOfLocs=_locs.size();
2678   for(int i=0;i<nbOfLocs;i++)
2679     _locs[i]->writeLL(fid);
2680 }
2681
2682 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2683 {
2684   std::vector<std::string> pfls=getPfls();
2685   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2686     {
2687       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2688       if(it2==pfls.end())
2689         {
2690           _pfls.push_back(*it);
2691         }
2692       else
2693         {
2694           int id=std::distance(pfls.begin(),it2);
2695           if(!(*it)->isEqual(*_pfls[id]))
2696             {
2697               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2698               throw INTERP_KERNEL::Exception(oss.str());
2699             }
2700         }
2701     }
2702   std::vector<std::string> locs=getLocs();
2703   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2704     {
2705       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2706       if(it2==locs.end())
2707         {
2708           _locs.push_back(*it);
2709         }
2710       else
2711         {
2712           int id=std::distance(locs.begin(),it2);
2713           if(!(*it)->isEqual(*_locs[id],eps))
2714             {
2715               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2716               throw INTERP_KERNEL::Exception(oss.str());
2717             }
2718         }
2719     }
2720 }
2721
2722 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2723 {
2724   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2725     getProfile((*it).c_str());
2726 }
2727
2728 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2729 {
2730   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2731     getLocalization((*it).c_str());
2732 }
2733
2734 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2735 {
2736   std::vector<std::string> profiles=real.getPflsReallyUsed();
2737   int sz=profiles.size();
2738   _pfls.resize(sz);
2739   for(int i=0;i<sz;i++)
2740     loadProfileInFile(fid,i,profiles[i].c_str());
2741   //
2742   std::vector<std::string> locs=real.getLocsReallyUsed();
2743   sz=locs.size();
2744   _locs.resize(sz);
2745   for(int i=0;i<sz;i++)
2746     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2747 }
2748
2749 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2750 {
2751   int nProfil=MEDnProfile(fid);
2752   for(int i=0;i<nProfil;i++)
2753     loadProfileInFile(fid,i);
2754   int sz=MEDnLocalization(fid);
2755   _locs.resize(sz);
2756   for(int i=0;i<sz;i++)
2757     {
2758       _locs[i]=MEDFileFieldLoc::New(fid,i);
2759     }
2760 }
2761
2762 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2763 {
2764   return new MEDFileFieldGlobs(fname);
2765 }
2766
2767 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2768 {
2769   return new MEDFileFieldGlobs;
2770 }
2771
2772 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2773 {
2774   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2775 }
2776
2777 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2778 {
2779   std::vector<const BigMemoryObject *> ret;
2780   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2781     ret.push_back((const DataArrayInt *)*it);
2782   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2783     ret.push_back((const MEDFileFieldLoc *)*it);
2784   return ret;
2785 }
2786
2787 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2788 {
2789   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2790   std::size_t i=0;
2791   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2792     {
2793       if((const DataArrayInt *)*it)
2794         ret->_pfls[i]=(*it)->deepCopy();
2795     }
2796   i=0;
2797   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2798     {
2799       if((const MEDFileFieldLoc*)*it)
2800         ret->_locs[i]=(*it)->deepCopy();
2801     }
2802   return ret.retn();
2803 }
2804
2805 /*!
2806  * \throw if a profile in \a pfls in not in \a this.
2807  * \throw if a localization in \a locs in not in \a this.
2808  * \sa MEDFileFieldGlobs::deepCpyPart
2809  */
2810 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2811 {
2812   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2813   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2814     {
2815       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2816       if(!pfl)
2817         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2818       pfl->incrRef();
2819       MCAuto<DataArrayInt> pfl2(pfl);
2820       ret->_pfls.push_back(pfl2);
2821     }
2822   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2823     {
2824       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2825       if(!loc)
2826         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2827       loc->incrRef();
2828       MCAuto<MEDFileFieldLoc> loc2(loc);
2829       ret->_locs.push_back(loc2);
2830     }
2831   ret->setFileName(getFileName());
2832   return ret.retn();
2833 }
2834
2835 /*!
2836  * \throw if a profile in \a pfls in not in \a this.
2837  * \throw if a localization in \a locs in not in \a this.
2838  * \sa MEDFileFieldGlobs::shallowCpyPart
2839  */
2840 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2841 {
2842   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2843   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2844     {
2845       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2846       if(!pfl)
2847         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2848       ret->_pfls.push_back(pfl->deepCopy());
2849     }
2850   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2851     {
2852       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2853       if(!loc)
2854         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2855       ret->_locs.push_back(loc->deepCopy());
2856     }
2857   ret->setFileName(getFileName());
2858   return ret.retn();
2859 }
2860
2861 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2862 {
2863 }
2864
2865 MEDFileFieldGlobs::MEDFileFieldGlobs()
2866 {
2867 }
2868
2869 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2870 {
2871 }
2872
2873 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2874 {
2875   oss << "Profiles :\n";
2876   std::size_t n=_pfls.size();
2877   for(std::size_t i=0;i<n;i++)
2878     {
2879       oss << "  - #" << i << " ";
2880       const DataArrayInt *pfl=_pfls[i];
2881       if(pfl)
2882         oss << "\"" << pfl->getName() << "\"\n";
2883       else
2884         oss << "EMPTY !\n";
2885     }
2886   n=_locs.size();
2887   oss << "Localizations :\n";
2888   for(std::size_t i=0;i<n;i++)
2889     {
2890       oss << "  - #" << i << " ";
2891       const MEDFileFieldLoc *loc=_locs[i];
2892       if(loc)
2893         loc->simpleRepr(oss);
2894       else
2895         oss<< "EMPTY !\n";
2896     }
2897 }
2898
2899 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2900 {
2901   _file_name=fileName;
2902 }
2903
2904 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2905 {
2906   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2907     {
2908       DataArrayInt *elt(*it);
2909       if(elt)
2910         {
2911           std::string name(elt->getName());
2912           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2913             {
2914               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2915                 {
2916                   elt->setName((*it2).second.c_str());
2917                   return;
2918                 }
2919             }
2920         }
2921     }
2922 }
2923
2924 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2925 {
2926   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2927     {
2928       MEDFileFieldLoc *elt(*it);
2929       if(elt)
2930         {
2931           std::string name(elt->getName());
2932           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2933             {
2934               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2935                 {
2936                   elt->setName((*it2).second.c_str());
2937                   return;
2938                 }
2939             }
2940         }
2941     }
2942 }
2943
2944 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2945 {
2946   if(locId<0 || locId>=(int)_locs.size())
2947     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2948   return _locs[locId]->getNbOfGaussPtPerCell();
2949 }
2950
2951 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2952 {
2953   return getLocalizationFromId(getLocalizationId(locName));
2954 }
2955
2956 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2957 {
2958   if(locId<0 || locId>=(int)_locs.size())
2959     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2960   return *_locs[locId];
2961 }
2962
2963 /// @cond INTERNAL
2964 namespace MEDCouplingImpl
2965 {
2966   class LocFinder
2967   {
2968   public:
2969     LocFinder(const std::string& loc):_loc(loc) { }
2970     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2971   private:
2972     const std::string &_loc;
2973   };
2974
2975   class PflFinder
2976   {
2977   public:
2978     PflFinder(const std::string& pfl):_pfl(pfl) { }
2979     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2980   private:
2981     const std::string& _pfl;
2982   };
2983 }
2984 /// @endcond
2985
2986 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2987 {
2988   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2989   if(it==_locs.end())
2990     {
2991       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2992       for(it=_locs.begin();it!=_locs.end();it++)
2993         oss << "\"" << (*it)->getName() << "\", ";
2994       throw INTERP_KERNEL::Exception(oss.str());
2995     }
2996   return std::distance(_locs.begin(),it);
2997 }
2998
2999 /*!
3000  * The returned value is never null.
3001  */
3002 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3003 {
3004   std::string pflNameCpp(pflName);
3005   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3006   if(it==_pfls.end())
3007     {
3008       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3009       for(it=_pfls.begin();it!=_pfls.end();it++)
3010         oss << "\"" << (*it)->getName() << "\", ";
3011       throw INTERP_KERNEL::Exception(oss.str());
3012     }
3013   return *it;
3014 }
3015
3016 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3017 {
3018   if(pflId<0 || pflId>=(int)_pfls.size())
3019     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3020   return _pfls[pflId];
3021 }
3022
3023 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3024 {
3025   if(locId<0 || locId>=(int)_locs.size())
3026     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3027   return *_locs[locId];
3028 }
3029
3030 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3031 {
3032   return getLocalizationFromId(getLocalizationId(locName));
3033 }
3034
3035 /*!
3036  * The returned value is never null.
3037  */
3038 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3039 {
3040   std::string pflNameCpp(pflName);
3041   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3042   if(it==_pfls.end())
3043     {
3044       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3045       for(it=_pfls.begin();it!=_pfls.end();it++)
3046         oss << "\"" << (*it)->getName() << "\", ";
3047       throw INTERP_KERNEL::Exception(oss.str());
3048     }
3049   return *it;
3050 }
3051
3052 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3053 {
3054   if(pflId<0 || pflId>=(int)_pfls.size())
3055     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3056   return _pfls[pflId];
3057 }
3058
3059 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3060 {
3061   std::vector< MCAuto<DataArrayInt> > newPfls;
3062   int i=0;
3063   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3064     {
3065       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3066         newPfls.push_back(*it);
3067     }
3068   _pfls=newPfls;
3069 }
3070
3071 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3072 {
3073   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3074   int i=0;
3075   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3076     {
3077       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3078         newLocs.push_back(*it);
3079     }
3080   _locs=newLocs;
3081 }
3082
3083 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3084 {
3085   int sz=_pfls.size();
3086   std::vector<std::string> ret(sz);
3087   for(int i=0;i<sz;i++)
3088     ret[i]=_pfls[i]->getName();
3089   return ret;
3090 }
3091
3092 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3093 {
3094   int sz=_locs.size();
3095   std::vector<std::string> ret(sz);
3096   for(int i=0;i<sz;i++)
3097     ret[i]=_locs[i]->getName();
3098   return ret;
3099 }
3100
3101 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3102 {
3103   std::vector<std::string> v=getPfls();
3104   std::string s(pflName);
3105   return std::find(v.begin(),v.end(),s)!=v.end();
3106 }
3107
3108 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3109 {
3110   std::vector<std::string> v=getLocs();
3111   std::string s(locName);
3112   return std::find(v.begin(),v.end(),s)!=v.end();
3113 }
3114
3115 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3116 {
3117   std::map<int,std::vector<int> > m;
3118   int i=0;
3119   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3120     {
3121       const DataArrayInt *tmp=(*it);
3122       if(tmp)
3123         {
3124           m[tmp->getHashCode()].push_back(i);
3125         }
3126     }
3127   std::vector< std::vector<int> > ret;
3128   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3129     {
3130       if((*it2).second.size()>1)
3131         {
3132           std::vector<int> ret0;
3133           bool equalityOrNot=false;
3134           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3135             {
3136               std::vector<int>::const_iterator it4=it3; it4++;
3137               for(;it4!=(*it2).second.end();it4++)
3138                 {
3139                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3140                     {
3141                       if(!equalityOrNot)
3142                         ret0.push_back(*it3);
3143                       ret0.push_back(*it4);
3144                       equalityOrNot=true;
3145                     }
3146                 }
3147             }
3148           if(!ret0.empty())
3149             ret.push_back(ret0);
3150         }
3151     }
3152   return ret;
3153 }
3154
3155 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3156 {
3157   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3158 }
3159
3160 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3161 {
3162   std::string name(pfl->getName());
3163   if(name.empty())
3164     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3165   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3166     if(name==(*it)->getName())
3167       {
3168         if(!pfl->isEqual(*(*it)))
3169           {
3170             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3171             throw INTERP_KERNEL::Exception(oss.str());
3172           }
3173       }
3174   pfl->incrRef();
3175   _pfls.push_back(pfl);
3176 }
3177
3178 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)
3179 {
3180   std::string name(locName);
3181   if(name.empty())
3182     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3183   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3184   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3185     if((*it)->isName(locName))
3186       {
3187         if(!(*it)->isEqual(*obj,1e-12))
3188           {
3189             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3190             throw INTERP_KERNEL::Exception(oss.str());
3191           }
3192       }
3193   _locs.push_back(obj);
3194 }
3195
3196 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3197 {
3198   std::vector<std::string> names=getPfls();
3199   return CreateNewNameNotIn("NewPfl_",names);
3200 }
3201
3202 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3203 {
3204   std::vector<std::string> names=getLocs();
3205   return CreateNewNameNotIn("NewLoc_",names);
3206 }
3207
3208 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3209 {
3210   for(std::size_t sz=0;sz<100000;sz++)
3211     {
3212       std::ostringstream tryName;
3213       tryName << prefix << sz;
3214       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3215         return tryName.str();
3216     }
3217   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3218 }
3219
3220 /*!
3221  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3222  *  \param [in] fname - the file name.
3223  */
3224 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3225 {
3226 }
3227
3228 /*!
3229  * Creates an empty MEDFileFieldGlobsReal.
3230  */
3231 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3232 {
3233 }
3234
3235 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3236 {
3237   return 0;
3238 }
3239
3240 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3241 {
3242   std::vector<const BigMemoryObject *> ret;
3243   ret.push_back((const MEDFileFieldGlobs *)_globals);
3244   return ret;
3245 }
3246
3247 /*!
3248  * Returns a string describing profiles and Gauss points held in \a this.
3249  *  \return std::string - the description string.
3250  */
3251 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3252 {
3253   const MEDFileFieldGlobs *glob=_globals;
3254   std::ostringstream oss2; oss2 << glob;
3255   std::string stars(oss2.str().length(),'*');
3256   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3257   if(glob)
3258     glob->simpleRepr(oss);
3259   else
3260     oss << "NO GLOBAL INFORMATION !\n";
3261 }
3262
3263 void MEDFileFieldGlobsReal::resetContent()
3264 {
3265   _globals=MEDFileFieldGlobs::New();
3266 }
3267
3268 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3269 {
3270 }
3271
3272 /*!
3273  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3274  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3275  */
3276 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3277 {
3278   _globals=other._globals;
3279 }
3280
3281 /*!
3282  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3283  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3284  */
3285 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3286 {
3287   const MEDFileFieldGlobs *otherg(other._globals);
3288   if(!otherg)
3289     return ;
3290   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3291 }
3292
3293 /*!
3294  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3295  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3296  */
3297 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3298 {
3299   const MEDFileFieldGlobs *otherg(other._globals);
3300   if(!otherg)
3301     return ;
3302   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3303 }
3304
3305 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3306 {
3307   _globals=other._globals;
3308   if((const MEDFileFieldGlobs *)_globals)
3309     _globals=other._globals->deepCopy();
3310 }
3311
3312 /*!
3313  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3314  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3315  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3316  *         \a this and \a other MEDFileFieldGlobsReal.
3317  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3318  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3319  */
3320 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3321 {
3322   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3323   if(thisGlobals==otherGlobals)
3324     return ;
3325   if(!thisGlobals)
3326     {
3327       _globals=other._globals;
3328       return ;
3329     }
3330   _globals->appendGlobs(*other._globals,eps);
3331 }
3332
3333 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3334 {
3335   checkGlobsPflsPartCoherency();
3336   checkGlobsLocsPartCoherency();
3337 }
3338
3339 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3340 {
3341   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3342 }
3343
3344 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3345 {
3346   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3347 }
3348
3349 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3350 {
3351   contentNotNull()->loadProfileInFile(fid,id,pflName);
3352 }
3353
3354 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3355 {
3356   contentNotNull()->loadProfileInFile(fid,id);
3357 }
3358
3359 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3360 {
3361   contentNotNull()->loadGlobals(fid,*this);
3362 }
3363
3364 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3365 {
3366   contentNotNull()->loadAllGlobals(fid);
3367 }
3368
3369 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3370 {
3371   contentNotNull()->writeGlobals(fid,opt);
3372 }
3373
3374 /*!
3375  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3376  * or getPflsReallyUsedMulti().
3377  *  \return std::vector<std::string> - a sequence of names of all profiles.
3378  */
3379 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3380 {
3381   return contentNotNull()->getPfls();
3382 }
3383
3384 /*!
3385  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3386  * or getLocsReallyUsedMulti().
3387  *  \return std::vector<std::string> - a sequence of names of all localizations.
3388  */
3389 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3390 {
3391   return contentNotNull()->getLocs();
3392 }
3393
3394 /*!
3395  * Checks if the profile with a given name exists.
3396  *  \param [in] pflName - the profile name of interest.
3397  *  \return bool - \c true if the profile named \a pflName exists.
3398  */
3399 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3400 {
3401   return contentNotNull()->existsPfl(pflName);
3402 }
3403
3404 /*!
3405  * Checks if the localization with a given name exists.
3406  *  \param [in] locName - the localization name of interest.
3407  *  \return bool - \c true if the localization named \a locName exists.
3408  */
3409 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3410 {
3411   return contentNotNull()->existsLoc(locName);
3412 }
3413
3414 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3415 {
3416   return contentNotNull()->createNewNameOfPfl();
3417 }
3418
3419 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3420 {
3421   return contentNotNull()->createNewNameOfLoc();
3422 }
3423
3424 /*!
3425  * Sets the name of a MED file.
3426  *  \param [inout] fileName - the file name.
3427  */
3428 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3429 {
3430   contentNotNull()->setFileName(fileName);
3431 }
3432
3433 /*!
3434  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3435  * in the same order.
3436  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3437  *          Each item of this sequence is a vector containing ids of equal profiles.
3438  */
3439 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3440 {
3441   return contentNotNull()->whichAreEqualProfiles();
3442 }
3443
3444 /*!
3445  * Finds equal localizations.
3446  *  \param [in] eps - a precision used to compare real values of the localizations.
3447  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3448  *          Each item of this sequence is a vector containing ids of equal localizations.
3449  */
3450 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3451 {
3452   return contentNotNull()->whichAreEqualLocs(eps);
3453 }
3454
3455 /*!
3456  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3457  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3458  *        this sequence is a pair whose 
3459  *        - the first item is a vector of profile names to replace by the second item,
3460  *        - the second item is a profile name to replace every profile name of the first item.
3461  */
3462 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3463 {
3464   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3465 }
3466
3467 /*!
3468  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3469  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3470  *        this sequence is a pair whose 
3471  *        - the first item is a vector of localization names to replace by the second item,
3472  *        - the second item is a localization name to replace every localization name of the first item.
3473  */
3474 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3475 {
3476   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3477 }
3478
3479 /*!
3480  * Replaces references to some profiles (a reference is a profile name) by references
3481  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3482  * them-selves accordingly. <br>
3483  * This method is a generalization of changePflName().
3484  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3485  *        this sequence is a pair whose 
3486  *        - the first item is a vector of profile names to replace by the second item,
3487  *        - the second item is a profile name to replace every profile of the first item.
3488  * \sa changePflsRefsNamesGen()
3489  * \sa changePflName()
3490  */
3491 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3492 {
3493   changePflsRefsNamesGen(mapOfModif);
3494   changePflsNamesInStruct(mapOfModif);
3495 }
3496
3497 /*!
3498  * Replaces references to some localizations (a reference is a localization name) by references
3499  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3500  * them-selves accordingly. <br>
3501  * This method is a generalization of changeLocName().
3502  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3503  *        this sequence is a pair whose 
3504  *        - the first item is a vector of localization names to replace by the second item,
3505  *        - the second item is a localization name to replace every localization of the first item.
3506  * \sa changeLocsRefsNamesGen()
3507  * \sa changeLocName()
3508  */
3509 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3510 {
3511   changeLocsRefsNamesGen(mapOfModif);
3512   changeLocsNamesInStruct(mapOfModif);
3513 }
3514
3515 /*!
3516  * Renames the profile having a given name and updates references to this profile.
3517  *  \param [in] oldName - the name of the profile to rename.
3518  *  \param [in] newName - a new name of the profile.
3519  * \sa changePflsNames().
3520  */
3521 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3522 {
3523   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3524   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3525   mapOfModif[0]=p;
3526   changePflsNames(mapOfModif);
3527 }
3528
3529 /*!
3530  * Renames the localization having a given name and updates references to this localization.
3531  *  \param [in] oldName - the name of the localization to rename.
3532  *  \param [in] newName - a new name of the localization.
3533  * \sa changeLocsNames().
3534  */
3535 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3536 {
3537   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3538   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3539   mapOfModif[0]=p;
3540   changeLocsNames(mapOfModif);
3541 }
3542
3543 /*!
3544  * Removes duplicated profiles. Returns a map used to update references to removed 
3545  * profiles via changePflsRefsNamesGen().
3546  * Equal profiles are found using whichAreEqualProfiles().
3547  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3548  *          a sequence describing the performed replacements of profiles. Each element of
3549  *          this sequence is a pair whose
3550  *          - the first item is a vector of profile names replaced by the second item,
3551  *          - the second item is a profile name replacing every profile of the first item.
3552  */
3553 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3554 {
3555   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3556   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3557   int i=0;
3558   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3559     {
3560       std::vector< std::string > tmp((*it).size());
3561       int j=0;
3562       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3563         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3564       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3565       ret[i]=p;
3566       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3567       killProfileIds(tmp2);
3568     }
3569   changePflsRefsNamesGen(ret);
3570   return ret;
3571 }
3572
3573 /*!
3574  * Removes duplicated localizations. Returns a map used to update references to removed 
3575  * localizations via changeLocsRefsNamesGen().
3576  * Equal localizations are found using whichAreEqualLocs().
3577  *  \param [in] eps - a precision used to compare real values of the localizations.
3578  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3579  *          a sequence describing the performed replacements of localizations. Each element of
3580  *          this sequence is a pair whose
3581  *          - the first item is a vector of localization names replaced by the second item,
3582  *          - the second item is a localization name replacing every localization of the first item.
3583  */
3584 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3585 {
3586   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3587   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3588   int i=0;
3589   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3590     {
3591       std::vector< std::string > tmp((*it).size());
3592       int j=0;
3593       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3594         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3595       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3596       ret[i]=p;
3597       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3598       killLocalizationIds(tmp2);
3599     }
3600   changeLocsRefsNamesGen(ret);
3601   return ret;
3602 }
3603
3604 /*!
3605  * Returns number of Gauss points per cell in a given localization.
3606  *  \param [in] locId - an id of the localization of interest.
3607  *  \return int - the number of the Gauss points per cell.
3608  */
3609 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3610 {
3611   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3612 }
3613
3614 /*!
3615  * Returns an id of a localization by its name.
3616  *  \param [in] loc - the localization name of interest.
3617  *  \return int - the id of the localization.
3618  *  \throw If there is no a localization named \a loc.
3619  */
3620 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3621 {
3622   return contentNotNull()->getLocalizationId(loc);
3623 }
3624
3625 /*!
3626  * Returns the name of the MED file.
3627  *  \return const std::string&  - the MED file name.
3628  */
3629 std::string MEDFileFieldGlobsReal::getFileName() const
3630 {
3631   return contentNotNull()->getFileName();
3632 }
3633
3634 /*!
3635  * Returns a localization object by its name.
3636  *  \param [in] locName - the name of the localization of interest.
3637  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3638  *  \throw If there is no a localization named \a locName.
3639  */
3640 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3641 {
3642   return contentNotNull()->getLocalization(locName);
3643 }
3644
3645 /*!
3646  * Returns a localization object by its id.
3647  *  \param [in] locId - the id of the localization of interest.
3648  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3649  *  \throw If there is no a localization with id \a locId.
3650  */
3651 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3652 {
3653   return contentNotNull()->getLocalizationFromId(locId);
3654 }
3655
3656 /*!
3657  * Returns a profile array by its name.
3658  *  \param [in] pflName - the name of the profile of interest.
3659  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3660  *  \throw If there is no a profile named \a pflName.
3661  */
3662 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3663 {
3664   return contentNotNull()->getProfile(pflName);
3665 }
3666
3667 /*!
3668  * Returns a profile array by its id.
3669  *  \param [in] pflId - the id of the profile of interest.
3670  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3671  *  \throw If there is no a profile with id \a pflId.
3672  */
3673 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3674 {
3675   return contentNotNull()->getProfileFromId(pflId);
3676 }
3677
3678 /*!
3679  * Returns a localization object, apt for modification, by its id.
3680  *  \param [in] locId - the id of the localization of interest.
3681  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3682  *          having the id \a locId.
3683  *  \throw If there is no a localization with id \a locId.
3684  */
3685 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3686 {
3687   return contentNotNull()->getLocalizationFromId(locId);
3688 }
3689
3690 /*!
3691  * Returns a localization object, apt for modification, by its name.
3692  *  \param [in] locName - the name of the localization of interest.
3693  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3694  *          having the name \a locName.
3695  *  \throw If there is no a localization named \a locName.
3696  */
3697 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3698 {
3699   return contentNotNull()->getLocalization(locName);
3700 }
3701
3702 /*!
3703  * Returns a profile array, apt for modification, by its name.
3704  *  \param [in] pflName - the name of the profile of interest.
3705  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3706  *  \throw If there is no a profile named \a pflName.
3707  */
3708 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3709 {
3710   return contentNotNull()->getProfile(pflName);
3711 }
3712
3713 /*!
3714  * Returns a profile array, apt for modification, by its id.
3715  *  \param [in] pflId - the id of the profile of interest.
3716  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3717  *  \throw If there is no a profile with id \a pflId.
3718  */
3719 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3720 {
3721   return contentNotNull()->getProfileFromId(pflId);
3722 }
3723
3724 /*!
3725  * Removes profiles given by their ids. No data is updated to track this removal.
3726  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3727  */
3728 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3729 {
3730   contentNotNull()->killProfileIds(pflIds);
3731 }
3732
3733 /*!
3734  * Removes localizations given by their ids. No data is updated to track this removal.
3735  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3736  */
3737 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3738 {
3739   contentNotNull()->killLocalizationIds(locIds);
3740 }
3741
3742 /*!
3743  * Stores a profile array.
3744  *  \param [in] pfl - the profile array to store.
3745  *  \throw If the name of \a pfl is empty.
3746  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3747  *         different ids.
3748  */
3749 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3750 {
3751   contentNotNull()->appendProfile(pfl);
3752 }
3753
3754 /*!
3755  * Adds a new localization of Gauss points.
3756  *  \param [in] locName - the name of the new localization.
3757  *  \param [in] geoType - a geometrical type of the reference cell.
3758  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3759  *         must be \c nbOfNodesPerCell * \c dimOfType.
3760  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3761  *         must be  _wg_.size() * \c dimOfType.
3762  *  \param [in] w - the weights of Gauss points.
3763  *  \throw If \a locName is empty.
3764  *  \throw If a localization with the name \a locName already exists but is
3765  *         different form the new one.
3766  */
3767 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)
3768 {
3769   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3770 }
3771
3772 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3773 {
3774   MEDFileFieldGlobs *g(_globals);
3775   if(!g)
3776     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3777   return g;
3778 }
3779
3780 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3781 {
3782   const MEDFileFieldGlobs *g(_globals);
3783   if(!g)
3784     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3785   return g;
3786 }
3787
3788 //= MEDFileFieldNameScope
3789
3790 MEDFileFieldNameScope::MEDFileFieldNameScope()
3791 {
3792 }
3793
3794 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3795 {
3796 }
3797
3798 /*!
3799  * Returns the name of \a this field.
3800  *  \return std::string - a string containing the field name.
3801  */
3802 std::string MEDFileFieldNameScope::getName() const
3803 {
3804   return _name;
3805 }
3806
3807 /*!
3808  * Sets name of \a this field
3809  *  \param [in] name - the new field name.
3810  */
3811 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3812 {
3813   _name=fieldName;
3814 }
3815
3816 std::string MEDFileFieldNameScope::getDtUnit() const
3817 {
3818   return _dt_unit;
3819 }
3820
3821 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3822 {
3823   _dt_unit=dtUnit;
3824 }
3825
3826 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3827 {
3828   _name=other._name;
3829   _dt_unit=other._dt_unit;
3830 }
3831
3832 //= MEDFileAnyTypeField1TSWithoutSDA
3833
3834 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3835 {
3836   _field_per_mesh.resize(other._field_per_mesh.size());
3837   std::size_t i=0;
3838   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3839     {
3840       if((const MEDFileFieldPerMesh *)*it)
3841         _field_per_mesh[i]=(*it)->deepCopy(this);
3842     }
3843 }
3844
3845 /*!
3846  * Prints a string describing \a this field into a stream. This string is outputted 
3847  * by \c print Python command.
3848  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3849  *  \param [in,out] oss - the out stream.
3850  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3851  *          info id printed, else, not.
3852  */
3853 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3854 {
3855   std::string startOfLine(bkOffset,' ');
3856   oss << startOfLine << "Field ";
3857   if(bkOffset==0)
3858     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3859   oss << "on one time Step ";
3860   if(f1tsId>=0)
3861     oss << "(" << f1tsId << ") ";
3862   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3863   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3864   const DataArray *arr=getUndergroundDataArray();
3865   if(arr)
3866     {
3867       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3868       if(f1tsId<0)
3869         {
3870           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3871           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3872             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3873         }
3874       if(arr->isAllocated())
3875         {
3876           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3877         }
3878       else
3879         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3880     }
3881   else
3882     {
3883       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3884     }
3885   oss << startOfLine << "----------------------" << std::endl;
3886   if(!_field_per_mesh.empty())
3887     {
3888       int i=0;
3889       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3890         {
3891           const MEDFileFieldPerMesh *cur=(*it2);
3892           if(cur)
3893             cur->simpleRepr(bkOffset,oss,i);
3894           else
3895             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3896         }
3897     }
3898   else
3899     {
3900       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3901     }
3902   oss << startOfLine << "----------------------" << std::endl;
3903 }
3904
3905 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3906 {
3907   const DataArray *arr(getUndergroundDataArray());
3908   if(!arr)
3909     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3910   int nbOfCompo=arr->getNumberOfComponents();
3911   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3912   for(int i=0;i<nbOfCompo;i++)
3913     {
3914       ret[i]=deepCopy();
3915       std::vector<int> v(1,i);
3916       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3917       ret[i]->setArray(arr2);
3918     }
3919   return ret;
3920 }
3921
3922 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)
3923 {
3924 }
3925
3926 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3927 {
3928 }
3929
3930 /*!
3931  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3932  * empty. Returns -1 if this in on nodes.
3933  *  \return int - the dimension of \a this.
3934  */
3935 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3936 {
3937   int ret=-2;
3938   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3939     (*it)->getDimension(ret);
3940   return ret;
3941 }
3942
3943 /*!
3944  * Returns the mesh name.
3945  *  \return std::string - a string holding the mesh name.
3946  *  \throw If \c _field_per_mesh.empty()
3947  */
3948 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3949 {
3950   if(_field_per_mesh.empty())
3951     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3952   return _field_per_mesh[0]->getMeshName();
3953 }
3954
3955 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3956 {
3957   std::string oldName(getMeshName());
3958   std::vector< std::pair<std::string,std::string> > v(1);
3959   v[0].first=oldName; v[0].second=newMeshName;
3960   changeMeshNames(v);
3961 }
3962
3963 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3964 {
3965   bool ret=false;
3966   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3967     {
3968       MEDFileFieldPerMesh *cur(*it);
3969       if(cur)
3970         ret=cur->changeMeshNames(modifTab) || ret;
3971     }
3972   return ret;
3973 }
3974
3975 /*!
3976  * Returns the number of iteration of the state of underlying mesh.
3977  *  \return int - the iteration number.
3978  *  \throw If \c _field_per_mesh.empty()
3979  */
3980 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3981 {
3982   if(_field_per_mesh.empty())
3983     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3984   return _field_per_mesh[0]->getMeshIteration();
3985 }
3986
3987 /*!
3988  * Returns the order number of iteration of the state of underlying mesh.
3989  *  \return int - the order number.
3990  *  \throw If \c _field_per_mesh.empty()
3991  */
3992 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3993 {
3994   if(_field_per_mesh.empty())
3995     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3996   return _field_per_mesh[0]->getMeshOrder();
3997 }
3998
3999 /*!
4000  * Checks if \a this field is tagged by a given iteration number and a given
4001  * iteration order number.
4002  *  \param [in] iteration - the iteration number of interest.
4003  *  \param [in] order - the iteration order number of interest.
4004  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4005  *          \a this->getOrder() == \a order.
4006  */
4007 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4008 {
4009   return iteration==_iteration && order==_order;
4010 }
4011
4012 /*!
4013  * Returns number of iteration and order number of iteration when
4014  * \a this field has been calculated.
4015  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4016  *          order number.
4017  */
4018 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4019 {
4020   std::pair<int,int> p;
4021   fillIteration(p);
4022   return p;
4023 }
4024
4025 /*!
4026  * Returns number of iteration and order number of iteration when
4027  * \a this field has been calculated.
4028  *  \param [in,out] p - a pair returning the iteration number and the iteration
4029  *          order number.
4030  */
4031 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4032 {
4033   p.first=_iteration;
4034   p.second=_order;
4035 }
4036
4037 /*!
4038  * Returns all types of spatial discretization of \a this field.
4039  *  \param [in,out] types - a sequence of types of \a this field.
4040  */
4041 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4042 {
4043   std::set<TypeOfField> types2;
4044   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4045     {
4046       (*it)->fillTypesOfFieldAvailable(types2);
4047     }
4048   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4049   std::copy(types2.begin(),types2.end(),bi);
4050 }
4051
4052 /*!
4053  * Returns all types of spatial discretization of \a this field.
4054  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4055  *          of \a this field.
4056  */
4057 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4058 {
4059   std::vector<TypeOfField> ret;
4060   fillTypesOfFieldAvailable(ret);
4061   return ret;
4062 }
4063
4064 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4065 {
4066   std::vector<std::string> ret;
4067   std::set<std::string> ret2;
4068   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4069     {
4070       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4071       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4072         if(ret2.find(*it2)==ret2.end())
4073           {
4074             ret.push_back(*it2);
4075             ret2.insert(*it2);
4076           }
4077     }
4078   return ret;
4079 }
4080
4081 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4082 {
4083   std::vector<std::string> ret;
4084   std::set<std::string> ret2;
4085   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4086     {
4087       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4088       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4089         if(ret2.find(*it2)==ret2.end())
4090           {
4091             ret.push_back(*it2);
4092             ret2.insert(*it2);
4093           }
4094     }
4095   return ret;
4096 }
4097
4098 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4099 {
4100   std::vector<std::string> ret;
4101   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4102     {
4103       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4104       ret.insert(ret.end(),tmp.begin(),tmp.end());
4105     }
4106   return ret;
4107 }
4108
4109 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4110 {
4111   std::vector<std::string> ret;
4112   std::set<std::string> ret2;
4113   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4114     {
4115       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4116       ret.insert(ret.end(),tmp.begin(),tmp.end());
4117     }
4118   return ret;
4119 }
4120
4121 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4122 {
4123   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4124     (*it)->changePflsRefsNamesGen(mapOfModif);
4125 }
4126
4127 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4128 {
4129   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4130     (*it)->changeLocsRefsNamesGen(mapOfModif);
4131 }
4132
4133 /*!
4134  * Returns all attributes of parts of \a this field lying on a given mesh.
4135  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4136  * item of every of returned sequences refers to the _i_-th part of \a this field.
4137  * Thus all sequences returned by this method are of the same length equal to number
4138  * of different types of supporting entities.<br>
4139  * A field part can include sub-parts with several different spatial discretizations,
4140  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4141  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4142  * of a nested sequence corresponds to a type of spatial discretization.<br>
4143  * This method allows for iteration over MEDFile DataStructure without any overhead.
4144  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4145  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4146  *          not checked if \a mname == \c NULL).
4147  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4148  *          a field part is returned. 
4149  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4150  *          This sequence is of the same length as \a types. 
4151  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4152  *          discretization. A profile name can be empty.
4153  *          Length of this and of nested sequences is the same as that of \a typesF.
4154  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4155  *          discretization. A localization name can be empty.
4156  *          Length of this and of nested sequences is the same as that of \a typesF.
4157  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4158  *          of ids of tuples within the data array, per each type of spatial
4159  *          discretization within one mesh entity type. 
4160  *          Length of this and of nested sequences is the same as that of \a typesF.
4161  *  \throw If no field is lying on \a mname.
4162  */
4163 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
4164 {
4165   int meshId=0;
4166   if(!mname.empty())
4167     meshId=getMeshIdFromMeshName(mname);
4168   else
4169     if(_field_per_mesh.empty())
4170       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4171   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4172 }
4173
4174 /*!
4175  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4176  * maximal absolute dimension and values returned via the out parameter \a levs are 
4177  * dimensions relative to the maximal absolute dimension. <br>
4178  * This method is designed for MEDFileField1TS instances that have a discretization
4179  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4180  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4181  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4182  * Only these 3 discretizations will be taken into account here. If \a this is
4183  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4184  * This method is useful to make the link between the dimension of the underlying mesh
4185  * and the levels of \a this, because it is possible that the highest dimension of \a this
4186  * field is not equal to the dimension of the underlying mesh.
4187  * 
4188  * Let's consider the following case:
4189  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4190  * TETRA4, HEXA8, TRI3 and SEG2.
4191  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4192  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4193  *
4194  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4195  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4196  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4197  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4198  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4199  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4200  * For example<br>
4201  * to retrieve the highest level of
4202  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4203  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4204  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4205  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4206  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4207  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4208  *          not checked if \a mname == \c NULL).
4209  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4210  *          absolute one. They are in decreasing order. This sequence is cleared before
4211  *          filling it in.
4212  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4213  *  \throw If no field is lying on \a mname.
4214  */
4215 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4216 {
4217   levs.clear();
4218   int meshId=getMeshIdFromMeshName(mname);
4219   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4220   std::vector< std::vector<TypeOfField> > typesF;
4221   std::vector< std::vector<std::string> > pfls, locs;
4222   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4223   if(types.empty())
4224     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4225   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4226   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4227     return -1;
4228   st.erase(INTERP_KERNEL::NORM_ERROR);
4229   std::set<int> ret1;
4230   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4231     {
4232       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4233       ret1.insert((int)cm.getDimension());
4234     }
4235   int ret=*std::max_element(ret1.begin(),ret1.end());
4236   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4237   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4238   return ret;
4239 }
4240
4241 /*!
4242  * \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.
4243  * \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.
4244  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4245  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4246  */
4247 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4248 {
4249   int mid=getMeshIdFromMeshName(mName);
4250   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4251 }
4252
4253 /*!
4254  * \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.
4255  * \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.
4256  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4257  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4258  */
4259 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4260 {
4261   int mid=getMeshIdFromMeshName(mName);
4262   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4263 }
4264
4265 /*!
4266  * \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.
4267  */
4268 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4269 {
4270   if(_field_per_mesh.empty())
4271     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4272   if(mName.empty())
4273     return 0;
4274   std::string mName2(mName);
4275   int ret=0;
4276   std::vector<std::string> msg;
4277   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4278     if(mName2==(*it)->getMeshName())
4279       return ret;
4280     else
4281       msg.push_back((*it)->getMeshName());
4282   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4283   oss << "Possible meshes are : ";
4284   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4285     oss << "\"" << (*it2) << "\" ";
4286   throw INTERP_KERNEL::Exception(oss.str());
4287 }
4288
4289 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4290 {
4291   if(!mesh)
4292     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4293   std::string tmp(mesh->getName());
4294   if(tmp.empty())
4295     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4296   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4297   int i=0;
4298   for(;it!=_field_per_mesh.end();it++,i++)
4299     {
4300       if((*it)->getMeshName()==tmp)
4301         return i;
4302     }
4303   int sz=_field_per_mesh.size();
4304   _field_per_mesh.resize(sz+1);
4305   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4306   return sz;
4307 }
4308
4309 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4310                                                                    MEDFileFieldGlobsReal& glob)
4311 {
4312   bool ret=false;
4313   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4314     {
4315       MEDFileFieldPerMesh *fpm(*it);
4316       if(fpm)
4317         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4318     }
4319   return ret;
4320 }
4321
4322 /*!
4323  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4324  * splitting that leads to single spatial discretization of this.
4325  *
4326  * \sa splitMultiDiscrPerGeoTypes
4327  */
4328 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4329 {
4330   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4331   std::vector< std::vector<TypeOfField> > typesF;
4332   std::vector< std::vector<std::string> > pfls,locs;
4333   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4334   std::set<TypeOfField> allEnt;
4335   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4336     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4337       allEnt.insert(*it2);
4338   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4339   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4340   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4341     {
4342       std::vector< std::pair<int,int> > its;
4343       ret[i]=shallowCpy();
4344       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4345       ret[i]->updateData(newLgth,its);
4346     }
4347   return ret;
4348 }
4349
4350 /*!
4351  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4352  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4353  *
4354  * \sa splitDiscretizations
4355  */
4356 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4357 {
4358   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4359   std::vector< std::vector<TypeOfField> > typesF;
4360   std::vector< std::vector<std::string> > pfls,locs;
4361   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4362   std::set<TypeOfField> allEnt;
4363   std::size_t nbOfMDPGT(0),ii(0);
4364   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4365     {
4366       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4367       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4368         allEnt.insert(*it2);
4369     }
4370   if(allEnt.size()!=1)
4371     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4372   if(nbOfMDPGT==0)
4373     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4374   if(nbOfMDPGT==1)
4375     {
4376       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4377       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4378       return ret0;
4379     }
4380   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4381   for(std::size_t i=0;i<nbOfMDPGT;i++)
4382     {
4383       std::vector< std::pair<int,int> > its;
4384       ret[i]=shallowCpy();
4385       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4386       ret[i]->updateData(newLgth,its);
4387     }
4388   return ret;
4389 }
4390
4391 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4392 {
4393   int globalCounter(0);
4394   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4395     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4396   return globalCounter;
4397 }
4398
4399 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4400 {
4401   int globalCounter(0);
4402   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4403     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4404   return globalCounter;
4405 }
4406
4407 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4408 {
4409   if(_nb_of_tuples_to_be_allocated>=0)
4410     {
4411       _nb_of_tuples_to_be_allocated=newLgth;
4412       const DataArray *oldArr(getUndergroundDataArray());
4413       if(oldArr)
4414         {
4415           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4416           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4417           setArray(newArr);
4418           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4419         }
4420       return ;
4421     }
4422   if(_nb_of_tuples_to_be_allocated==-1)
4423     return ;
4424   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4425     {
4426       const DataArray *oldArr(getUndergroundDataArray());
4427       if(!oldArr || !oldArr->isAllocated())
4428         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4429       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4430       newArr->alloc(newLgth,getNumberOfComponents());
4431       if(oldArr)
4432         newArr->copyStringInfoFrom(*oldArr);
4433       int pos=0;
4434       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4435         {
4436           if((*it).second<(*it).first)
4437             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4438           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4439           pos+=(*it).second-(*it).first;
4440         }
4441       setArray(newArr);
4442       return ;
4443     }
4444   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4445 }
4446
4447 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4448 {
4449   if(_field_per_mesh.empty())
4450     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4451   if(_field_per_mesh.size()>1)
4452     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4453   _field_per_mesh[0]->copyOptionsFrom(opts);
4454   _field_per_mesh[0]->writeLL(fid,nasc);
4455 }
4456
4457 /*!
4458  * 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.
4459  * If false is returned the memory allocation is not required.
4460  */
4461 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4462 {
4463   if(_nb_of_tuples_to_be_allocated>=0)
4464     {
4465       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4466       _nb_of_tuples_to_be_allocated=-2;
4467       return true;
4468     }
4469   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4470     return false;
4471   if(_nb_of_tuples_to_be_allocated==-1)
4472     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4473   if(_nb_of_tuples_to_be_allocated<-3)
4474     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4475   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4476 }
4477
4478 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4479 {
4480   med_int numdt,numit;
4481   med_float dt;
4482   med_int nmesh;
4483   med_bool localMesh;
4484   med_int meshnumdt,meshnumit;
4485   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4486   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4487   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4488   if(_iteration!=numdt || _order!=numit)
4489     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4490   _field_per_mesh.resize(nmesh);
4491   //
4492   MEDFileMesh *mm(0);
4493   if(ms)
4494     {
4495       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4496       mm=ms->getMeshWithName(meshNameCpp);
4497     }
4498   //
4499   for(int i=0;i<nmesh;i++)
4500     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4501   _nb_of_tuples_to_be_allocated=0;
4502   for(int i=0;i<nmesh;i++)
4503     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4504 }
4505
4506 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4507 {
4508   allocIfNecessaryTheArrayToReceiveDataFromFile();
4509   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4510     (*it)->loadBigArraysRecursively(fid,nasc);
4511 }
4512
4513 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4514 {
4515   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4516     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4517       (*it)->loadBigArraysRecursively(fid,nasc);
4518 }
4519
4520 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4521 {
4522   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4523   loadBigArraysRecursively(fid,nasc);
4524 }
4525
4526 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4527 {
4528   DataArray *thisArr(getUndergroundDataArray());
4529   if(thisArr && thisArr->isAllocated())
4530     {
4531       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4532       thisArr->desallocate();
4533     }
4534 }
4535
4536 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4537 {
4538   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4539 }
4540
4541 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4542 {
4543   std::vector<const BigMemoryObject *> ret;
4544   if(getUndergroundDataArray())
4545     ret.push_back(getUndergroundDataArray());
4546   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4547     ret.push_back((const MEDFileFieldPerMesh *)*it);
4548   return ret;
4549 }
4550
4551 /*!
4552  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4553  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4554  * "Sort By Type"), if not, an exception is thrown. 
4555  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4556  *  \param [in] arr - the array of values.
4557  *  \param [in,out] glob - the global data where profiles and localization present in
4558  *          \a field, if any, are added.
4559  *  \throw If the name of \a field is empty.
4560  *  \throw If the data array of \a field is not set.
4561  *  \throw If \a this->_arr is already allocated but has different number of components
4562  *         than \a field.
4563  *  \throw If the underlying mesh of \a field has no name.
4564  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4565  */
4566 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4567 {
4568   const MEDCouplingMesh *mesh=field->getMesh();
4569   //
4570   TypeOfField type=field->getTypeOfField();
4571   std::vector<DataArrayInt *> dummy;
4572   int start=copyTinyInfoFrom(field,arr);
4573   int pos=addNewEntryIfNecessary(mesh);
4574   if(type!=ON_NODES)
4575     {
4576       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4577       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4578     }
4579   else
4580     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4581 }
4582
4583 /*!
4584  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4585  * of a given mesh are used as the support of the given field (a real support is not used). 
4586  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4587  * Order of underlying mesh entities of the given field specified by \a profile parameter
4588  * is not prescribed; this method permutes field values to have them sorted by element
4589  * type as required for writing to MED file. A new profile is added only if no equal
4590  * profile is missing. 
4591  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4592  *  \param [in] arrOfVals - the values of the field \a field used.
4593  *  \param [in] mesh - the supporting mesh of \a field.
4594  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4595  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4596  *  \param [in,out] glob - the global data where profiles and localization present in
4597  *          \a field, if any, are added.
4598  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4599  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4600  *  \throw If the data array of \a field is not set.
4601  *  \throw If \a this->_arr is already allocated but has different number of components
4602  *         than \a field.
4603  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4604  *  \sa setFieldNoProfileSBT()
4605  */
4606 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4607 {
4608   if(!field)
4609     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4610   if(!arrOfVals || !arrOfVals->isAllocated())
4611     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4612   TypeOfField type=field->getTypeOfField();
4613   std::vector<DataArrayInt *> idsInPflPerType;
4614   std::vector<DataArrayInt *> idsPerType;
4615   std::vector<int> code,code2;
4616   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4617   if(type!=ON_NODES)
4618     {
4619       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4620       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4621       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4622       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4623       // start of check
4624       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4625       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4626       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4627         {
4628           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4629           throw INTERP_KERNEL::Exception(oss.str());
4630         }
4631       // end of check
4632       int start=copyTinyInfoFrom(field,arrOfVals);
4633       code2=m->getDistributionOfTypes();
4634       //
4635       int pos=addNewEntryIfNecessary(m);
4636       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4637     }
4638   else
4639     {
4640       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4641         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4642       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4643       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4644       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4645       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4646         {
4647           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4648           throw INTERP_KERNEL::Exception(oss.str());
4649         }
4650       int start=copyTinyInfoFrom(field,arrOfVals);
4651       int pos=addNewEntryIfNecessary(m);
4652       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4653     }
4654 }
4655
4656 /*!
4657  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4658  */
4659 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4660 {
4661   if(_nb_of_tuples_to_be_allocated>=0)
4662     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 !");
4663   DataArray *arr(getOrCreateAndGetArray());
4664   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4665   _nb_of_tuples_to_be_allocated=-3;
4666 }
4667
4668 /*!
4669  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4670  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4671  * larger by the size of \a field. Returns an id of the first not filled
4672  * tuple of \a this->_arr.
4673  *  \param [in] field - the field to copy the info on components and the name from.
4674  *  \return int - the id of first not initialized tuple of \a this->_arr.
4675  *  \throw If the name of \a field is empty.
4676  *  \throw If the data array of \a field is not set.
4677  *  \throw If \a this->_arr is already allocated but has different number of components
4678  *         than \a field.
4679  */
4680 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4681 {
4682   if(!field)
4683     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4684   std::string name(field->getName());
4685   setName(name.c_str());
4686   setDtUnit(field->getTimeUnit());
4687   if(name.empty())
4688     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4689   if(!arr)
4690     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4691   if(!arr->isAllocated())
4692     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4693   _dt=field->getTime(_iteration,_order);
4694   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4695   if(!getOrCreateAndGetArray()->isAllocated())
4696     {
4697       allocNotFromFile(arr->getNumberOfTuples());
4698       return 0;
4699     }
4700   else
4701     {
4702       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4703       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4704       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4705       _nb_of_tuples_to_be_allocated=-3;
4706       return oldNbOfTuples;
4707     }
4708 }
4709
4710 /*!
4711  * Returns number of components in \a this field
4712  *  \return int - the number of components.
4713  */
4714 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4715 {
4716   return getOrCreateAndGetArray()->getNumberOfComponents();
4717 }
4718
4719 /*!
4720  * Change info on components in \a this.
4721  * \throw If size of \a infos is not equal to the number of components already in \a this.
4722  */
4723 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4724 {
4725   DataArray *arr=getOrCreateAndGetArray();
4726   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4727 }
4728
4729 /*!
4730  * Returns info on components of \a this field.
4731  *  \return const std::vector<std::string>& - a sequence of strings each being an
4732  *          information on _i_-th component.
4733  */
4734 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4735 {
4736   const DataArray *arr=getOrCreateAndGetArray();
4737   return arr->getInfoOnComponents();
4738 }
4739
4740 /*!
4741  * Returns a mutable info on components of \a this field.
4742  *  \return std::vector<std::string>& - a sequence of strings each being an
4743  *          information on _i_-th component.
4744  */
4745 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4746 {
4747   DataArray *arr=getOrCreateAndGetArray();
4748   return arr->getInfoOnComponents();
4749 }
4750
4751 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4752 {
4753   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4754     {
4755       const MEDFileFieldPerMesh *fpm(*it);
4756       if(!fpm)
4757         continue;
4758       if(fpm->presenceOfMultiDiscPerGeoType())
4759         return true;
4760     }
4761   return false;
4762 }
4763
4764 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4765 {
4766   static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to extract a field ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
4767   if(_field_per_mesh.empty())
4768     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4769   if(_field_per_mesh.size()>1)
4770     throw INTERP_KERNEL::Exception(MSG0);
4771   if(_field_per_mesh[0].isNull())
4772     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4773   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4774   std::set<TypeOfField> types;
4775   pm->fillTypesOfFieldAvailable(types);
4776   if(types.size()!=1)
4777     throw INTERP_KERNEL::Exception(MSG0);
4778   TypeOfField type(*types.begin());
4779   int meshDimRelToMax(0);
4780   if(type==ON_NODES)
4781     meshDimRelToMax=0;
4782   else
4783     {
4784       int myDim(std::numeric_limits<int>::max());
4785       bool isUnique(pm->isUniqueLevel(myDim));
4786       if(!isUnique)
4787         throw INTERP_KERNEL::Exception(MSG0);
4788       meshDimRelToMax=myDim-mesh->getMeshDimension();
4789       if(meshDimRelToMax>0)
4790         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4791     }
4792   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4793 }
4794
4795 /*!
4796  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4797  *  \param [in] type - a spatial discretization of the new field.
4798  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4799  *  \param [in] mName - a name of the supporting mesh.
4800  *  \param [in] renumPol - specifies how to permute values of the result field according to
4801  *          the optional numbers of cells and nodes, if any. The valid values are
4802  *          - 0 - do not permute.
4803  *          - 1 - permute cells.
4804  *          - 2 - permute nodes.
4805  *          - 3 - permute cells and nodes.
4806  *
4807  *  \param [in] glob - the global data storing profiles and localization.
4808  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4809  *          caller is to delete this field using decrRef() as it is no more needed. 
4810  *  \throw If the MED file is not readable.
4811  *  \throw If there is no mesh named \a mName in the MED file.
4812  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4813  *  \throw If no field of \a this is lying on the mesh \a mName.
4814  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4815  */
4816 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4817 {
4818   MCAuto<MEDFileMesh> mm;
4819   if(mName.empty())
4820     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4821   else
4822     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4823   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4824 }
4825
4826 /*!
4827  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4828  *  \param [in] type - a spatial discretization of the new field.
4829  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4830  *  \param [in] renumPol - specifies how to permute values of the result field according to
4831  *          the optional numbers of cells and nodes, if any. The valid values are
4832  *          - 0 - do not permute.
4833  *          - 1 - permute cells.
4834  *          - 2 - permute nodes.
4835  *          - 3 - permute cells and nodes.
4836  *
4837  *  \param [in] glob - the global data storing profiles and localization.
4838  *  \param [in] mesh - the supporting mesh.
4839  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4840  *          caller is to delete this field using decrRef() as it is no more needed. 
4841  *  \throw If the MED file is not readable.
4842  *  \throw If no field of \a this is lying on \a mesh.
4843  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4844  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4845  */
4846 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4847 {
4848   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4849   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4850   if(meshDimRelToMax==1)
4851     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4852   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4853 }
4854
4855 /*!
4856  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4857  * given mesh. 
4858  *  \param [in] type - a spatial discretization of the new field.
4859  *  \param [in] mName - a name of the supporting mesh.
4860  *  \param [in] renumPol - specifies how to permute values of the result field according to
4861  *          the optional numbers of cells and nodes, if any. The valid values are
4862  *          - 0 - do not permute.
4863  *          - 1 - permute cells.
4864  *          - 2 - permute nodes.
4865  *          - 3 - permute cells and nodes.
4866  *
4867  *  \param [in] glob - the global data storing profiles and localization.
4868  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4869  *          caller is to delete this field using decrRef() as it is no more needed. 
4870  *  \throw If the MED file is not readable.
4871  *  \throw If there is no mesh named \a mName in the MED file.
4872  *  \throw If there are no mesh entities in the mesh.
4873  *  \throw If no field values of the given \a type are available.
4874  */
4875 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4876 {
4877   MCAuto<MEDFileMesh> mm;
4878   if(mName.empty())
4879     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4880   else
4881     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4882   int absDim=getDimension();
4883   int meshDimRelToMax=absDim-mm->getMeshDimension();
4884   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4885 }
4886
4887 /*!
4888  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4889  *  \param [in] type - a spatial discretization of the new field.
4890  *  \param [in] renumPol - specifies how to permute values of the result field according to
4891  *          the optional numbers of cells and nodes, if any. The valid values are
4892  *          - 0 - do not permute.
4893  *          - 1 - permute cells.
4894  *          - 2 - permute nodes.
4895  *          - 3 - permute cells and nodes.
4896  *
4897  *  \param [in] glob - the global data storing profiles and localization.
4898  *  \param [in] mesh - the supporting mesh.
4899  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4900  *         field according to \a renumPol.
4901  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4902  *         field according to \a renumPol.
4903  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4904  *          caller is to delete this field using decrRef() as it is no more needed. 
4905  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4906  *  \throw If no field of \a this is lying on \a mesh.
4907  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4908  */
4909 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
4910 {
4911   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4912   int meshId=getMeshIdFromMeshName(mesh->getName());
4913   bool isPfl=false;
4914   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4915   switch(renumPol)
4916   {
4917     case 0:
4918       {
4919         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4920         return ret.retn();
4921       }
4922     case 3:
4923     case 1:
4924       {
4925         if(isPfl)
4926           throw INTERP_KERNEL::Exception(msg1);
4927         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4928         if(cellRenum)
4929           {
4930             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4931               {
4932                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4933                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4934                 throw INTERP_KERNEL::Exception(oss.str());
4935               }
4936             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4937             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4938             std::vector<DataArray *> arrOut2(1,arrOut);
4939             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4940             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4941             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4942           }
4943         if(renumPol==1)
4944           return ret.retn();
4945       }
4946     case 2:
4947       {
4948         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4949         if(isPfl)
4950           throw INTERP_KERNEL::Exception(msg1);
4951         if(nodeRenum)
4952           {
4953             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4954               {
4955                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4956                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4957                 throw INTERP_KERNEL::Exception(oss.str());
4958               }
4959             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4960             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4961               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4962             ret->renumberNodes(nodeRenumSafe->getConstPointer());
4963           }
4964         return ret.retn();
4965       }
4966     default:
4967       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4968   }
4969 }
4970
4971 /*!
4972  * Returns values and a profile of the field of a given type lying on a given support.
4973  *  \param [in] type - a spatial discretization of the field.
4974  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4975  *  \param [in] mesh - the supporting mesh.
4976  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4977  *          field of interest lies on. If the field lies on all entities of the given
4978  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
4979  *          using decrRef() as it is no more needed.  
4980  *  \param [in] glob - the global data storing profiles and localization.
4981  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4982  *          field. The caller is to delete this array using decrRef() as it is no more needed.
4983  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4984  *  \throw If no field of \a this is lying on \a mesh.
4985  *  \throw If no field values of the given \a type are available.
4986  */
4987 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4988 {
4989   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4990   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4991   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4992   ret->setName(nasc.getName().c_str());
4993   return ret.retn();
4994 }
4995
4996 //= MEDFileField1TSWithoutSDA
4997
4998 /*!
4999  * Throws if a given value is not a valid (non-extended) relative dimension.
5000  *  \param [in] meshDimRelToMax - the relative dimension value.
5001  *  \throw If \a meshDimRelToMax > 0.
5002  */
5003 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5004 {
5005   if(meshDimRelToMax>0)
5006     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5007 }
5008
5009 /*!
5010  * Checks if elements of a given mesh are in the order suitable for writing 
5011  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5012  * vector describing types of elements and their number.
5013  *  \param [in] mesh - the mesh to check.
5014  *  \return std::vector<int> - a vector holding for each element type (1) item of
5015  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5016  *          These values are in full-interlace mode.
5017  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5018  */
5019 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5020 {
5021   if(!mesh)
5022     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5023   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5024   int nbOfTypes=geoTypes.size();
5025   std::vector<int> code(3*nbOfTypes);
5026   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5027   arr1->alloc(nbOfTypes,1);
5028   int *arrPtr=arr1->getPointer();
5029   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5030   for(int i=0;i<nbOfTypes;i++,it++)
5031     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5032   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5033   const int *arrPtr2=arr2->getConstPointer();
5034   int i=0;
5035   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5036     {
5037       int pos=arrPtr2[i];
5038       int nbCells=mesh->getNumberOfCellsWithType(*it);
5039       code[3*pos]=(int)(*it);
5040       code[3*pos+1]=nbCells;
5041       code[3*pos+2]=-1;//no profiles
5042     }
5043   std::vector<const DataArrayInt *> idsPerType;//no profiles
5044   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5045   if(da)
5046     {
5047       da->decrRef();
5048       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5049     }
5050   return code;
5051 }
5052
5053 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5054 {
5055   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5056 }
5057
5058 /*!
5059  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5060  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5061  * item of every of returned sequences refers to the _i_-th part of \a this field.
5062  * Thus all sequences returned by this method are of the same length equal to number
5063  * of different types of supporting entities.<br>
5064  * A field part can include sub-parts with several different spatial discretizations,
5065  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5066  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5067  * of a nested sequence corresponds to a type of spatial discretization.<br>
5068  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5069  * The overhead is due to selecting values into new instances of DataArrayDouble.
5070  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5071  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5072  *          not checked if \a mname == \c NULL).
5073  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5074  *          a field part is returned. 
5075  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5076  *          A field part can include sub-parts with several different spatial discretizations,
5077  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5078  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5079  *          This sequence is of the same length as \a types. 
5080  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5081  *          discretization. A profile name can be empty.
5082  *          Length of this and of nested sequences is the same as that of \a typesF.
5083  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5084  *          discretization. A localization name can be empty.
5085  *          Length of this and of nested sequences is the same as that of \a typesF.
5086  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5087  *          per each type of spatial discretization within one mesh entity type.
5088  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5089  *          Length of this and of nested sequences is the same as that of \a typesF.
5090  *  \throw If no field is lying on \a mname.
5091  */
5092 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
5093 {
5094   int meshId=0;
5095   if(!mname.empty())
5096     meshId=getMeshIdFromMeshName(mname);
5097   else
5098     if(_field_per_mesh.empty())
5099       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5100   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5101   int nbOfRet=ret0.size();
5102   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5103   for(int i=0;i<nbOfRet;i++)
5104     {
5105       const std::vector< std::pair<int,int> >& p=ret0[i];
5106       int nbOfRet1=p.size();
5107       ret[i].resize(nbOfRet1);
5108       for(int j=0;j<nbOfRet1;j++)
5109         {
5110           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5111           ret[i][j]=tmp;
5112         }
5113     }
5114   return ret;
5115 }
5116
5117 /*!
5118  * Returns a pointer to the underground DataArrayDouble instance. So the
5119  * caller should not decrRef() it. This method allows for a direct access to the field
5120  * values. This method is quite unusable if there is more than a nodal field or a cell
5121  * field on single geometric cell type. 
5122  *  \return DataArrayDouble * - the pointer to the field values array.
5123  */
5124 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5125 {
5126   const DataArrayDouble *ret=_arr;
5127   if(ret)
5128     return const_cast<DataArrayDouble *>(ret);
5129   else
5130     return 0;
5131 }
5132
5133 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5134 {
5135   return TYPE_STR;
5136 }
5137
5138 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5139 {
5140   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5141   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5142   ret->deepCpyLeavesFrom(*this);
5143   const DataArrayDouble *arr(_arr);
5144   if(arr)
5145     {
5146       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5147       ret->setArray(arr2);
5148     }
5149   return ret.retn();
5150 }
5151
5152 /*!
5153  * Returns a pointer to the underground DataArrayDouble instance. So the
5154  * caller should not decrRef() it. This method allows for a direct access to the field
5155  * values. This method is quite unusable if there is more than a nodal field or a cell
5156  * field on single geometric cell type. 
5157  *  \return DataArrayDouble * - the pointer to the field values array.
5158  */
5159 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5160 {
5161   return getUndergroundDataArrayDouble();
5162 }
5163
5164 /*!
5165  * Returns a pointer to the underground DataArrayDouble instance and a
5166  * sequence describing parameters of a support of each part of \a this field. The
5167  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5168  * direct access to the field values. This method is intended for the field lying on one
5169  * mesh only.
5170  *  \param [in,out] entries - the sequence describing parameters of a support of each
5171  *         part of \a this field. Each item of this sequence consists of two parts. The
5172  *         first part describes a type of mesh entity and an id of discretization of a
5173  *         current field part. The second part describes a range of values [begin,end)
5174  *         within the returned array relating to the current field part.
5175  *  \return DataArrayDouble * - the pointer to the field values array.
5176  *  \throw If the number of underlying meshes is not equal to 1.
5177  *  \throw If no field values are available.
5178  *  \sa getUndergroundDataArray()
5179  */
5180 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5181 {
5182   if(_field_per_mesh.size()!=1)
5183     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5184   if(_field_per_mesh[0]==0)
5185     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5186   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5187   return getUndergroundDataArrayDouble();
5188 }
5189
5190 /*!
5191  * Returns a pointer to the underground DataArrayDouble instance and a
5192  * sequence describing parameters of a support of each part of \a this field. The
5193  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5194  * direct access to the field values. This method is intended for the field lying on one
5195  * mesh only.
5196  *  \param [in,out] entries - the sequence describing parameters of a support of each
5197  *         part of \a this field. Each item of this sequence consists of two parts. The
5198  *         first part describes a type of mesh entity and an id of discretization of a
5199  *         current field part. The second part describes a range of values [begin,end)
5200  *         within the returned array relating to the current field part.
5201  *  \return DataArrayDouble * - the pointer to the field values array.
5202  *  \throw If the number of underlying meshes is not equal to 1.
5203  *  \throw If no field values are available.
5204  *  \sa getUndergroundDataArray()
5205  */
5206 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5207 {
5208   return getUndergroundDataArrayDoubleExt(entries);
5209 }
5210
5211 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5212 {
5213   DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5214   arr->setInfoAndChangeNbOfCompo(infos);
5215 }
5216
5217 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5218 {
5219 }
5220
5221 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5222 {
5223   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5224   ret->deepCpyLeavesFrom(*this);
5225   return ret.retn();
5226 }
5227
5228 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5229 {
5230   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5231   if((const DataArrayDouble *)_arr)
5232     ret->_arr=_arr->deepCopy();
5233   return ret.retn();
5234 }
5235
5236 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5237 {
5238   if(!arr)
5239     {
5240       _nb_of_tuples_to_be_allocated=-1;
5241       _arr=0;
5242       return ;
5243     }
5244   DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5245   if(!arrC)
5246     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5247   else
5248     _nb_of_tuples_to_be_allocated=-3;
5249   arrC->incrRef();
5250   _arr=arrC;
5251 }
5252
5253 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5254 {
5255   return DataArrayDouble::New();
5256 }
5257
5258 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5259 {
5260   DataArrayDouble *ret=_arr;
5261   if(ret)
5262     return ret;
5263   _arr=DataArrayDouble::New();
5264   return _arr;
5265 }
5266
5267 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5268 {
5269   return getOrCreateAndGetArrayDouble();
5270 }
5271
5272 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5273 {
5274   const DataArrayDouble *ret=_arr;
5275   if(ret)
5276     return ret;
5277   DataArrayDouble *ret2=DataArrayDouble::New();
5278   const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5279   return ret2;
5280 }
5281
5282 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5283 {
5284   return getOrCreateAndGetArrayDouble();
5285 }
5286
5287 //= MEDFileIntField1TSWithoutSDA
5288
5289 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5290 {
5291   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5292 }
5293
5294 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5295 {
5296 }
5297
5298 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5299                                                            const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5300 {
5301   DataArrayInt *arr(getOrCreateAndGetArrayInt());
5302   arr->setInfoAndChangeNbOfCompo(infos);
5303 }
5304
5305 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5306 {
5307   return TYPE_STR;
5308 }
5309
5310 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5311 {
5312   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5313   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5314   ret->deepCpyLeavesFrom(*this);
5315   const DataArrayInt *arr(_arr);
5316   if(arr)
5317     {
5318       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5319       ret->setArray(arr2);
5320     }
5321   return ret.retn();
5322 }
5323
5324 /*!
5325  * Returns a pointer to the underground DataArrayInt instance. So the
5326  * caller should not decrRef() it. This method allows for a direct access to the field
5327  * values. This method is quite unusable if there is more than a nodal field or a cell
5328  * field on single geometric cell type. 
5329  *  \return DataArrayInt * - the pointer to the field values array.
5330  */
5331 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5332 {
5333   return getUndergroundDataArrayInt();
5334 }
5335
5336 /*!
5337  * Returns a pointer to the underground DataArrayInt instance. So the
5338  * caller should not decrRef() it. This method allows for a direct access to the field
5339  * values. This method is quite unusable if there is more than a nodal field or a cell
5340  * field on single geometric cell type. 
5341  *  \return DataArrayInt * - the pointer to the field values array.
5342  */
5343 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5344 {
5345   const DataArrayInt *ret=_arr;
5346   if(ret)
5347     return const_cast<DataArrayInt *>(ret);
5348   else
5349     return 0;
5350 }
5351
5352 /*!
5353  * Returns a pointer to the underground DataArrayInt instance and a
5354  * sequence describing parameters of a support of each part of \a this field. The
5355  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5356  * direct access to the field values. This method is intended for the field lying on one
5357  * mesh only.
5358  *  \param [in,out] entries - the sequence describing parameters of a support of each
5359  *         part of \a this field. Each item of this sequence consists of two parts. The
5360  *         first part describes a type of mesh entity and an id of discretization of a
5361  *         current field part. The second part describes a range of values [begin,end)
5362  *         within the returned array relating to the current field part.
5363  *  \return DataArrayInt * - the pointer to the field values array.
5364  *  \throw If the number of underlying meshes is not equal to 1.
5365  *  \throw If no field values are available.
5366  *  \sa getUndergroundDataArray()
5367  */
5368 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5369 {
5370   return getUndergroundDataArrayIntExt(entries);
5371 }
5372
5373 /*!
5374  * Returns a pointer to the underground DataArrayInt instance and a
5375  * sequence describing parameters of a support of each part of \a this field. The
5376  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5377  * direct access to the field values. This method is intended for the field lying on one
5378  * mesh only.
5379  *  \param [in,out] entries - the sequence describing parameters of a support of each
5380  *         part of \a this field. Each item of this sequence consists of two parts. The
5381  *         first part describes a type of mesh entity and an id of discretization of a
5382  *         current field part. The second part describes a range of values [begin,end)
5383  *         within the returned array relating to the current field part.
5384  *  \return DataArrayInt * - the pointer to the field values array.
5385  *  \throw If the number of underlying meshes is not equal to 1.
5386  *  \throw If no field values are available.
5387  *  \sa getUndergroundDataArray()
5388  */
5389 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5390 {
5391   if(_field_per_mesh.size()!=1)
5392     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5393   if(_field_per_mesh[0]==0)
5394     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5395   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5396   return getUndergroundDataArrayInt();
5397 }
5398
5399 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5400 {
5401   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5402   ret->deepCpyLeavesFrom(*this);
5403   return ret.retn();
5404 }
5405
5406 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5407 {
5408   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5409   if((const DataArrayInt *)_arr)
5410     ret->_arr=_arr->deepCopy();
5411   return ret.retn();
5412 }
5413
5414 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5415 {
5416   if(!arr)
5417     {
5418       _nb_of_tuples_to_be_allocated=-1;
5419       _arr=0;
5420       return ;
5421     }
5422   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5423   if(!arrC)
5424     throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5425   else
5426     _nb_of_tuples_to_be_allocated=-3;
5427   arrC->incrRef();
5428   _arr=arrC;
5429 }
5430
5431 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5432 {
5433   return DataArrayInt::New();
5434 }
5435
5436 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5437 {
5438   DataArrayInt *ret=_arr;
5439   if(ret)
5440     return ret;
5441   _arr=DataArrayInt::New();
5442   return _arr;
5443 }
5444
5445 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5446 {
5447   return getOrCreateAndGetArrayInt();
5448 }
5449
5450 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5451 {
5452   const DataArrayInt *ret=_arr;
5453   if(ret)
5454     return ret;
5455   DataArrayInt *ret2=DataArrayInt::New();
5456   const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5457   return ret2;
5458 }
5459
5460 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5461 {
5462   return getOrCreateAndGetArrayInt();
5463 }
5464
5465 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5466 {
5467 }
5468
5469 //= MEDFileAnyTypeField1TS
5470
5471 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5472 {
5473   med_field_type typcha;
5474   //
5475   std::vector<std::string> infos;
5476   std::string dtunit,fieldName;
5477   LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5478   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5479   switch(typcha)
5480   {
5481     case MED_FLOAT64:
5482       {
5483         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5484         break;
5485       }
5486     case MED_INT32:
5487       {
5488         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5489         break;
5490       }
5491     default:
5492       {
5493         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5494         throw INTERP_KERNEL::Exception(oss.str());
5495       }
5496   }
5497   ret->setDtUnit(dtunit.c_str());
5498   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5499   //
5500   med_int numdt,numit;
5501   med_float dt;
5502   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5503   ret->setTime(numdt,numit,dt);
5504   ret->_csit=1;
5505   if(loadAll)
5506     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5507   else
5508     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5509   return ret.retn();
5510 }
5511
5512 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5513 try:MEDFileFieldGlobsReal(fileName)
5514 {
5515   MEDFileUtilities::CheckFileForRead(fileName);
5516   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5517   _content=BuildContentFrom(fid,fileName,loadAll,ms);
5518   loadGlobals(fid);
5519 }
5520 catch(INTERP_KERNEL::Exception& e)
5521 {
5522     throw e;
5523 }
5524
5525 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5526 {
5527   med_field_type typcha;
5528   std::vector<std::string> infos;
5529   std::string dtunit;
5530   int iii=-1;
5531   int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5532   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5533   switch(typcha)
5534   {
5535     case MED_FLOAT64:
5536       {
5537         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5538         break;
5539       }
5540     case MED_INT32:
5541       {
5542         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5543         break;
5544       }
5545     default:
5546       {
5547         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5548         throw INTERP_KERNEL::Exception(oss.str());
5549       }
5550   }
5551   ret->setDtUnit(dtunit.c_str());
5552   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5553   //
5554   if(nbSteps<1)
5555     {
5556       std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5557       throw INTERP_KERNEL::Exception(oss.str());
5558     }
5559   //
5560   med_int numdt,numit;
5561   med_float dt;
5562   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5563   ret->setTime(numdt,numit,dt);
5564   ret->_csit=1;
5565   if(loadAll)
5566     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5567   else
5568     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5569   return ret.retn();
5570 }
5571
5572 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5573 try:MEDFileFieldGlobsReal(fileName)
5574 {
5575   MEDFileUtilities::CheckFileForRead(fileName);
5576   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5577   _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5578   loadGlobals(fid);
5579 }
5580 catch(INTERP_KERNEL::Exception& e)
5581 {
5582     throw e;
5583 }
5584
5585 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5586 {
5587   if(!c)
5588     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5589   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5590     {
5591       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5592       ret->setFileName(fileName);
5593       ret->_content=c; c->incrRef();
5594       return ret.retn();
5595     }
5596   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5597     {
5598       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5599       ret->setFileName(fileName);
5600       ret->_content=c; c->incrRef();
5601       return ret.retn();
5602     }
5603   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5604 }
5605
5606 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5607 {
5608   MEDFileUtilities::CheckFileForRead(fileName);
5609   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5610   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5611   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5612   ret->loadGlobals(fid);
5613   return ret.retn();
5614 }
5615
5616 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5617 {
5618   MEDFileUtilities::CheckFileForRead(fileName);
5619   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5620   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5621   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5622   ret->loadGlobals(fid);
5623   return ret.retn();
5624 }
5625
5626 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5627 {
5628   MEDFileUtilities::CheckFileForRead(fileName);
5629   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5630   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5631   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5632   ret->loadGlobals(fid);
5633   return ret.retn();
5634 }
5635
5636 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5637 {
5638   med_field_type typcha;
5639   std::vector<std::string> infos;
5640   std::string dtunit;
5641   int iii=-1;
5642   int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5643   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5644   switch(typcha)
5645   {
5646     case MED_FLOAT64:
5647       {
5648         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5649         break;
5650       }
5651     case MED_INT32:
5652       {
5653         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5654         break;
5655       }
5656     default:
5657       {
5658         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5659         throw INTERP_KERNEL::Exception(oss.str());
5660       }
5661   }
5662   ret->setDtUnit(dtunit.c_str());
5663   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5664   //
5665   bool found=false;
5666   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5667   for(int i=0;i<nbOfStep2 && !found;i++)
5668     {
5669       med_int numdt,numit;
5670       med_float dt;
5671       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5672       if(numdt==iteration && numit==order)
5673         {
5674           found=true;
5675           ret->_csit=i+1;
5676         }
5677       else
5678         dtits[i]=std::pair<int,int>(numdt,numit);
5679     }
5680   if(!found)
5681     {
5682       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5683       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5684         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5685       throw INTERP_KERNEL::Exception(oss.str());
5686     }
5687   if(loadAll)
5688     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5689   else
5690     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5691   return ret.retn();
5692 }
5693
5694 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5695 try:MEDFileFieldGlobsReal(fileName)
5696 {
5697   MEDFileUtilities::CheckFileForRead(fileName);
5698   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5699   _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5700   loadGlobals(fid);
5701 }
5702 catch(INTERP_KERNEL::Exception& e)
5703 {
5704     throw e;
5705 }
5706
5707 /*!
5708  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5709  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5710  *
5711  * \warning this is a shallow copy constructor
5712  */
5713 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5714 {
5715   if(!shallowCopyOfContent)
5716     {
5717       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5718       otherPtr->incrRef();
5719       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5720     }
5721   else
5722     {
5723       _content=other.shallowCpy();
5724     }
5725 }
5726
5727 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5728 {
5729   if(checkFieldId)
5730     {
5731       int nbFields=MEDnField(fid);
5732       if(fieldIdCFormat>=nbFields)
5733         {
5734           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5735           throw INTERP_KERNEL::Exception(oss.str());
5736         }
5737     }
5738   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5739   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5740   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5741   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5742   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5743   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5744   med_bool localMesh;
5745   int nbOfStep;
5746   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5747   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5748   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5749   infos.clear(); infos.resize(ncomp);
5750   for(int j=0;j<ncomp;j++)
5751     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5752   return nbOfStep;
5753 }
5754
5755 /*!
5756  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5757  * 
5758  * \param [out]
5759  * \return in case of success the number of time steps available for the field with name \a fieldName.
5760  */
5761 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5762 {
5763   int nbFields=MEDnField(fid);
5764   bool found=false;
5765   std::vector<std::string> fns(nbFields);
5766   int nbOfStep2=-1;
5767   for(int i=0;i<nbFields && !found;i++)
5768     {
5769       std::string tmp;
5770       nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5771       fns[i]=tmp;
5772       found=(tmp==fieldName);
5773       if(found)
5774         posCFormat=i;
5775     }
5776   if(!found)
5777     {
5778       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5779       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5780         oss << "\"" << *it << "\" ";
5781       throw INTERP_KERNEL::Exception(oss.str());
5782     }
5783   return nbOfStep2;
5784 }
5785
5786 /*!
5787  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5788  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5789  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5790  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5791  * to keep a valid instance.
5792  * 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.
5793  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5794  * 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.
5795  *
5796  * \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.
5797  * \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.
5798  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5799  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5800  * \param [in] newLocName is the new localization name.
5801  * \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.
5802  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5803  */
5804 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5805 {
5806   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5807   std::string oldPflName=disc->getProfile();
5808   std::vector<std::string> vv=getPflsReallyUsedMulti();
5809   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5810   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5811     {
5812       disc->setProfile(newPflName);
5813       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5814       pfl->setName(newPflName);
5815     }
5816   else
5817     {
5818       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5819       throw INTERP_KERNEL::Exception(oss.str());
5820     }
5821 }
5822
5823 /*!
5824  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5825  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5826  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5827  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5828  * to keep a valid instance.
5829  * 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.
5830  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5831  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5832  * 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.
5833  *
5834  * \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.
5835  * \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.
5836  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5837  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5838  * \param [in] newLocName is the new localization name.
5839  * \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.
5840  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5841  */
5842 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5843 {
5844   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5845   std::string oldLocName=disc->getLocalization();
5846   std::vector<std::string> vv=getLocsReallyUsedMulti();
5847   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5848   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5849     {
5850       disc->setLocalization(newLocName);
5851       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5852       loc.setName(newLocName);
5853     }
5854   else
5855     {
5856       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5857       throw INTERP_KERNEL::Exception(oss.str());
5858     }
5859 }
5860
5861 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5862 {
5863   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5864   if(!ret)
5865     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5866   return ret;
5867 }
5868
5869 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5870 {
5871   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5872   if(!ret)
5873     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5874   return ret;
5875 }
5876
5877 /*!
5878  * Writes \a this field into a MED file specified by its name.
5879  *  \param [in] fileName - the MED file name.
5880  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5881  * - 2 - erase; an existing file is removed.
5882  * - 1 - append; same data should not be present in an existing file.
5883  * - 0 - overwrite; same data present in an existing file is overwritten.
5884  *  \throw If the field name is not set.
5885  *  \throw If no field data is set.
5886  *  \throw If \a mode == 1 and the same data is present in an existing file.
5887  */
5888 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5889 {
5890   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5891   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5892   writeLL(fid);
5893 }
5894
5895 /*!
5896  * This method alloc the arrays and load potentially huge arrays contained in this field.
5897  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5898  * This method can be also called to refresh or reinit values from a file.
5899  * 
5900  * \throw If the fileName is not set or points to a non readable MED file.
5901  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5902  */
5903 void MEDFileAnyTypeField1TS::loadArrays()
5904 {
5905   if(getFileName().empty())
5906     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5907   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5908   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5909 }
5910
5911 /*!
5912  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5913  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5914  * this method does not throw if \a this does not come from file read.
5915  * 
5916  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5917  */
5918 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5919 {
5920   if(!getFileName().empty())
5921     {
5922       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5923       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5924     }
5925 }
5926
5927 /*!
5928  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5929  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5930  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5931  * 
5932  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5933  */
5934 void MEDFileAnyTypeField1TS::unloadArrays()
5935 {
5936   contentNotNullBase()->unloadArrays();
5937 }
5938
5939 /*!
5940  * 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.
5941  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5942  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5943  * 
5944  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5945  */
5946 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5947 {
5948   if(!getFileName().empty())
5949     contentNotNullBase()->unloadArrays();
5950 }
5951
5952 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5953 {
5954   int nbComp=getNumberOfComponents();
5955   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5956   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5957   for(int i=0;i<nbComp;i++)
5958     {
5959       std::string info=getInfo()[i];
5960       std::string c,u;
5961       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5962       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5963       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5964     }
5965   if(getName().empty())
5966     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5967   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5968   writeGlobals(fid,*this);
5969   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5970 }
5971
5972 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5973 {
5974   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5975 }
5976
5977 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5978 {
5979   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5980   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5981   return ret;
5982 }
5983
5984 /*!
5985  * Returns a string describing \a this field. This string is outputted 
5986  * by \c print Python command.
5987  */
5988 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5989 {
5990   std::ostringstream oss;
5991   contentNotNullBase()->simpleRepr(0,oss,-1);
5992   simpleReprGlobs(oss);
5993   return oss.str();
5994 }
5995
5996 /*!
5997  * This method returns all profiles whose name is non empty used.
5998  * \b WARNING If profile is used several times it will be reported \b only \b once.
5999  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6000  */
6001 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6002 {
6003   return contentNotNullBase()->getPflsReallyUsed2();
6004 }
6005
6006 /*!
6007  * This method returns all localizations whose name is non empty used.
6008  * \b WARNING If localization is used several times it will be reported \b only \b once.
6009  */
6010 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6011 {
6012   return contentNotNullBase()->getLocsReallyUsed2();
6013 }
6014
6015 /*!
6016  * This method returns all profiles whose name is non empty used.
6017  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6018  */
6019 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6020 {
6021   return contentNotNullBase()->getPflsReallyUsedMulti2();
6022 }
6023
6024 /*!
6025  * This method returns all localizations whose name is non empty used.
6026  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6027  */
6028 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6029 {
6030   return contentNotNullBase()->getLocsReallyUsedMulti2();
6031 }
6032
6033 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6034 {
6035   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6036 }
6037
6038 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6039 {
6040   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6041 }
6042
6043 int MEDFileAnyTypeField1TS::getDimension() const
6044 {
6045   return contentNotNullBase()->getDimension();
6046 }
6047
6048 int MEDFileAnyTypeField1TS::getIteration() const
6049 {
6050   return contentNotNullBase()->getIteration();
6051 }
6052
6053 int MEDFileAnyTypeField1TS::getOrder() const
6054 {
6055   return contentNotNullBase()->getOrder();
6056 }
6057
6058 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6059 {
6060   return contentNotNullBase()->getTime(iteration,order);
6061 }
6062
6063 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6064 {
6065   contentNotNullBase()->setTime(iteration,order,val);
6066 }
6067
6068 std::string MEDFileAnyTypeField1TS::getName() const
6069 {
6070   return contentNotNullBase()->getName();
6071 }
6072
6073 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6074 {
6075   contentNotNullBase()->setName(name);
6076 }
6077
6078 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6079 {
6080   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6081 }
6082
6083 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6084 {
6085   return contentNotNullBase()->getDtUnit();
6086 }
6087
6088 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6089 {
6090   contentNotNullBase()->setDtUnit(dtUnit);
6091 }
6092
6093 std::string MEDFileAnyTypeField1TS::getMeshName() const
6094 {
6095   return contentNotNullBase()->getMeshName();
6096 }
6097
6098 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6099 {
6100   contentNotNullBase()->setMeshName(newMeshName);
6101 }
6102
6103 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6104 {
6105   return contentNotNullBase()->changeMeshNames(modifTab);
6106 }
6107
6108 int MEDFileAnyTypeField1TS::getMeshIteration() const
6109 {
6110   return contentNotNullBase()->getMeshIteration();
6111 }
6112
6113 int MEDFileAnyTypeField1TS::getMeshOrder() const
6114 {
6115   return contentNotNullBase()->getMeshOrder();
6116 }
6117
6118 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6119 {
6120   return contentNotNullBase()->getNumberOfComponents();
6121 }
6122
6123 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6124 {
6125   return contentNotNullBase()->isDealingTS(iteration,order);
6126 }
6127
6128 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6129 {
6130   return contentNotNullBase()->getDtIt();
6131 }
6132
6133 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6134 {
6135   contentNotNullBase()->fillIteration(p);
6136 }
6137
6138 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6139 {
6140   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6141 }
6142
6143 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6144 {
6145   contentNotNullBase()->setInfo(infos);
6146 }
6147
6148 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6149 {
6150   return contentNotNullBase()->getInfo();
6151 }
6152 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6153 {
6154   return contentNotNullBase()->getInfo();
6155 }
6156
6157 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6158 {
6159   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6160 }
6161
6162 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6163 {
6164   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6165 }
6166
6167 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6168 {
6169   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6170 }
6171
6172 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6173 {
6174   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6175 }
6176
6177 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6178 {
6179   return contentNotNullBase()->getTypesOfFieldAvailable();
6180 }
6181
6182 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,
6183                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6184 {
6185   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6186 }
6187
6188 /*!
6189  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6190  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6191  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6192  */
6193 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6194 {
6195   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6196   if(!content)
6197     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6198   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6199   std::size_t sz(contentsSplit.size());
6200   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6201   for(std::size_t i=0;i<sz;i++)
6202     {
6203       ret[i]=shallowCpy();
6204       ret[i]->_content=contentsSplit[i];
6205     }
6206   return ret;
6207 }
6208
6209 /*!
6210  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6211  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6212  */
6213 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6214 {
6215   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6216   if(!content)
6217     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6218   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6219   std::size_t sz(contentsSplit.size());
6220   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6221   for(std::size_t i=0;i<sz;i++)
6222     {
6223       ret[i]=shallowCpy();
6224       ret[i]->_content=contentsSplit[i];
6225     }
6226   return ret;
6227 }
6228
6229 /*!
6230  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6231  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6232  */
6233 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6234 {
6235   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6236   if(!content)
6237     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6238   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6239   std::size_t sz(contentsSplit.size());
6240   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6241   for(std::size_t i=0;i<sz;i++)
6242     {
6243       ret[i]=shallowCpy();
6244       ret[i]->_content=contentsSplit[i];
6245     }
6246   return ret;
6247 }
6248
6249 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6250 {
6251   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6252   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6253     ret->_content=_content->deepCopy();
6254   ret->deepCpyGlobs(*this);
6255   return ret.retn();
6256 }
6257
6258 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6259 {
6260   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6261 }
6262
6263 //= MEDFileField1TS
6264
6265 /*!
6266  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6267  * the first field that has been read from a specified MED file.
6268  *  \param [in] fileName - the name of the MED file to read.
6269  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6270  *          is to delete this field using decrRef() as it is no more needed.
6271  *  \throw If reading the file fails.
6272  */
6273 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6274 {
6275   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6276   ret->contentNotNull();
6277   return ret.retn();
6278 }
6279
6280 /*!
6281  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6282  * a given field that has been read from a specified MED file.
6283  *  \param [in] fileName - the name of the MED file to read.
6284  *  \param [in] fieldName - the name of the field to read.
6285  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6286  *          is to delete this field using decrRef() as it is no more needed.
6287  *  \throw If reading the file fails.
6288  *  \throw If there is no field named \a fieldName in the file.
6289  */
6290 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6291 {
6292   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6293   ret->contentNotNull();
6294   return ret.retn();
6295 }
6296
6297 /*!
6298  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6299  * a given field that has been read from a specified MED file.
6300  *  \param [in] fileName - the name of the MED file to read.
6301  *  \param [in] fieldName - the name of the field to read.
6302  *  \param [in] iteration - the iteration number of a required time step.
6303  *  \param [in] order - the iteration order number of required time step.
6304  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6305  *          is to delete this field using decrRef() as it is no more needed.
6306  *  \throw If reading the file fails.
6307  *  \throw If there is no field named \a fieldName in the file.
6308  *  \throw If the required time step is missing from the file.
6309  */
6310 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6311 {
6312   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6313   ret->contentNotNull();
6314   return ret.retn();
6315 }
6316
6317 /*!
6318  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6319  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6320  *
6321  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6322  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6323  * \warning this is a shallow copy constructor
6324  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6325  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6326  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6327  *          is to delete this field using decrRef() as it is no more needed.
6328  */
6329 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6330 {
6331   MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6332   ret->contentNotNull();
6333   return ret.retn();
6334 }
6335
6336 /*!
6337  * Returns a new empty instance of MEDFileField1TS.
6338  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6339  *          is to delete this field using decrRef() as it is no more needed.
6340  */
6341 MEDFileField1TS *MEDFileField1TS::New()
6342 {
6343   MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6344   ret->contentNotNull();
6345   return ret.retn();
6346 }
6347
6348 /*!
6349  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6350  * following the given input policy.
6351  *
6352  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6353  *                            By default (true) the globals are deeply copied.
6354  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6355  */
6356 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6357 {
6358   MCAuto<MEDFileIntField1TS> ret;
6359   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6360   if(content)
6361     {
6362       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6363       if(!contc)
6364         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6365       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6366       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6367     }
6368   else
6369     ret=MEDFileIntField1TS::New();
6370   if(isDeepCpyGlobs)
6371     ret->deepCpyGlobs(*this);
6372   else
6373     ret->shallowCpyGlobs(*this);
6374   return ret.retn();
6375 }
6376
6377 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6378 {
6379   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6380   if(!pt)
6381     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6382   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6383   if(!ret)
6384     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 !");
6385   return ret;
6386 }
6387
6388 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6389 {
6390   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6391   if(!pt)
6392     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6393   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6394   if(!ret)
6395     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 !");
6396   return ret;
6397 }
6398
6399 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6400 {
6401   if(!f)
6402     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6403   if(arr.isNull())
6404     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6405   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6406   if(!arrOutC)
6407     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6408   f->setArray(arrOutC);
6409 }
6410
6411 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6412 {
6413   if(arr.isNull())
6414     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6415   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6416   if(!arrOutC)
6417     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6418   arrOutC->incrRef();
6419   return arrOutC;
6420 }
6421
6422 /*!
6423  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6424  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6425  *
6426  * \return A new object that the caller is responsible to deallocate.
6427  */
6428 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6429 {
6430   if(!mm)
6431     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6432   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6433   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6434   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6435     {
6436       if((*it0)!=ON_NODES)
6437         {
6438           std::vector<int> levs;
6439           getNonEmptyLevels(mm->getName(),levs);
6440           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6441             {
6442               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6443               if(it2!=extractDef.end())
6444                 {
6445                   MCAuto<DataArrayInt> t((*it2).second);
6446                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6447                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6448                   ret->setFieldNoProfileSBT(fOut);
6449                 }
6450             }
6451         }
6452       else
6453         {
6454           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6455           if(it2==extractDef.end())
6456             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6457           MCAuto<DataArrayInt> t((*it2).second);
6458           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6459           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6460           DataArrayDouble *arr(f->getArray());
6461           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6462           fOut->setArray(newArr);
6463           ret->setFieldNoProfileSBT(fOut);
6464         }
6465     }
6466   return ret.retn();
6467 }
6468
6469 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6470 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6471 {
6472 }
6473 catch(INTERP_KERNEL::Exception& e)
6474 { throw e; }
6475
6476 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6477 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6478 {
6479 }
6480 catch(INTERP_KERNEL::Exception& e)
6481 { throw e; }
6482
6483 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6484 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6485 {
6486 }
6487 catch(INTERP_KERNEL::Exception& e)
6488 { throw e; }
6489
6490 /*!
6491  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6492  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6493  *
6494  * \warning this is a shallow copy constructor
6495  */
6496 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6497 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6498 {
6499 }
6500 catch(INTERP_KERNEL::Exception& e)
6501 { throw e; }
6502
6503 MEDFileField1TS::MEDFileField1TS()
6504 {
6505   _content=new MEDFileField1TSWithoutSDA;
6506 }
6507
6508 /*!
6509  * 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
6510  * method should be called (getFieldOnMeshAtLevel for example).
6511  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6512  *
6513  * \param [in] mesh - the mesh the field is lying on
6514  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6515  *          caller is to delete this field using decrRef() as it is no more needed. 
6516  */
6517 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6518 {
6519   MCAuto<DataArray> arrOut;
6520   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6521   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6522   return ret.retn();
6523 }
6524
6525 /*!
6526  * Returns a new MEDCouplingFieldDouble of a given type lying on
6527  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6528  * has not been constructed via file reading, an exception is thrown.
6529  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6530  *  \param [in] type - a spatial discretization of interest.
6531  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6532  *  \param [in] renumPol - specifies how to permute values of the result field according to
6533  *          the optional numbers of cells and nodes, if any. The valid values are
6534  *          - 0 - do not permute.
6535  *          - 1 - permute cells.
6536  *          - 2 - permute nodes.
6537  *          - 3 - permute cells and nodes.
6538  *
6539  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6540  *          caller is to delete this field using decrRef() as it is no more needed. 
6541  *  \throw If \a this field has not been constructed via file reading.
6542  *  \throw If the MED file is not readable.
6543  *  \throw If there is no mesh in the MED file.
6544  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6545  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6546  *  \sa getFieldOnMeshAtLevel()
6547  */
6548 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6549 {
6550   if(getFileName().empty())
6551     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6552   MCAuto<DataArray> arrOut;
6553   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6554   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6555   return ret.retn();
6556 }
6557
6558 /*!
6559  * Returns a new MEDCouplingFieldDouble of a given type lying on
6560  * the top level cells of the first mesh in MED file. If \a this field 
6561  * has not been constructed via file reading, an exception is thrown.
6562  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6563  *  \param [in] type - a spatial discretization of interest.
6564  *  \param [in] renumPol - specifies how to permute values of the result field according to
6565  *          the optional numbers of cells and nodes, if any. The valid values are
6566  *          - 0 - do not permute.
6567  *          - 1 - permute cells.
6568  *          - 2 - permute nodes.
6569  *          - 3 - permute cells and nodes.
6570  *
6571  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6572  *          caller is to delete this field using decrRef() as it is no more needed. 
6573  *  \throw If \a this field has not been constructed via file reading.
6574  *  \throw If the MED file is not readable.
6575  *  \throw If there is no mesh in the MED file.
6576  *  \throw If no field values of the given \a type.
6577  *  \throw If no field values lying on the top level support.
6578  *  \sa getFieldAtLevel()
6579  */
6580 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6581 {
6582   if(getFileName().empty())
6583     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6584   MCAuto<DataArray> arrOut;
6585   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6586   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6587   return ret.retn();
6588 }
6589
6590 /*!
6591  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6592  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6593  *  \param [in] type - a spatial discretization of the new field.
6594  *  \param [in] mesh - the supporting mesh.
6595  *  \param [in] renumPol - specifies how to permute values of the result field according to
6596  *          the optional numbers of cells and nodes, if any. The valid values are
6597  *          - 0 - do not permute.
6598  *          - 1 - permute cells.
6599  *          - 2 - permute nodes.
6600  *          - 3 - permute cells and nodes.
6601  *
6602  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6603  *          caller is to delete this field using decrRef() as it is no more needed. 
6604  *  \throw If no field of \a this is lying on \a mesh.
6605  *  \throw If the mesh is empty.
6606  *  \throw If no field values of the given \a type are available.
6607  *  \sa getFieldAtLevel()
6608  *  \sa getFieldOnMeshAtLevel() 
6609  */
6610 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6611 {
6612   MCAuto<DataArray> arrOut;
6613   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6614   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6615   return ret.retn();
6616 }
6617
6618 /*!
6619  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6620  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6621  *  \param [in] type - a spatial discretization of interest.
6622  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6623  *  \param [in] mesh - the supporting mesh.
6624  *  \param [in] renumPol - specifies how to permute values of the result field according to
6625  *          the optional numbers of cells and nodes, if any. The valid values are
6626  *          - 0 - do not permute.
6627  *          - 1 - permute cells.
6628  *          - 2 - permute nodes.
6629  *          - 3 - permute cells and nodes.
6630  *
6631  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6632  *          caller is to delete this field using decrRef() as it is no more needed. 
6633  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6634  *  \throw If no field of \a this is lying on \a mesh.
6635  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6636  *  \sa getFieldAtLevel()
6637  *  \sa getFieldOnMeshAtLevel() 
6638  */
6639 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6640 {
6641   MCAuto<DataArray> arrOut;
6642   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6643   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6644   return ret.retn();
6645 }
6646
6647 /*!
6648  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6649  * This method is called "Old" because in MED3 norm a field has only one meshName
6650  * attached, so this method is for readers of MED2 files. If \a this field 
6651  * has not been constructed via file reading, an exception is thrown.
6652  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6653  *  \param [in] type - a spatial discretization of interest.
6654  *  \param [in] mName - a name of the supporting mesh.
6655  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6656  *  \param [in] renumPol - specifies how to permute values of the result field according to
6657  *          the optional numbers of cells and nodes, if any. The valid values are
6658  *          - 0 - do not permute.
6659  *          - 1 - permute cells.
6660  *          - 2 - permute nodes.
6661  *          - 3 - permute cells and nodes.
6662  *
6663  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6664  *          caller is to delete this field using decrRef() as it is no more needed. 
6665  *  \throw If the MED file is not readable.
6666  *  \throw If there is no mesh named \a mName in the MED file.
6667  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6668  *  \throw If \a this field has not been constructed via file reading.
6669  *  \throw If no field of \a this is lying on the mesh named \a mName.
6670  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6671  *  \sa getFieldAtLevel()
6672  */
6673 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6674 {
6675   if(getFileName().empty())
6676     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6677   MCAuto<DataArray> arrOut;
6678   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6679   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6680   return ret.retn();
6681 }
6682
6683 /*!
6684  * Returns values and a profile of the field of a given type lying on a given support.
6685  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6686  *  \param [in] type - a spatial discretization of the field.
6687  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6688  *  \param [in] mesh - the supporting mesh.
6689  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6690  *          field of interest lies on. If the field lies on all entities of the given
6691  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6692  *          using decrRef() as it is no more needed.  
6693  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6694  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6695  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6696  *  \throw If no field of \a this is lying on \a mesh.
6697  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6698  */
6699 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6700 {
6701   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6702   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6703 }
6704
6705 /*!
6706  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6707  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6708  * "Sort By Type"), if not, an exception is thrown. 
6709  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6710  *  \param [in] field - the field to add to \a this.
6711  *  \throw If the name of \a field is empty.
6712  *  \throw If the data array of \a field is not set.
6713  *  \throw If the data array is already allocated but has different number of components
6714  *         than \a field.
6715  *  \throw If the underlying mesh of \a field has no name.
6716  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6717  */
6718 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6719 {
6720   setFileName("");
6721   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6722 }
6723
6724 /*!
6725  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6726  * can be an aggregation of several MEDCouplingFieldDouble instances.
6727  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6728  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6729  * and \a profile.
6730  *
6731  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6732  * A new profile is added only if no equal profile is missing.
6733  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6734  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6735  *  \param [in] mesh - the supporting mesh of \a field.
6736  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6737  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6738  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6739  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6740  *  \throw If the data array of \a field is not set.
6741  *  \throw If the data array of \a this is already allocated but has different number of
6742  *         components than \a field.
6743  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6744  *  \sa setFieldNoProfileSBT()
6745  */
6746 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6747 {
6748   setFileName("");
6749   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6750 }
6751
6752 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6753 {
6754   return new MEDFileField1TS(*this);
6755 }
6756
6757 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6758 {
6759   return contentNotNull()->getUndergroundDataArrayDouble();
6760 }
6761
6762 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6763 {
6764   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6765 }
6766
6767 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6768                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6769 {
6770   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6771 }
6772
6773 //= MEDFileIntField1TS
6774
6775 MEDFileIntField1TS *MEDFileIntField1TS::New()
6776 {
6777   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6778   ret->contentNotNull();
6779   return ret.retn();
6780 }
6781
6782 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6783 {
6784   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6785   ret->contentNotNull();
6786   return ret.retn();
6787 }
6788
6789 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6790 {
6791   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6792   ret->contentNotNull();
6793   return ret.retn();
6794 }
6795
6796 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6797 {
6798   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6799   ret->contentNotNull();
6800   return ret.retn();
6801 }
6802
6803 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6804 {
6805   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6806   ret->contentNotNull();
6807   return ret.retn();
6808 }
6809
6810 MEDFileIntField1TS::MEDFileIntField1TS()
6811 {
6812   _content=new MEDFileIntField1TSWithoutSDA;
6813 }
6814
6815 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6816 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6817 {
6818 }
6819 catch(INTERP_KERNEL::Exception& e)
6820 { throw e; }
6821
6822 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6823 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6824 {
6825 }
6826 catch(INTERP_KERNEL::Exception& e)
6827 { throw e; }
6828
6829 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6830 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6831 {
6832 }
6833 catch(INTERP_KERNEL::Exception& e)
6834 { throw e; }
6835
6836 /*!
6837  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6838  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6839  *
6840  * \warning this is a shallow copy constructor
6841  */
6842 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6843 {
6844 }
6845
6846 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6847 {
6848   return new MEDFileIntField1TS(*this);
6849 }
6850
6851 /*!
6852  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6853  * following the given input policy.
6854  *
6855  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6856  *                            By default (true) the globals are deeply copied.
6857  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6858  */
6859 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6860 {
6861   MCAuto<MEDFileField1TS> ret;
6862   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6863   if(content)
6864     {
6865       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6866       if(!contc)
6867         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6868       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6869       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6870     }
6871   else
6872     ret=MEDFileField1TS::New();
6873   if(isDeepCpyGlobs)
6874     ret->deepCpyGlobs(*this);
6875   else
6876     ret->shallowCpyGlobs(*this);
6877   return ret.retn();
6878 }
6879
6880 /*!
6881  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6882  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6883  * "Sort By Type"), if not, an exception is thrown. 
6884  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6885  *  \param [in] field - the field to add to \a this.
6886  *  \throw If the name of \a field is empty.
6887  *  \throw If the data array of \a field is not set.
6888  *  \throw If the data array is already allocated but has different number of components
6889  *         than \a field.
6890  *  \throw If the underlying mesh of \a field has no name.
6891  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6892  */
6893 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6894 {
6895   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6896   setFileName("");
6897   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6898 }
6899
6900 /*!
6901  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6902  * can be an aggregation of several MEDCouplingFieldDouble instances.
6903  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6904  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6905  * and \a profile.
6906  *
6907  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6908  * A new profile is added only if no equal profile is missing.
6909  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6910  *  \param [in] field - the field to add to \a this.
6911  *  \param [in] mesh - the supporting mesh of \a field.
6912  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6913  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6914  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6915  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6916  *  \throw If the data array of \a field is not set.
6917  *  \throw If the data array of \a this is already allocated but has different number of
6918  *         components than \a field.
6919  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6920  *  \sa setFieldNoProfileSBT()
6921  */
6922 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6923 {
6924   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6925   setFileName("");
6926   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6927 }
6928
6929 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6930 {
6931   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6932   if(!pt)
6933     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6934   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6935   if(!ret)
6936     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 !");
6937   return ret;
6938 }
6939
6940 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6941 {
6942   if(getFileName().empty())
6943     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6944   MCAuto<DataArray> arrOut;
6945   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6946   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6947   return ret2.retn();
6948 }
6949
6950 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6951 {
6952   if(arr.isNull())
6953     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6954   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6955   if(!arrC)
6956     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6957   arrC->incrRef();
6958   return arrC;
6959 }
6960
6961 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6962 {
6963   int t1,t2;
6964   double t0(f->getTime(t1,t2));
6965   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6966   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6967   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6968   ret->setTime(t0,t1,t2); ret->setArray(arr2);
6969   return ret.retn();
6970 }
6971
6972 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6973 {
6974   if(!f)
6975     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6976   int t1,t2;
6977   double t0(f->getTime(t1,t2));
6978   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6979   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6980   ret->setTime(t0,t1,t2);
6981   return ret;
6982 }
6983
6984 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6985 {
6986   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6987 }
6988
6989 /*!
6990  * 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
6991  * method should be called (getFieldOnMeshAtLevel for example).
6992  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6993  *
6994  * \param [in] mesh - the mesh the field is lying on
6995  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6996  *          caller is to delete this field using decrRef() as it is no more needed. 
6997  */
6998 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
6999 {
7000   MCAuto<DataArray> arrOut;
7001   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7002   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7003   return ret2.retn();
7004 }
7005
7006 /*!
7007  * Returns a new MEDCouplingFieldInt of a given type lying on
7008  * the top level cells of the first mesh in MED file. If \a this field 
7009  * has not been constructed via file reading, an exception is thrown.
7010  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7011  *  \param [in] type - a spatial discretization of interest.
7012  *  \param [in] renumPol - specifies how to permute values of the result field according to
7013  *          the optional numbers of cells and nodes, if any. The valid values are
7014  *          - 0 - do not permute.
7015  *          - 1 - permute cells.
7016  *          - 2 - permute nodes.
7017  *          - 3 - permute cells and nodes.
7018  *
7019  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7020  *          caller is to delete this field using decrRef() as it is no more needed. 
7021  *  \throw If \a this field has not been constructed via file reading.
7022  *  \throw If the MED file is not readable.
7023  *  \throw If there is no mesh in the MED file.
7024  *  \throw If no field values of the given \a type.
7025  *  \throw If no field values lying on the top level support.
7026  *  \sa getFieldAtLevel()
7027  */
7028 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7029 {
7030   if(getFileName().empty())
7031     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7032   MCAuto<DataArray> arrOut;
7033   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7034   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7035   return ret2.retn();
7036 }
7037
7038 /*!
7039  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7040  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7041  *  \param [in] type - a spatial discretization of the new field.
7042  *  \param [in] mesh - the supporting mesh.
7043  *  \param [in] renumPol - specifies how to permute values of the result field according to
7044  *          the optional numbers of cells and nodes, if any. The valid values are
7045  *          - 0 - do not permute.
7046  *          - 1 - permute cells.
7047  *          - 2 - permute nodes.
7048  *          - 3 - permute cells and nodes.
7049  *
7050  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7051  *          caller is to delete this field using decrRef() as it is no more needed. 
7052  *  \throw If no field of \a this is lying on \a mesh.
7053  *  \throw If the mesh is empty.
7054  *  \throw If no field values of the given \a type are available.
7055  *  \sa getFieldAtLevel()
7056  *  \sa getFieldOnMeshAtLevel() 
7057  */
7058 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7059 {
7060   MCAuto<DataArray> arrOut;
7061   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7062   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7063   return ret2.retn();
7064 }
7065
7066 /*!
7067  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7068  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7069  *  \param [in] type - a spatial discretization of interest.
7070  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7071  *  \param [in] mesh - the supporting mesh.
7072  *  \param [in] renumPol - specifies how to permute values of the result field according to
7073  *          the optional numbers of cells and nodes, if any. The valid values are
7074  *          - 0 - do not permute.
7075  *          - 1 - permute cells.
7076  *          - 2 - permute nodes.
7077  *          - 3 - permute cells and nodes.
7078  *
7079  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7080  *          caller is to delete this field using decrRef() as it is no more needed. 
7081  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7082  *  \throw If no field of \a this is lying on \a mesh.
7083  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7084  *  \sa getFieldAtLevel()
7085  *  \sa getFieldOnMeshAtLevel() 
7086  */
7087 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7088 {
7089   MCAuto<DataArray> arrOut;
7090   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7091   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7092   return ret2.retn();
7093 }
7094
7095 /*!
7096  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7097  * This method is called "Old" because in MED3 norm a field has only one meshName
7098  * attached, so this method is for readers of MED2 files. If \a this field 
7099  * has not been constructed via file reading, an exception is thrown.
7100  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7101  *  \param [in] type - a spatial discretization of interest.
7102  *  \param [in] mName - a name of the supporting mesh.
7103  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7104  *  \param [in] renumPol - specifies how to permute values of the result field according to
7105  *          the optional numbers of cells and nodes, if any. The valid values are
7106  *          - 0 - do not permute.
7107  *          - 1 - permute cells.
7108  *          - 2 - permute nodes.
7109  *          - 3 - permute cells and nodes.
7110  *
7111  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7112  *          caller is to delete this field using decrRef() as it is no more needed. 
7113  *  \throw If the MED file is not readable.
7114  *  \throw If there is no mesh named \a mName in the MED file.
7115  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7116  *  \throw If \a this field has not been constructed via file reading.
7117  *  \throw If no field of \a this is lying on the mesh named \a mName.
7118  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7119  *  \sa getFieldAtLevel()
7120  */
7121 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7122 {
7123   if(getFileName().empty())
7124     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7125   MCAuto<DataArray> arrOut;
7126   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7127   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7128   return ret2.retn();
7129 }
7130
7131 /*!
7132  * Returns values and a profile of the field of a given type lying on a given support.
7133  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7134  *  \param [in] type - a spatial discretization of the field.
7135  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7136  *  \param [in] mesh - the supporting mesh.
7137  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7138  *          field of interest lies on. If the field lies on all entities of the given
7139  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7140  *          using decrRef() as it is no more needed.  
7141  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7142  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7143  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7144  *  \throw If no field of \a this is lying on \a mesh.
7145  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7146  */
7147 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7148 {
7149   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7150   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7151 }
7152
7153 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7154 {
7155   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7156   if(!pt)
7157     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7158   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7159   if(!ret)
7160     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 !");
7161   return ret;
7162 }
7163
7164 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7165 {
7166   return contentNotNull()->getUndergroundDataArrayInt();
7167 }
7168
7169 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7170
7171 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7172 {
7173 }
7174
7175 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7176 {
7177 }
7178
7179 /*!
7180  * \param [in] fieldId field id in C mode
7181  */
7182 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7183 {
7184   med_field_type typcha;
7185   std::string dtunitOut;
7186   int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7187   setDtUnit(dtunitOut.c_str());
7188   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7189 }
7190
7191 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7192 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7193 {
7194   setDtUnit(dtunit.c_str());
7195   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7196 }
7197 catch(INTERP_KERNEL::Exception& e)
7198 {
7199     throw e;
7200 }
7201
7202 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7203 {
7204   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7205   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7206     ret+=(*it).capacity();
7207   return ret;
7208 }
7209
7210 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7211 {
7212   std::vector<const BigMemoryObject *> ret;
7213   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7214     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7215   return ret;
7216 }
7217
7218 /*!
7219  * 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
7220  * NULL.
7221  */
7222 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7223 {
7224   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7225   ret->setInfo(_infos);
7226   int sz=(int)_time_steps.size();
7227   for(const int *id=startIds;id!=endIds;id++)
7228     {
7229       if(*id>=0 && *id<sz)
7230         {
7231           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7232           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7233           if(tse)
7234             {
7235               tse->incrRef();
7236               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7237             }
7238           ret->pushBackTimeStep(tse2);
7239         }
7240       else
7241         {
7242           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7243           oss << " ! Should be in [0," << sz << ") !";
7244           throw INTERP_KERNEL::Exception(oss.str());
7245         }
7246     }
7247   if(ret->getNumberOfTS()>0)
7248     ret->synchronizeNameScope();
7249   ret->copyNameScope(*this);
7250   return ret.retn();
7251 }
7252
7253 /*!
7254  * 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
7255  * NULL.
7256  */
7257 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7258 {
7259   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7260   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7261   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7262   ret->setInfo(_infos);
7263   int sz=(int)_time_steps.size();
7264   int j=bg;
7265   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7266     {
7267       if(j>=0 && j<sz)
7268         {
7269           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7270           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7271           if(tse)
7272             {
7273               tse->incrRef();
7274               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7275             }
7276           ret->pushBackTimeStep(tse2);
7277         }
7278       else
7279         {
7280           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7281           oss << " ! Should be in [0," << sz << ") !";
7282           throw INTERP_KERNEL::Exception(oss.str());
7283         }
7284     }
7285   if(ret->getNumberOfTS()>0)
7286     ret->synchronizeNameScope();
7287   ret->copyNameScope(*this);
7288   return ret.retn();
7289 }
7290
7291 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(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 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7308 {
7309   int id=0;
7310   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7311   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7312     {
7313       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7314       if(!cur)
7315         continue;
7316       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7317       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7318         ids->pushBackSilent(id);
7319     }
7320   return buildFromTimeStepIds(ids->begin(),ids->end());
7321 }
7322
7323 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7324 {
7325   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7326     {
7327       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7328       if(!cur)
7329         continue;
7330       if(cur->presenceOfMultiDiscPerGeoType())
7331         return true;
7332     }
7333   return false;
7334 }
7335
7336 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7337 {
7338   return _infos;
7339 }
7340
7341 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7342 {
7343   _infos=info;
7344 }
7345
7346 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7347 {
7348   int ret=0;
7349   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7350     {
7351       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7352       if(pt->isDealingTS(iteration,order))
7353         return ret;
7354     }
7355   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7356   std::vector< std::pair<int,int> > vp=getIterations();
7357   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7358     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7359   throw INTERP_KERNEL::Exception(oss.str());
7360 }
7361
7362 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7363 {
7364   return *_time_steps[getTimeStepPos(iteration,order)];
7365 }
7366
7367 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7368 {
7369   return *_time_steps[getTimeStepPos(iteration,order)];
7370 }
7371
7372 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7373 {
7374   if(_time_steps.empty())
7375     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7376   return _time_steps[0]->getMeshName();
7377 }
7378
7379 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7380 {
7381   std::string oldName(getMeshName());
7382   std::vector< std::pair<std::string,std::string> > v(1);
7383   v[0].first=oldName; v[0].second=newMeshName;
7384   changeMeshNames(v);
7385 }
7386
7387 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7388 {
7389   bool ret=false;
7390   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7391     {
7392       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7393       if(cur)
7394         ret=cur->changeMeshNames(modifTab) || ret;
7395     }
7396   return ret;
7397 }
7398
7399 /*!
7400  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7401  */
7402 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7403 {
7404   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7405 }
7406
7407 /*!
7408  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7409  */
7410 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7411 {
7412   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7413 }
7414
7415 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7416                                                                        MEDFileFieldGlobsReal& glob)
7417 {
7418   bool ret=false;
7419   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7420     {
7421       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7422       if(f1ts)
7423         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7424     }
7425   return ret;
7426 }
7427
7428 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7429 {
7430   std::string startLine(bkOffset,' ');
7431   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7432   if(fmtsId>=0)
7433     oss << " (" << fmtsId << ")";
7434   oss << " has the following name: \"" << _name << "\"." << std::endl;
7435   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7436   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7437     {
7438       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7439     }
7440   int i=0;
7441   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7442     {
7443       std::string chapter(17,'0'+i);
7444       oss << startLine << chapter << std::endl;
7445       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7446       if(cur)
7447         cur->simpleRepr(bkOffset+2,oss,i);
7448       else
7449         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7450       oss << startLine << chapter << std::endl;
7451     }
7452 }
7453
7454 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7455 {
7456   std::size_t sz=_time_steps.size();
7457   std::vector< std::pair<int,int> > ret(sz);
7458   ret1.resize(sz);
7459   for(std::size_t i=0;i<sz;i++)
7460     {
7461       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7462       if(f1ts)
7463         {
7464           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7465         }
7466       else
7467         {
7468           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7469           throw INTERP_KERNEL::Exception(oss.str());
7470         }
7471     }
7472   return ret;
7473 }
7474
7475 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7476 {
7477   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7478   if(!tse2)
7479     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7480   checkCoherencyOfType(tse2);
7481   if(_time_steps.empty())
7482     {
7483       setName(tse2->getName().c_str());
7484       setInfo(tse2->getInfo());
7485     }
7486   checkThatComponentsMatch(tse2->getInfo());
7487   _time_steps.push_back(tse);
7488 }
7489
7490 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7491 {
7492   std::size_t nbOfCompo=_infos.size();
7493   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7494     {
7495       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7496       if(cur)
7497         {
7498           if((cur->getInfo()).size()!=nbOfCompo)
7499             {
7500               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7501               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7502               throw INTERP_KERNEL::Exception(oss.str());
7503             }
7504           cur->copyNameScope(*this);
7505         }
7506     }
7507 }
7508
7509 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7510 {
7511   _time_steps.resize(nbPdt);
7512   for(int i=0;i<nbPdt;i++)
7513     {
7514       std::vector< std::pair<int,int> > ts;
7515       med_int numdt=0,numo=0;
7516       med_int meshIt=0,meshOrder=0;
7517       med_float dt=0.0;
7518       MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7519       switch(fieldTyp)
7520       {
7521         case MED_FLOAT64:
7522           {
7523             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7524             break;
7525           }
7526         case MED_INT32:
7527           {
7528             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7529             break;
7530           }
7531         default:
7532           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7533       }
7534       if(loadAll)
7535         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7536       else
7537         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7538     }
7539 }
7540
7541 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7542 {
7543   if(_time_steps.empty())
7544     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7545   checkThatNbOfCompoOfTSMatchThis();
7546   std::vector<std::string> infos(getInfo());
7547   int nbComp=infos.size();
7548   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7549   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7550   for(int i=0;i<nbComp;i++)
7551     {
7552       std::string info=infos[i];
7553       std::string c,u;
7554       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7555       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7556       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7557     }
7558   if(_name.empty())
7559     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7560   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7561   int nbOfTS=_time_steps.size();
7562   for(int i=0;i<nbOfTS;i++)
7563     _time_steps[i]->writeLL(fid,opts,*this);
7564 }
7565
7566 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7567 {
7568   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7569     {
7570       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7571       if(elt)
7572         elt->loadBigArraysRecursively(fid,nasc);
7573     }
7574 }
7575
7576 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7577 {
7578   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7579     {
7580       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7581       if(elt)
7582         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7583     }
7584 }
7585
7586 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7587 {
7588   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7589     {
7590       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7591       if(elt)
7592         elt->unloadArrays();
7593     }
7594 }
7595
7596 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7597 {
7598   return _time_steps.size();
7599 }
7600
7601 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7602 {
7603   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7604   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7605     {
7606       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7607       if(tmp)
7608         newTS.push_back(*it);
7609     }
7610   _time_steps=newTS;
7611 }
7612
7613 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7614 {
7615   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7616   int maxId=(int)_time_steps.size();
7617   int ii=0;
7618   std::set<int> idsToDel;
7619   for(const int *id=startIds;id!=endIds;id++,ii++)
7620     {
7621       if(*id>=0 && *id<maxId)
7622         {
7623           idsToDel.insert(*id);
7624         }
7625       else
7626         {
7627           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7628           throw INTERP_KERNEL::Exception(oss.str());
7629         }
7630     }
7631   for(int iii=0;iii<maxId;iii++)
7632     if(idsToDel.find(iii)==idsToDel.end())
7633       newTS.push_back(_time_steps[iii]);
7634   _time_steps=newTS;
7635 }
7636
7637 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7638 {
7639   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7640   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7641   if(nbOfEntriesToKill==0)
7642     return ;
7643   std::size_t sz=_time_steps.size();
7644   std::vector<bool> b(sz,true);
7645   int j=bg;
7646   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7647     b[j]=false;
7648   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7649   for(std::size_t i=0;i<sz;i++)
7650     if(b[i])
7651       newTS.push_back(_time_steps[i]);
7652   _time_steps=newTS;
7653 }
7654
7655 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7656 {
7657   int ret=0;
7658   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7659   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7660     {
7661       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7662       if(tmp)
7663         {
7664           int it2,ord;
7665           tmp->getTime(it2,ord);
7666           if(it2==iteration && order==ord)
7667             return ret;
7668           else
7669             oss << "(" << it2 << ","  << ord << "), ";
7670         }
7671     }
7672   throw INTERP_KERNEL::Exception(oss.str());
7673 }
7674
7675 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7676 {
7677   int ret=0;
7678   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7679   oss.precision(15);
7680   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7681     {
7682       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7683       if(tmp)
7684         {
7685           int it2,ord;
7686           double ti=tmp->getTime(it2,ord);
7687           if(fabs(time-ti)<eps)
7688             return ret;
7689           else
7690             oss << ti << ", ";
7691         }
7692     }
7693   throw INTERP_KERNEL::Exception(oss.str());
7694 }
7695
7696 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7697 {
7698   int lgth=_time_steps.size();
7699   std::vector< std::pair<int,int> > ret(lgth);
7700   for(int i=0;i<lgth;i++)
7701     _time_steps[i]->fillIteration(ret[i]);
7702   return ret;
7703 }
7704
7705 /*!
7706  * 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'
7707  * This method returns two things.
7708  * - The absolute dimension of 'this' in first parameter. 
7709  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7710  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7711  *
7712  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7713  * Only these 3 discretizations will be taken into account here.
7714  *
7715  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7716  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7717  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7718  *
7719  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7720  * 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'.
7721  * 
7722  * Let's consider the typical following case :
7723  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7724  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7725  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7726  *   TETRA4 and SEG2
7727  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7728  *
7729  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7730  * 
7731  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7732  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7733  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7734  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7735  */
7736 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7737 {
7738   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7739 }
7740
7741 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7742 {
7743   if(pos<0 || pos>=(int)_time_steps.size())
7744     {
7745       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7746       throw INTERP_KERNEL::Exception(oss.str());
7747     }
7748   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7749   if(item==0)
7750     {
7751       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7752       oss << "\nTry to use following method eraseEmptyTS !";
7753       throw INTERP_KERNEL::Exception(oss.str());
7754     }
7755   return item;
7756 }
7757
7758 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7759 {
7760   if(pos<0 || pos>=(int)_time_steps.size())
7761     {
7762       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7763       throw INTERP_KERNEL::Exception(oss.str());
7764     }
7765   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7766   if(item==0)
7767     {
7768       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7769       oss << "\nTry to use following method eraseEmptyTS !";
7770       throw INTERP_KERNEL::Exception(oss.str());
7771     }
7772   return item;
7773 }
7774
7775 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7776 {
7777   std::vector<std::string> ret;
7778   std::set<std::string> ret2;
7779   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7780     {
7781       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7782       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7783         if(ret2.find(*it2)==ret2.end())
7784           {
7785             ret.push_back(*it2);
7786             ret2.insert(*it2);
7787           }
7788     }
7789   return ret;
7790 }
7791
7792 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7793 {
7794   std::vector<std::string> ret;
7795   std::set<std::string> ret2;
7796   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7797     {
7798       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7799       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7800         if(ret2.find(*it2)==ret2.end())
7801           {
7802             ret.push_back(*it2);
7803             ret2.insert(*it2);
7804           }
7805     }
7806   return ret;
7807 }
7808
7809 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7810 {
7811   std::vector<std::string> ret;
7812   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7813     {
7814       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7815       ret.insert(ret.end(),tmp.begin(),tmp.end());
7816     }
7817   return ret;
7818 }
7819
7820 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7821 {
7822   std::vector<std::string> ret;
7823   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7824     {
7825       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7826       ret.insert(ret.end(),tmp.begin(),tmp.end());
7827     }
7828   return ret;
7829 }
7830
7831 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7832 {
7833   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7834     (*it)->changePflsRefsNamesGen2(mapOfModif);
7835 }
7836
7837 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7838 {
7839   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7840     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7841 }
7842
7843 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7844 {
7845   int lgth=_time_steps.size();
7846   std::vector< std::vector<TypeOfField> > ret(lgth);
7847   for(int i=0;i<lgth;i++)
7848     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7849   return ret;
7850 }
7851
7852 /*!
7853  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7854  */
7855 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
7856 {
7857   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7858 }
7859
7860 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7861 {
7862   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7863   std::size_t i=0;
7864   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7865     {
7866       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7867         ret->_time_steps[i]=(*it)->deepCopy();
7868     }
7869   return ret.retn();
7870 }
7871
7872 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7873 {
7874   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7875   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7876   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7877   for(std::size_t i=0;i<sz;i++)
7878     {
7879       ret[i]=shallowCpy();
7880       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7881     }
7882   for(std::size_t i=0;i<sz2;i++)
7883     {
7884       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7885       if(ret1.size()!=sz)
7886         {
7887           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7888           throw INTERP_KERNEL::Exception(oss.str());
7889         }
7890       ts[i]=ret1;
7891     }
7892   for(std::size_t i=0;i<sz;i++)
7893     for(std::size_t j=0;j<sz2;j++)
7894       ret[i]->_time_steps[j]=ts[j][i];
7895   return ret;
7896 }
7897
7898 /*!
7899  * This method splits into discretization each time steps in \a this.
7900  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7901  */
7902 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7903 {
7904   std::size_t sz(_time_steps.size());
7905   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7906   for(std::size_t i=0;i<sz;i++)
7907     {
7908       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7909       if(!timeStep)
7910         {
7911           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7912           throw INTERP_KERNEL::Exception(oss.str());
7913         }
7914       items[i]=timeStep->splitDiscretizations();  
7915     }
7916   //
7917   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7918   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7919   std::vector< TypeOfField > types;
7920   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7921     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7922       {
7923         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7924         if(ts.size()!=1)
7925           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7926         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7927         if(it2==types.end())
7928           types.push_back(ts[0]);
7929       }
7930   ret.resize(types.size()); ret2.resize(types.size());
7931   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7932     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7933       {
7934         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7935         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7936         ret2[pos].push_back(*it1);
7937       }
7938   for(std::size_t i=0;i<types.size();i++)
7939     {
7940       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7941       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7942         elt->pushBackTimeStep(*it1);//also updates infos in elt
7943       ret[i]=elt;
7944       elt->MEDFileFieldNameScope::operator=(*this);
7945     }
7946   return ret;
7947 }
7948
7949 /*!
7950  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7951  */
7952 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7953 {
7954   std::size_t sz(_time_steps.size());
7955   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7956   std::size_t szOut(std::numeric_limits<std::size_t>::max());
7957   for(std::size_t i=0;i<sz;i++)
7958     {
7959       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7960       if(!timeStep)
7961         {
7962           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7963           throw INTERP_KERNEL::Exception(oss.str());
7964         }
7965       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7966       if(szOut==std::numeric_limits<std::size_t>::max())
7967         szOut=items[i].size();
7968       else
7969         if(items[i].size()!=szOut)
7970           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7971     }
7972   if(szOut==std::numeric_limits<std::size_t>::max())
7973     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7974   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7975   for(std::size_t i=0;i<szOut;i++)
7976     {
7977       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7978       for(std::size_t j=0;j<sz;j++)
7979         elt->pushBackTimeStep(items[j][i]);
7980       ret[i]=elt;
7981       elt->MEDFileFieldNameScope::operator=(*this);
7982     }
7983   return ret;
7984 }
7985
7986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7987 {
7988   _name=field->getName();
7989   if(_name.empty())
7990     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7991   if(!arr)
7992     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7993   _infos=arr->getInfoOnComponents();
7994 }
7995
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7997 {
7998   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7999   if(_name!=field->getName())
8000     {
8001       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8002       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8003       throw INTERP_KERNEL::Exception(oss.str());
8004     }
8005   if(!arr)
8006     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8007   checkThatComponentsMatch(arr->getInfoOnComponents());
8008 }
8009
8010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8011 {
8012   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8013   if(getInfo().size()!=compos.size())
8014     {
8015       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8016       oss << " number of components of element to append (" << compos.size() << ") !";
8017       throw INTERP_KERNEL::Exception(oss.str());
8018     }
8019   if(_infos!=compos)
8020     {
8021       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8022       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8023       oss << " But compo in input fields are : ";
8024       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8025       oss << " !";
8026       throw INTERP_KERNEL::Exception(oss.str());
8027     }
8028 }
8029
8030 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8031 {
8032   std::size_t sz=_infos.size();
8033   int j=0;
8034   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8035     {
8036       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8037       if(elt)
8038         if(elt->getInfo().size()!=sz)
8039           {
8040             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8041             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8042             throw INTERP_KERNEL::Exception(oss.str());
8043           }
8044     }
8045 }
8046
8047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8048 {
8049   if(!field)
8050     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8051   if(!_time_steps.empty())
8052     checkCoherencyOfTinyInfo(field,arr);
8053   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8054   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8055   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8056   copyTinyInfoFrom(field,arr);
8057   _time_steps.push_back(obj);
8058 }
8059
8060 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8061 {
8062   if(!field)
8063     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8064   if(!_time_steps.empty())
8065     checkCoherencyOfTinyInfo(field,arr);
8066   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8067   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8068   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8069   copyTinyInfoFrom(field,arr);
8070   _time_steps.push_back(obj);
8071 }
8072
8073 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8074 {
8075   int sz=(int)_time_steps.size();
8076   if(i<0 || i>=sz)
8077     {
8078       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8079       throw INTERP_KERNEL::Exception(oss.str());
8080     }
8081   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8082   if(tsPtr)
8083     {
8084       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8085         {
8086           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8087           throw INTERP_KERNEL::Exception(oss.str());
8088         }
8089     }
8090   _time_steps[i]=ts;
8091 }
8092
8093 //= MEDFileFieldMultiTSWithoutSDA
8094
8095 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8096 {
8097   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8098 }
8099
8100 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8101 {
8102 }
8103
8104 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8105 {
8106 }
8107
8108 /*!
8109  * \param [in] fieldId field id in C mode
8110  */
8111 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8112 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8113 {
8114 }
8115 catch(INTERP_KERNEL::Exception& e)
8116 { throw e; }
8117
8118 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8119 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8120 {
8121 }
8122 catch(INTERP_KERNEL::Exception& e)
8123 { throw e; }
8124
8125 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8126 {
8127   return new MEDFileField1TSWithoutSDA;
8128 }
8129
8130 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8131 {
8132   if(!f1ts)
8133     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8134   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8135   if(!f1tsC)
8136     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8137 }
8138
8139 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8140 {
8141   return MEDFileField1TSWithoutSDA::TYPE_STR;
8142 }
8143
8144 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8145 {
8146   return new MEDFileFieldMultiTSWithoutSDA(*this);
8147 }
8148
8149 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8150 {
8151   return new MEDFileFieldMultiTSWithoutSDA;
8152 }
8153
8154 /*!
8155  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8156  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8157  */
8158 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
8159 {
8160   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8161   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8162   if(!myF1TSC)
8163     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8164   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8165 }
8166
8167 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8168 {
8169   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8170   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8171   int i=0;
8172   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8173     {
8174       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8175       if(eltToConv)
8176         {
8177           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8178           if(!eltToConvC)
8179             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8180           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8181           ret->setIteration(i,elt);
8182         }
8183     }
8184   return ret.retn();
8185 }
8186
8187 //= MEDFileAnyTypeFieldMultiTS
8188
8189 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8190 {
8191 }
8192
8193 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8194 try:MEDFileFieldGlobsReal(fileName)
8195 {
8196   MEDFileUtilities::CheckFileForRead(fileName);
8197   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8198   _content=BuildContentFrom(fid,fileName,loadAll,ms);
8199   loadGlobals(fid);
8200 }
8201 catch(INTERP_KERNEL::Exception& e)
8202 {
8203     throw e;
8204 }
8205
8206 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8207 {
8208   med_field_type typcha;
8209   std::vector<std::string> infos;
8210   std::string dtunit;
8211   int i=-1;
8212   MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8213   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8214   switch(typcha)
8215   {
8216     case MED_FLOAT64:
8217       {
8218         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8219         break;
8220       }
8221     case MED_INT32:
8222       {
8223         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8224         break;
8225       }
8226     default:
8227       {
8228         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8229         throw INTERP_KERNEL::Exception(oss.str());
8230       }
8231   }
8232   ret->setDtUnit(dtunit.c_str());
8233   return ret.retn();
8234 }
8235
8236 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8237 {
8238   med_field_type typcha;
8239   //
8240   std::vector<std::string> infos;
8241   std::string dtunit,fieldName;
8242   MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8243   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8244   switch(typcha)
8245   {
8246     case MED_FLOAT64:
8247       {
8248         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8249         break;
8250       }
8251     case MED_INT32:
8252       {
8253         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8254         break;
8255       }
8256     default:
8257       {
8258         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8259         throw INTERP_KERNEL::Exception(oss.str());
8260       }
8261   }
8262   ret->setDtUnit(dtunit.c_str());
8263   return ret.retn();
8264 }
8265
8266 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8267 {
8268   if(!c)
8269     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8270   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8271     {
8272       MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8273       ret->setFileName(fileName);
8274       ret->_content=c;  c->incrRef();
8275       return ret.retn();
8276     }
8277   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8278     {
8279       MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8280       ret->setFileName(fileName);
8281       ret->_content=c;  c->incrRef();
8282       return ret.retn();
8283     }
8284   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8285 }
8286
8287 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8288 try:MEDFileFieldGlobsReal(fileName)
8289 {
8290   MEDFileUtilities::CheckFileForRead(fileName);
8291   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8292   _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8293   loadGlobals(fid);
8294 }
8295 catch(INTERP_KERNEL::Exception& e)
8296 {
8297     throw e;
8298 }
8299
8300 //= MEDFileIntFieldMultiTSWithoutSDA
8301
8302 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8303 {
8304   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8305 }
8306
8307 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8308 {
8309 }
8310
8311 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8312 {
8313 }
8314
8315 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8316 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8317 {
8318 }
8319 catch(INTERP_KERNEL::Exception& e)
8320 { throw e; }
8321
8322 /*!
8323  * \param [in] fieldId field id in C mode
8324  */
8325 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8326 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8327 {
8328 }
8329 catch(INTERP_KERNEL::Exception& e)
8330 { throw e; }
8331
8332 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8333 {
8334   return new MEDFileIntField1TSWithoutSDA;
8335 }
8336
8337 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8338 {
8339   if(!f1ts)
8340     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8341   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8342   if(!f1tsC)
8343     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8344 }
8345
8346 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8347 {
8348   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8349 }
8350
8351 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8352 {
8353   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8354 }
8355
8356 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8357 {
8358   return new MEDFileIntFieldMultiTSWithoutSDA;
8359 }
8360
8361 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8362 {
8363   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8364   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8365   int i=0;
8366   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8367     {
8368       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8369       if(eltToConv)
8370         {
8371           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8372           if(!eltToConvC)
8373             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8374           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8375           ret->setIteration(i,elt);
8376         }
8377     }
8378   return ret.retn();
8379 }
8380
8381 //= MEDFileAnyTypeFieldMultiTS
8382
8383 /*!
8384  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8385  * that has been read from a specified MED file.
8386  *  \param [in] fileName - the name of the MED file to read.
8387  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8388  *          is to delete this field using decrRef() as it is no more needed.
8389  *  \throw If reading the file fails.
8390  */
8391 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8392 {
8393   MEDFileUtilities::CheckFileForRead(fileName);
8394   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8395   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8396   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8397   ret->loadGlobals(fid);
8398   return ret.retn();
8399 }
8400
8401 /*!
8402  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8403  * that has been read from a specified MED file.
8404  *  \param [in] fileName - the name of the MED file to read.
8405  *  \param [in] fieldName - the name of the field to read.
8406  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8407  *          is to delete this field using decrRef() as it is no more needed.
8408  *  \throw If reading the file fails.
8409  *  \throw If there is no field named \a fieldName in the file.
8410  */
8411 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8412 {
8413   MEDFileUtilities::CheckFileForRead(fileName);
8414   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8415   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8416   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8417   ret->loadGlobals(fid);
8418   return ret.retn();
8419 }
8420
8421 /*!
8422  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8423  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8424  *
8425  * \warning this is a shallow copy constructor
8426  */
8427 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8428 {
8429   if(!shallowCopyOfContent)
8430     {
8431       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8432       otherPtr->incrRef();
8433       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8434     }
8435   else
8436     {
8437       _content=other.shallowCpy();
8438     }
8439 }
8440
8441 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8442 {
8443   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8444   if(!ret)
8445     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8446   return ret;
8447 }
8448
8449 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8450 {
8451   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8452   if(!ret)
8453     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8454   return ret;
8455 }
8456
8457 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8458 {
8459   return contentNotNullBase()->getPflsReallyUsed2();
8460 }
8461
8462 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8463 {
8464   return contentNotNullBase()->getLocsReallyUsed2();
8465 }
8466
8467 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8468 {
8469   return contentNotNullBase()->getPflsReallyUsedMulti2();
8470 }
8471
8472 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8473 {
8474   return contentNotNullBase()->getLocsReallyUsedMulti2();
8475 }
8476
8477 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8478 {
8479   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8480 }
8481
8482 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8483 {
8484   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8485 }
8486
8487 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8488 {
8489   return contentNotNullBase()->getNumberOfTS();
8490 }
8491
8492 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8493 {
8494   contentNotNullBase()->eraseEmptyTS();
8495 }
8496
8497 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8498 {
8499   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8500 }
8501
8502 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8503 {
8504   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8505 }
8506
8507 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8508 {
8509   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8510   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8511   ret->_content=c;
8512   return ret.retn();
8513 }
8514
8515 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8516 {
8517   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8518   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8519   ret->_content=c;
8520   return ret.retn();
8521 }
8522
8523 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8524 {
8525   return contentNotNullBase()->getIterations();
8526 }
8527
8528 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8529 {
8530   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8531     pushBackTimeStep(*it);
8532 }
8533
8534 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8535 {
8536   if(!fmts)
8537     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8538   int nbOfTS(fmts->getNumberOfTS());
8539   for(int i=0;i<nbOfTS;i++)
8540     {
8541       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8542       pushBackTimeStep(elt);
8543     }
8544 }
8545
8546 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8547 {
8548   if(!f1ts)
8549     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8550   checkCoherencyOfType(f1ts);
8551   f1ts->incrRef();
8552   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8553   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8554   c->incrRef();
8555   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8556   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8557     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8558   _content->pushBackTimeStep(cSafe);
8559   appendGlobs(*f1ts,1e-12);
8560 }
8561
8562 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8563 {
8564   contentNotNullBase()->synchronizeNameScope();
8565 }
8566
8567 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8568 {
8569   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8570 }
8571
8572 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8573 {
8574   return contentNotNullBase()->getPosGivenTime(time,eps);
8575 }
8576
8577 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8578 {
8579   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8580 }
8581
8582 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8583 {
8584   return contentNotNullBase()->getTypesOfFieldAvailable();
8585 }
8586
8587 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
8588 {
8589   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8590 }
8591
8592 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8593 {
8594   return contentNotNullBase()->getName();
8595 }
8596
8597 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8598 {
8599   contentNotNullBase()->setName(name);
8600 }
8601
8602 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8603 {
8604   return contentNotNullBase()->getDtUnit();
8605 }
8606
8607 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8608 {
8609   contentNotNullBase()->setDtUnit(dtUnit);
8610 }
8611
8612 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8613 {
8614   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8615 }
8616
8617 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8618 {
8619   return contentNotNullBase()->getTimeSteps(ret1);
8620 }
8621
8622 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8623 {
8624   return contentNotNullBase()->getMeshName();
8625 }
8626
8627 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8628 {
8629   contentNotNullBase()->setMeshName(newMeshName);
8630 }
8631
8632 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8633 {
8634   return contentNotNullBase()->changeMeshNames(modifTab);
8635 }
8636
8637 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8638 {
8639   return contentNotNullBase()->getInfo();
8640 }
8641
8642 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8643 {
8644   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8645 }
8646
8647 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8648 {
8649   return contentNotNullBase()->setInfo(info);
8650 }
8651
8652 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8653 {
8654   const std::vector<std::string> ret=getInfo();
8655   return (int)ret.size();
8656 }
8657
8658 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8659 {
8660   writeGlobals(fid,*this);
8661   contentNotNullBase()->writeLL(fid,*this);
8662 }
8663
8664 /*!
8665  * Writes \a this field into a MED file specified by its name.
8666  *  \param [in] fileName - the MED file name.
8667  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8668  * - 2 - erase; an existing file is removed.
8669  * - 1 - append; same data should not be present in an existing file.
8670  * - 0 - overwrite; same data present in an existing file is overwritten.
8671  *  \throw If the field name is not set.
8672  *  \throw If no field data is set.
8673  *  \throw If \a mode == 1 and the same data is present in an existing file.
8674  */
8675 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8676 {
8677   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8678   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8679   writeLL(fid);
8680 }
8681
8682 /*!
8683  * This method alloc the arrays and load potentially huge arrays contained in this field.
8684  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8685  * This method can be also called to refresh or reinit values from a file.
8686  * 
8687  * \throw If the fileName is not set or points to a non readable MED file.
8688  */
8689 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8690 {
8691   if(getFileName().empty())
8692     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8693   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8694   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8695 }
8696
8697 /*!
8698  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8699  * But once data loaded once, this method does nothing.
8700  * 
8701  * \throw If the fileName is not set or points to a non readable MED file.
8702  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8703  */
8704 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8705 {
8706   if(!getFileName().empty())
8707     {
8708       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8709       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8710     }
8711 }
8712
8713 /*!
8714  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8715  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8716  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8717  * 
8718  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8719  */
8720 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8721 {
8722   contentNotNullBase()->unloadArrays();
8723 }
8724
8725 /*!
8726  * 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.
8727  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8728  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8729  * 
8730  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8731  */
8732 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8733 {
8734   if(!getFileName().empty())
8735     contentNotNullBase()->unloadArrays();
8736 }
8737
8738 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8739 {
8740   std::ostringstream oss;
8741   contentNotNullBase()->simpleRepr(0,oss,-1);
8742   simpleReprGlobs(oss);
8743   return oss.str();
8744 }
8745
8746 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8747 {
8748   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8749 }
8750
8751 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8752 {
8753   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8754   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8755   return ret;
8756 }
8757
8758 /*!
8759  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8760  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8761  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8762  */
8763 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8764 {
8765   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8766   if(!content)
8767     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8768   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8769   std::size_t sz(contentsSplit.size());
8770   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8771   for(std::size_t i=0;i<sz;i++)
8772     {
8773       ret[i]=shallowCpy();
8774       ret[i]->_content=contentsSplit[i];
8775     }
8776   return ret;
8777 }
8778
8779 /*!
8780  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8781  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8782  */
8783 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8784 {
8785   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8786   if(!content)
8787     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8788   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8789   std::size_t sz(contentsSplit.size());
8790   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8791   for(std::size_t i=0;i<sz;i++)
8792     {
8793       ret[i]=shallowCpy();
8794       ret[i]->_content=contentsSplit[i];
8795     }
8796   return ret;
8797 }
8798
8799 /*!
8800  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8801  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8802  */
8803 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8804 {
8805   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8806   if(!content)
8807     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8808   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8809   std::size_t sz(contentsSplit.size());
8810   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8811   for(std::size_t i=0;i<sz;i++)
8812     {
8813       ret[i]=shallowCpy();
8814       ret[i]->_content=contentsSplit[i];
8815     }
8816   return ret;
8817 }
8818
8819 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8820 {
8821   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8822   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8823     ret->_content=_content->deepCopy();
8824   ret->deepCpyGlobs(*this);
8825   return ret.retn();
8826 }
8827
8828 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8829 {
8830   return _content;
8831 }
8832
8833 /*!
8834  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8835  *  \param [in] iteration - the iteration number of a required time step.
8836  *  \param [in] order - the iteration order number of required time step.
8837  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8838  *          delete this field using decrRef() as it is no more needed.
8839  *  \throw If there is no required time step in \a this field.
8840  */
8841 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8842 {
8843   int pos=getPosOfTimeStep(iteration,order);
8844   return getTimeStepAtPos(pos);
8845 }
8846
8847 /*!
8848  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8849  *  \param [in] time - the time of the time step of interest.
8850  *  \param [in] eps - a precision used to compare time values.
8851  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8852  *          delete this field using decrRef() as it is no more needed.
8853  *  \throw If there is no required time step in \a this field.
8854  */
8855 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8856 {
8857   int pos=getPosGivenTime(time,eps);
8858   return getTimeStepAtPos(pos);
8859 }
8860
8861 /*!
8862  * 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.
8863  * The float64 value of time attached to the pair of integers are not considered here.
8864  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8865  *
8866  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8867  * \throw If there is a null pointer in \a vectFMTS.
8868  */
8869 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8870 {
8871   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8872   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8873   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8874   while(!lstFMTS.empty())
8875     {
8876       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8877       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8878       if(!curIt)
8879         throw INTERP_KERNEL::Exception(msg);
8880       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8881       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8882       elt.push_back(curIt); it=lstFMTS.erase(it);
8883       while(it!=lstFMTS.end())
8884         {
8885           curIt=*it;
8886           if(!curIt)
8887             throw INTERP_KERNEL::Exception(msg);
8888           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8889           if(refIts==curIts)
8890             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8891           else
8892             it++;
8893         }
8894       ret.push_back(elt);
8895     }
8896   return ret;
8897 }
8898
8899 /*!
8900  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8901  * All returned instances in a subvector can be safely loaded, rendered along time
8902  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8903  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8904  * 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).
8905  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8906  * 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.
8907  *
8908  * \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().
8909  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8910  * \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.
8911  * \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.
8912  *
8913  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8914  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8915  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8916  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8917  * \throw If mesh is null.
8918  * \throw If an element in \a vectFMTS is null.
8919  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8920  */
8921 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8922 {
8923   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8924   if(!mesh)
8925     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8926   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8927   if(vectFMTS.empty())
8928     return ret;
8929   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8930   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8931   if(!frstElt)
8932     throw INTERP_KERNEL::Exception(msg);
8933   std::size_t i=0;
8934   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8935   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8936   for(;it!=vectFMTS.end();it++,i++)
8937     {
8938       if(!(*it))
8939         throw INTERP_KERNEL::Exception(msg);
8940       TypeOfField tof0,tof1;
8941       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8942         {
8943           if(tof1!=ON_NODES)
8944             vectFMTSNotNodes.push_back(*it);
8945           else
8946             vectFMTSNodes.push_back(*it);
8947         }
8948       else
8949         vectFMTSNotNodes.push_back(*it);
8950     }
8951   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8952   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8953   ret=retCell;
8954   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8955     {
8956       i=0;
8957       bool isFetched(false);
8958       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8959         {
8960           if((*it0).empty())
8961             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8962           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8963             { ret[i].push_back(*it2); isFetched=true; }
8964         }
8965       if(!isFetched)
8966         {
8967           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8968           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8969           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8970         }
8971     }
8972   fsc=cmps;
8973   return ret;
8974 }
8975
8976 /*!
8977  * 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.
8978  * \param [out] cmps - same size than the returned vector.
8979  */
8980 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8981 {
8982   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8983   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8984   while(!lstFMTS.empty())
8985     {
8986       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8987       MEDFileAnyTypeFieldMultiTS *ref(*it);
8988       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8989       elt.push_back(ref); it=lstFMTS.erase(it);
8990       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8991       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8992       while(it!=lstFMTS.end())
8993         {
8994           MEDFileAnyTypeFieldMultiTS *curIt(*it);
8995           if(cmp->isEqual(curIt))
8996             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8997           else
8998             it++;
8999         }
9000       ret.push_back(elt); cmps.push_back(cmp);
9001     }
9002   return ret;
9003 }
9004
9005 /*!
9006  * 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.
9007  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9008  *
9009  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9010  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9011  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9012  * \thorw If \a f0 and \a f1 do not have the same times steps.
9013  * \throw If mesh is null.
9014  * \throw If \a f0 or \a f1 is null.
9015  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9016  */
9017 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9018 {
9019   if(!mesh)
9020     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9021   if(!f0 || !f1)
9022     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9023   if(f0->getMeshName()!=mesh->getName())
9024     {
9025       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9026       throw INTERP_KERNEL::Exception(oss.str());
9027     }
9028   if(f1->getMeshName()!=mesh->getName())
9029     {
9030       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9031       throw INTERP_KERNEL::Exception(oss.str());
9032     }
9033   int nts=f0->getNumberOfTS();
9034   if(nts!=f1->getNumberOfTS())
9035     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9036   if(nts==0)
9037     return nts;
9038   for(int i=0;i<nts;i++)
9039     {
9040       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9041       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9042       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9043       if(tofs0.size()!=1 || tofs1.size()!=1)
9044         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9045       if(i!=0)
9046         {
9047           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9048             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9049         }
9050       else
9051         { tof0=tofs0[0]; tof1=tofs1[0]; }
9052       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9053         {
9054           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() << ") !";
9055           throw INTERP_KERNEL::Exception(oss.str());
9056         }
9057       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9058         {
9059           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() << ") !";
9060           throw INTERP_KERNEL::Exception(oss.str());
9061         }
9062       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9063         {
9064           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() << ") !";
9065           throw INTERP_KERNEL::Exception(oss.str());
9066         }
9067     }
9068   return nts;
9069 }
9070
9071 /*!
9072  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9073  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9074  *
9075  * \return A new object that the caller is responsible to deallocate.
9076  */
9077 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9078 {
9079   if(!mm)
9080     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9081   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9082   int nbTS(getNumberOfTS());
9083   for(int i=0;i<nbTS;i++)
9084     {
9085       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9086       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9087       fmtsOut->pushBackTimeStep(f1tsOut);
9088     }
9089   return fmtsOut.retn();
9090 }
9091
9092 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9093 {
9094   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9095 }
9096
9097 //= MEDFileFieldMultiTS
9098
9099 /*!
9100  * Returns a new empty instance of MEDFileFieldMultiTS.
9101  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9102  *          is to delete this field using decrRef() as it is no more needed.
9103  */
9104 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9105 {
9106   return new MEDFileFieldMultiTS;
9107 }
9108
9109 /*!
9110  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9111  * that has been read from a specified MED file.
9112  *  \param [in] fileName - the name of the MED file to read.
9113  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9114  *          is to delete this field using decrRef() as it is no more needed.
9115  *  \throw If reading the file fails.
9116  */
9117 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9118 {
9119   MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
9120   ret->contentNotNull();//to check that content type matches with \a this type.
9121   return ret.retn();
9122 }
9123
9124 /*!
9125  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9126  * that has been read from a specified MED file.
9127  *  \param [in] fileName - the name of the MED file to read.
9128  *  \param [in] fieldName - the name of the field to read.
9129  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9130  *          is to delete this field using decrRef() as it is no more needed.
9131  *  \throw If reading the file fails.
9132  *  \throw If there is no field named \a fieldName in the file.
9133  */
9134 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9135 {
9136   MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
9137   ret->contentNotNull();//to check that content type matches with \a this type.
9138   return ret.retn();
9139 }
9140
9141 /*!
9142  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9143  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9144  *
9145  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9146  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9147  * \warning this is a shallow copy constructor
9148  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9149  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9150  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9151  *          is to delete this field using decrRef() as it is no more needed.
9152  */
9153 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9154 {
9155   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9156 }
9157
9158 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9159 {
9160   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
9161   ret->contentNotNull();//to check that content type matches with \a this type.
9162   return ret.retn();
9163 }
9164
9165 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9166 {
9167   return new MEDFileFieldMultiTS(*this);
9168 }
9169
9170 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9171 {
9172   if(!f1ts)
9173     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9174   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9175   if(!f1tsC)
9176     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9177 }
9178
9179 /*!
9180  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9181  * following the given input policy.
9182  *
9183  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9184  *                            By default (true) the globals are deeply copied.
9185  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9186  */
9187 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9188 {
9189   MCAuto<MEDFileIntFieldMultiTS> ret;
9190   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9191   if(content)
9192     {
9193       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9194       if(!contc)
9195         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9196       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9197       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9198     }
9199   else
9200     ret=MEDFileIntFieldMultiTS::New();
9201   if(isDeepCpyGlobs)
9202     ret->deepCpyGlobs(*this);
9203   else
9204     ret->shallowCpyGlobs(*this);
9205   return ret.retn();
9206 }
9207
9208 /*!
9209  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9210  *  \param [in] pos - a time step id.
9211  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9212  *          delete this field using decrRef() as it is no more needed.
9213  *  \throw If \a pos is not a valid time step id.
9214  */
9215 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9216 {
9217   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9218   if(!item)
9219     {
9220       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9221       throw INTERP_KERNEL::Exception(oss.str());
9222     }
9223   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9224   if(itemC)
9225     {
9226       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9227       ret->shallowCpyGlobs(*this);
9228       return ret.retn();
9229     }
9230   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9231   throw INTERP_KERNEL::Exception(oss.str());
9232 }
9233
9234 /*!
9235  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9236  * mesh entities of a given dimension of the first mesh in MED file.
9237  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9238  *  \param [in] type - a spatial discretization of interest.
9239  *  \param [in] iteration - the iteration number of a required time step.
9240  *  \param [in] order - the iteration order number of required time step.
9241  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9242  *  \param [in] renumPol - specifies how to permute values of the result field according to
9243  *          the optional numbers of cells and nodes, if any. The valid values are
9244  *          - 0 - do not permute.
9245  *          - 1 - permute cells.
9246  *          - 2 - permute nodes.
9247  *          - 3 - permute cells and nodes.
9248  *
9249  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9250  *          caller is to delete this field using decrRef() as it is no more needed. 
9251  *  \throw If the MED file is not readable.
9252  *  \throw If there is no mesh in the MED file.
9253  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9254  *  \throw If no field values of the required parameters are available.
9255  */
9256 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9257 {
9258   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9259   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9260   if(!myF1TSC)
9261     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9262   MCAuto<DataArray> arrOut;
9263   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9264   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9265   return ret.retn();
9266 }
9267
9268 /*!
9269  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9270  * the top level cells of the first mesh in MED file.
9271  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9272  *  \param [in] type - a spatial discretization of interest.
9273  *  \param [in] iteration - the iteration number of a required time step.
9274  *  \param [in] order - the iteration order number of required time step.
9275  *  \param [in] renumPol - specifies how to permute values of the result field according to
9276  *          the optional numbers of cells and nodes, if any. The valid values are
9277  *          - 0 - do not permute.
9278  *          - 1 - permute cells.
9279  *          - 2 - permute nodes.
9280  *          - 3 - permute cells and nodes.
9281  *
9282  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9283  *          caller is to delete this field using decrRef() as it is no more needed. 
9284  *  \throw If the MED file is not readable.
9285  *  \throw If there is no mesh in the MED file.
9286  *  \throw If no field values of the required parameters are available.
9287  */
9288 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9289 {
9290   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9291   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9292   if(!myF1TSC)
9293     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9294   MCAuto<DataArray> arrOut;
9295   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9296   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9297   return ret.retn();
9298 }
9299
9300 /*!
9301  * 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
9302  * method should be called (getFieldOnMeshAtLevel for example).
9303  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9304  *
9305  * \param [in] iteration - the iteration number of a required time step.
9306  * \param [in] order - the iteration order number of required time step.
9307  * \param [in] mesh - the mesh the field is lying on
9308  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9309  *          caller is to delete this field using decrRef() as it is no more needed. 
9310  */
9311 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9312 {
9313   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9314   MCAuto<DataArray> arrOut;
9315   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9316   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9317   return ret.retn();
9318 }
9319
9320 /*!
9321  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9322  * a given support.
9323  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9324  *  \param [in] type - a spatial discretization of interest.
9325  *  \param [in] iteration - the iteration number of a required time step.
9326  *  \param [in] order - the iteration order number of required time step.
9327  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9328  *  \param [in] mesh - the supporting mesh.
9329  *  \param [in] renumPol - specifies how to permute values of the result field according to
9330  *          the optional numbers of cells and nodes, if any. The valid values are
9331  *          - 0 - do not permute.
9332  *          - 1 - permute cells.
9333  *          - 2 - permute nodes.
9334  *          - 3 - permute cells and nodes.
9335  *
9336  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9337  *          caller is to delete this field using decrRef() as it is no more needed. 
9338  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9339  *  \throw If no field of \a this is lying on \a mesh.
9340  *  \throw If no field values of the required parameters are available.
9341  */
9342 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9343 {
9344   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9345   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9346   if(!myF1TSC)
9347     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9348   MCAuto<DataArray> arrOut;
9349   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9350   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9351   return ret.retn();
9352 }
9353
9354 /*!
9355  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9356  * given support. 
9357  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9358  *  \param [in] type - a spatial discretization of the new field.
9359  *  \param [in] iteration - the iteration number of a required time step.
9360  *  \param [in] order - the iteration order number of required time step.
9361  *  \param [in] mesh - the supporting mesh.
9362  *  \param [in] renumPol - specifies how to permute values of the result field according to
9363  *          the optional numbers of cells and nodes, if any. The valid values are
9364  *          - 0 - do not permute.
9365  *          - 1 - permute cells.
9366  *          - 2 - permute nodes.
9367  *          - 3 - permute cells and nodes.
9368  *
9369  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9370  *          caller is to delete this field using decrRef() as it is no more needed. 
9371  *  \throw If no field of \a this is lying on \a mesh.
9372  *  \throw If no field values of the required parameters are available.
9373  */
9374 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9375 {
9376   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9377   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9378   if(!myF1TSC)
9379     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9380   MCAuto<DataArray> arrOut;
9381   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9382   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9383   return ret.retn();
9384 }
9385
9386 /*!
9387  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9388  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9389  * This method is useful for MED2 file format when field on different mesh was autorized.
9390  */
9391 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9392 {
9393   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9394   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9395   if(!myF1TSC)
9396     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9397   MCAuto<DataArray> arrOut;
9398   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9399   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9400   return ret.retn();
9401 }
9402
9403 /*!
9404  * Returns values and a profile of the field of a given type, of a given time step,
9405  * lying on a given support.
9406  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9407  *  \param [in] type - a spatial discretization of the field.
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 [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9413  *          field of interest lies on. If the field lies on all entities of the given
9414  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9415  *          using decrRef() as it is no more needed.  
9416  *  \param [in] glob - the global data storing profiles and localization.
9417  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9418  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9419  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9420  *  \throw If no field of \a this is lying on \a mesh.
9421  *  \throw If no field values of the required parameters are available.
9422  */
9423 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9424 {
9425   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9426   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9427   if(!myF1TSC)
9428     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9429   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9430   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9431 }
9432
9433 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9434 {
9435   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9436   if(!pt)
9437     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9438   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9439   if(!ret)
9440     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 !");
9441   return ret;
9442 }
9443
9444 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9445 {
9446   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9447   if(!pt)
9448     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9449   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9450   if(!ret)
9451     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 !");
9452   return ret;
9453 }
9454
9455 /*!
9456  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9457  * the given field is checked if its elements are sorted suitable for writing to MED file
9458  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9459  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9460  *  \param [in] field - the field to add to \a this.
9461  *  \throw If the name of \a field is empty.
9462  *  \throw If the data array of \a field is not set.
9463  *  \throw If existing time steps have different name or number of components than \a field.
9464  *  \throw If the underlying mesh of \a field has no name.
9465  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9466  */
9467 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9468 {
9469   const DataArrayDouble *arr=0;
9470   if(field)
9471     arr=field->getArray();
9472   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9473 }
9474
9475 /*!
9476  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9477  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9478  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9479  * and \a profile.
9480  *
9481  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9482  * A new profile is added only if no equal profile is missing.
9483  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9484  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9485  *  \param [in] mesh - the supporting mesh of \a field.
9486  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9487  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9488  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9489  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9490  *  \throw If the data array of \a field is not set.
9491  *  \throw If the data array of \a this is already allocated but has different number of
9492  *         components than \a field.
9493  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9494  *  \sa setFieldNoProfileSBT()
9495  */
9496 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9497 {
9498   const DataArrayDouble *arr=0;
9499   if(field)
9500     arr=field->getArray();
9501   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9502 }
9503
9504 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9505 {
9506   _content=new MEDFileFieldMultiTSWithoutSDA;
9507 }
9508
9509 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9510 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9511 {
9512 }
9513 catch(INTERP_KERNEL::Exception& e)
9514 { throw e; }
9515
9516 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9517 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9518 {
9519 }
9520 catch(INTERP_KERNEL::Exception& e)
9521 { throw e; }
9522
9523 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9524 {
9525 }
9526
9527 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
9528 {
9529   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9530 }
9531
9532 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9533 {
9534   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9535 }
9536
9537 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9538 {
9539   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9540 }
9541
9542 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9543 {
9544   return MEDFileFieldMultiTS::New();
9545 }
9546
9547 //= MEDFileAnyTypeFieldMultiTSIterator
9548
9549 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9550 {
9551   if(fmts)
9552     {
9553       fmts->incrRef();
9554       _nb_iter=fmts->getNumberOfTS();
9555     }
9556 }
9557
9558 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9559 {
9560 }
9561
9562 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9563 {
9564   if(_iter_id<_nb_iter)
9565     {
9566       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9567       if(fmts)
9568         return fmts->getTimeStepAtPos(_iter_id++);
9569       else
9570         return 0;
9571     }
9572   else
9573     return 0;
9574 }
9575
9576 //= MEDFileIntFieldMultiTS
9577
9578 /*!
9579  * Returns a new empty instance of MEDFileFieldMultiTS.
9580  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9581  *          is to delete this field using decrRef() as it is no more needed.
9582  */
9583 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9584 {
9585   return new MEDFileIntFieldMultiTS;
9586 }
9587
9588 /*!
9589  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9590  * that has been read from a specified MED file.
9591  *  \param [in] fileName - the name of the MED file to read.
9592  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9593  *          is to delete this field using decrRef() as it is no more needed.
9594  *  \throw If reading the file fails.
9595  */
9596 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9597 {
9598   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9599   ret->contentNotNull();//to check that content type matches with \a this type.
9600   return ret.retn();
9601 }
9602
9603 /*!
9604  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9605  * that has been read from a specified MED file.
9606  *  \param [in] fileName - the name of the MED file to read.
9607  *  \param [in] fieldName - the name of the field to read.
9608  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9609  *          is to delete this field using decrRef() as it is no more needed.
9610  *  \throw If reading the file fails.
9611  *  \throw If there is no field named \a fieldName in the file.
9612  */
9613 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9614 {
9615   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9616   ret->contentNotNull();//to check that content type matches with \a this type.
9617   return ret.retn();
9618 }
9619
9620 /*!
9621  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9622  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9623  *
9624  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9625  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9626  * \warning this is a shallow copy constructor
9627  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9628  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9629  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9630  *          is to delete this field using decrRef() as it is no more needed.
9631  */
9632 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9633 {
9634   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9635 }
9636
9637 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9638 {
9639   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9640   ret->contentNotNull();//to check that content type matches with \a this type.
9641   return ret.retn();
9642 }
9643
9644 /*!
9645  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9646  * following the given input policy.
9647  *
9648  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9649  *                            By default (true) the globals are deeply copied.
9650  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9651  */
9652 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9653 {
9654   MCAuto<MEDFileFieldMultiTS> ret;
9655   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9656   if(content)
9657     {
9658       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9659       if(!contc)
9660         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9661       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9662       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9663     }
9664   else
9665     ret=MEDFileFieldMultiTS::New();
9666   if(isDeepCpyGlobs)
9667     ret->deepCpyGlobs(*this);
9668   else
9669     ret->shallowCpyGlobs(*this);
9670   return ret.retn();
9671 }
9672
9673 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9674 {
9675   return new MEDFileIntFieldMultiTS(*this);
9676 }
9677
9678 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9679 {
9680   if(!f1ts)
9681     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9682   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9683   if(!f1tsC)
9684     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9685 }
9686
9687 /*!
9688  * 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
9689  * method should be called (getFieldOnMeshAtLevel for example).
9690  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9691  *
9692  * \param [in] iteration - the iteration number of a required time step.
9693  * \param [in] order - the iteration order number of required time step.
9694  * \param [in] mesh - the mesh the field is lying on
9695  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9696  *          caller is to delete this field using decrRef() as it is no more needed. 
9697  */
9698 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9699 {
9700   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9701   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9702   if(!myF1TSC)
9703     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9704   MCAuto<DataArray> arrOut;
9705   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9706   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9707   return ret2.retn();
9708 }
9709
9710 /*!
9711  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9712  * mesh entities of a given dimension of the first mesh in MED file.
9713  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9714  *  \param [in] type - a spatial discretization of interest.
9715  *  \param [in] iteration - the iteration number of a required time step.
9716  *  \param [in] order - the iteration order number of required time step.
9717  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9718  *  \param [in] renumPol - specifies how to permute values of the result field according to
9719  *          the optional numbers of cells and nodes, if any. The valid values are
9720  *          - 0 - do not permute.
9721  *          - 1 - permute cells.
9722  *          - 2 - permute nodes.
9723  *          - 3 - permute cells and nodes.
9724  *
9725  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9726  *          caller is to delete this field using decrRef() as it is no more needed. 
9727  *  \throw If the MED file is not readable.
9728  *  \throw If there is no mesh in the MED file.
9729  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9730  *  \throw If no field values of the required parameters are available.
9731  */
9732 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9733 {
9734   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9735   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9736   if(!myF1TSC)
9737     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9738   MCAuto<DataArray> arr;
9739   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9740   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9741   return ret2.retn();
9742 }
9743
9744 /*!
9745  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9746  * the top level cells of the first mesh in MED file.
9747  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9748  *  \param [in] type - a spatial discretization of interest.
9749  *  \param [in] iteration - the iteration number of a required time step.
9750  *  \param [in] order - the iteration order number of required time step.
9751  *  \param [in] renumPol - specifies how to permute values of the result field according to
9752  *          the optional numbers of cells and nodes, if any. The valid values are
9753  *          - 0 - do not permute.
9754  *          - 1 - permute cells.
9755  *          - 2 - permute nodes.
9756  *          - 3 - permute cells and nodes.
9757  *
9758  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9759  *          caller is to delete this field using decrRef() as it is no more needed. 
9760  *  \throw If the MED file is not readable.
9761  *  \throw If there is no mesh in the MED file.
9762  *  \throw If no field values of the required parameters are available.
9763  */
9764 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9765 {
9766   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9767   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9768   if(!myF1TSC)
9769     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9770   MCAuto<DataArray> arr;
9771   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9772   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9773   return ret2.retn();
9774 }
9775
9776 /*!
9777  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9778  * a given support.
9779  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9780  *  \param [in] type - a spatial discretization of interest.
9781  *  \param [in] iteration - the iteration number of a required time step.
9782  *  \param [in] order - the iteration order number of required time step.
9783  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9784  *  \param [in] mesh - the supporting mesh.
9785  *  \param [in] renumPol - specifies how to permute values of the result field according to
9786  *          the optional numbers of cells and nodes, if any. The valid values are
9787  *          - 0 - do not permute.
9788  *          - 1 - permute cells.
9789  *          - 2 - permute nodes.
9790  *          - 3 - permute cells and nodes.
9791  *
9792  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9793  *          caller is to delete this field using decrRef() as it is no more needed. 
9794  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9795  *  \throw If no field of \a this is lying on \a mesh.
9796  *  \throw If no field values of the required parameters are available.
9797  */
9798 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9799 {
9800   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9801   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9802   if(!myF1TSC)
9803     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9804   MCAuto<DataArray> arr;
9805   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9806   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9807   return ret2.retn();
9808 }
9809
9810 /*!
9811  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9812  * given support. 
9813  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9814  *  \param [in] type - a spatial discretization of the new field.
9815  *  \param [in] iteration - the iteration number of a required time step.
9816  *  \param [in] order - the iteration order number of required time step.
9817  *  \param [in] mesh - the supporting mesh.
9818  *  \param [out] arrOut - the DataArrayInt containing values of field.
9819  *  \param [in] renumPol - specifies how to permute values of the result field according to
9820  *          the optional numbers of cells and nodes, if any. The valid values are
9821  *          - 0 - do not permute.
9822  *          - 1 - permute cells.
9823  *          - 2 - permute nodes.
9824  *          - 3 - permute cells and nodes.
9825  *
9826  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9827  *          caller is to delete this field using decrRef() as it is no more needed. 
9828  *  \throw If no field of \a this is lying on \a mesh.
9829  *  \throw If no field values of the required parameters are available.
9830  */
9831 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9832 {
9833   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9834   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9835   if(!myF1TSC)
9836     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9837   MCAuto<DataArray> arr;
9838   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9839   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9840   return ret2.retn();
9841 }
9842
9843 /*!
9844  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9845  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9846  * This method is useful for MED2 file format when field on different mesh was autorized.
9847  */
9848 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9849 {
9850   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9851   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9852   if(!myF1TSC)
9853     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9854   MCAuto<DataArray> arr;
9855   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9856   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9857   return ret2.retn();
9858 }
9859
9860 /*!
9861  * Returns values and a profile of the field of a given type, of a given time step,
9862  * lying on a given support.
9863  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9864  *  \param [in] type - a spatial discretization of the field.
9865  *  \param [in] iteration - the iteration number of a required time step.
9866  *  \param [in] order - the iteration order number of required time step.
9867  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9868  *  \param [in] mesh - the supporting mesh.
9869  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9870  *          field of interest lies on. If the field lies on all entities of the given
9871  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9872  *          using decrRef() as it is no more needed.  
9873  *  \param [in] glob - the global data storing profiles and localization.
9874  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9875  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9876  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9877  *  \throw If no field of \a this is lying on \a mesh.
9878  *  \throw If no field values of the required parameters are available.
9879  */
9880 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9881 {
9882   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9883   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9884   if(!myF1TSC)
9885     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9886   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9887   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9888 }
9889
9890 /*!
9891  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9892  *  \param [in] pos - a time step id.
9893  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9894  *          delete this field using decrRef() as it is no more needed.
9895  *  \throw If \a pos is not a valid time step id.
9896  */
9897 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9898 {
9899   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9900   if(!item)
9901     {
9902       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9903       throw INTERP_KERNEL::Exception(oss.str());
9904     }
9905   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9906   if(itemC)
9907     {
9908       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9909       ret->shallowCpyGlobs(*this);
9910       return ret.retn();
9911     }
9912   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9913   throw INTERP_KERNEL::Exception(oss.str());
9914 }
9915
9916 /*!
9917  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
9918  * the given field is checked if its elements are sorted suitable for writing to MED file
9919  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9920  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9921  *  \param [in] field - the field to add to \a this.
9922  *  \throw If the name of \a field is empty.
9923  *  \throw If the data array of \a field is not set.
9924  *  \throw If existing time steps have different name or number of components than \a field.
9925  *  \throw If the underlying mesh of \a field has no name.
9926  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9927  */
9928 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
9929 {
9930   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9931   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
9932 }
9933
9934 /*!
9935  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
9936  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9937  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9938  * and \a profile.
9939  *
9940  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9941  * A new profile is added only if no equal profile is missing.
9942  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9943  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9944  *  \param [in] arrOfVals - the values of the field \a field used.
9945  *  \param [in] mesh - the supporting mesh of \a field.
9946  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9947  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9948  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9949  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9950  *  \throw If the data array of \a field is not set.
9951  *  \throw If the data array of \a this is already allocated but has different number of
9952  *         components than \a field.
9953  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9954  *  \sa setFieldNoProfileSBT()
9955  */
9956 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9957 {
9958   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9959   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
9960 }
9961
9962 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9963 {
9964   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9965   if(!pt)
9966     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9967   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9968   if(!ret)
9969     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 !");
9970   return ret;
9971 }
9972
9973 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9974 {
9975   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9976   if(!pt)
9977     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9978   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9979   if(!ret)
9980     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 !");
9981   return ret;
9982 }
9983
9984 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9985 {
9986   _content=new MEDFileIntFieldMultiTSWithoutSDA;
9987 }
9988
9989 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9990 {
9991 }
9992
9993 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9994 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9995 {
9996 }
9997 catch(INTERP_KERNEL::Exception& e)
9998 { throw e; }
9999
10000 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10001 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
10002 {
10003 }
10004 catch(INTERP_KERNEL::Exception& e)
10005 { throw e; }
10006
10007 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10008 {
10009   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10010 }
10011
10012 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10013 {
10014   return MEDFileIntFieldMultiTS::New();
10015 }
10016
10017 //= MEDFileFields
10018
10019 MEDFileFields *MEDFileFields::New()
10020 {
10021   return new MEDFileFields;
10022 }
10023
10024 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10025 {
10026   return new MEDFileFields(fileName,loadAll,0,0);
10027 }
10028
10029 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10030 {
10031   return new MEDFileFields(fileName,loadAll,ms,0);
10032 }
10033
10034 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10035 {
10036   return new MEDFileFields(fileName,loadAll,0,&entities);
10037 }
10038
10039 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10040 {
10041   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10042   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10043   return ret;
10044 }
10045
10046 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10047 {
10048   std::vector<const BigMemoryObject *> ret;
10049   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10050     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10051   return ret;
10052 }
10053
10054 MEDFileFields *MEDFileFields::deepCopy() const
10055 {
10056   MCAuto<MEDFileFields> ret=shallowCpy();
10057   std::size_t i=0;
10058   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10059     {
10060       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10061         ret->_fields[i]=(*it)->deepCopy();
10062     }
10063   ret->deepCpyGlobs(*this);
10064   return ret.retn();
10065 }
10066
10067 MEDFileFields *MEDFileFields::shallowCpy() const
10068 {
10069   return new MEDFileFields(*this);
10070 }
10071
10072 /*!
10073  * 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
10074  * 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.
10075  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10076  *
10077  * \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.
10078  * \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.
10079  * 
10080  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10081  */
10082 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10083 {
10084   std::set< std::pair<int,int> > s;
10085   bool firstShot=true;
10086   areThereSomeForgottenTS=false;
10087   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10088     {
10089       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10090         continue;
10091       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10092       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10093       if(firstShot)
10094         { s=s1; firstShot=false; }
10095       else
10096         {
10097           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10098           if(s!=s2)
10099             areThereSomeForgottenTS=true;
10100           s=s2;
10101         }
10102     }
10103   std::vector< std::pair<int,int> > ret;
10104   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10105   return ret;
10106 }
10107
10108 int MEDFileFields::getNumberOfFields() const
10109 {
10110   return _fields.size();
10111 }
10112
10113 std::vector<std::string> MEDFileFields::getFieldsNames() const
10114 {
10115   std::vector<std::string> ret(_fields.size());
10116   int i=0;
10117   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10118     {
10119       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10120       if(f)
10121         {
10122           ret[i]=f->getName();
10123         }
10124       else
10125         {
10126           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10127           throw INTERP_KERNEL::Exception(oss.str());
10128         }
10129     }
10130   return ret;
10131 }
10132
10133 std::vector<std::string> MEDFileFields::getMeshesNames() const
10134 {
10135   std::vector<std::string> ret;
10136   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10137     {
10138       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10139       if(cur)
10140         ret.push_back(cur->getMeshName());
10141     }
10142   return ret;
10143 }
10144
10145 std::string MEDFileFields::simpleRepr() const
10146 {
10147   std::ostringstream oss;
10148   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10149   simpleRepr(0,oss);
10150   return oss.str();
10151 }
10152
10153 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10154 {
10155   int nbOfFields=getNumberOfFields();
10156   std::string startLine(bkOffset,' ');
10157   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10158   int i=0;
10159   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10160     {
10161       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10162       if(cur)
10163         {
10164           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10165         }
10166       else
10167         {
10168           oss << startLine << "  - not defined !" << std::endl;
10169         }
10170     }
10171   i=0;
10172   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10173     {
10174       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10175       std::string chapter(17,'0'+i);
10176       oss << startLine << chapter << std::endl;
10177       if(cur)
10178         {
10179           cur->simpleRepr(bkOffset+2,oss,i);
10180         }
10181       else
10182         {
10183           oss << startLine << "  - not defined !" << std::endl;
10184         }
10185       oss << startLine << chapter << std::endl;
10186     }
10187   simpleReprGlobs(oss);
10188 }
10189
10190 MEDFileFields::MEDFileFields()
10191 {
10192 }
10193
10194 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10195 try:MEDFileFieldGlobsReal(fileName)
10196 {
10197   MEDFileUtilities::CheckFileForRead(fileName);
10198   MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
10199   int nbFields(MEDnField(fid));
10200   _fields.resize(nbFields);
10201   med_field_type typcha;
10202   for(int i=0;i<nbFields;i++)
10203     {
10204       std::vector<std::string> infos;
10205       std::string fieldName,dtunit;
10206       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
10207       switch(typcha)
10208       {
10209         case MED_FLOAT64:
10210           {
10211             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10212             break;
10213           }
10214         case MED_INT32:
10215           {
10216             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10217             break;
10218           }
10219         default:
10220           {
10221             std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10222             throw INTERP_KERNEL::Exception(oss.str());
10223           }
10224       }
10225     }
10226   loadAllGlobals(fid);
10227 }
10228 catch(INTERP_KERNEL::Exception& e)
10229 {
10230     throw e;
10231 }
10232
10233 void MEDFileFields::writeLL(med_idt fid) const
10234 {
10235   int i=0;
10236   writeGlobals(fid,*this);
10237   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10238     {
10239       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10240       if(!elt)
10241         {
10242           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10243           throw INTERP_KERNEL::Exception(oss.str());
10244         }
10245       elt->writeLL(fid,*this);
10246     }
10247 }
10248
10249 void MEDFileFields::write(const std::string& fileName, int mode) const
10250 {
10251   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10252   MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10253   writeLL(fid);
10254 }
10255
10256 /*!
10257  * This method alloc the arrays and load potentially huge arrays contained in this field.
10258  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10259  * This method can be also called to refresh or reinit values from a file.
10260  * 
10261  * \throw If the fileName is not set or points to a non readable MED file.
10262  */
10263 void MEDFileFields::loadArrays()
10264 {
10265   if(getFileName().empty())
10266     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10267   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10268   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10269     {
10270       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10271       if(elt)
10272         elt->loadBigArraysRecursively(fid,*elt);
10273     }
10274 }
10275
10276 /*!
10277  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10278  * But once data loaded once, this method does nothing.
10279  * 
10280  * \throw If the fileName is not set or points to a non readable MED file.
10281  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10282  */
10283 void MEDFileFields::loadArraysIfNecessary()
10284 {
10285   if(!getFileName().empty())
10286     {
10287       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10288       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10289         {
10290           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10291           if(elt)
10292             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10293         }
10294     }
10295 }
10296
10297 /*!
10298  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10299  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10300  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10301  * 
10302  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10303  */
10304 void MEDFileFields::unloadArrays()
10305 {
10306   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10307     {
10308       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10309       if(elt)
10310         elt->unloadArrays();
10311     }
10312 }
10313
10314 /*!
10315  * 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.
10316  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10317  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10318  * 
10319  * \sa MEDFileFields::loadArraysIfNecessary
10320  */
10321 void MEDFileFields::unloadArraysWithoutDataLoss()
10322 {
10323   if(!getFileName().empty())
10324     unloadArrays();
10325 }
10326
10327 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10328 {
10329   std::vector<std::string> ret;
10330   std::set<std::string> ret2;
10331   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10332     {
10333       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10334       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10335         if(ret2.find(*it2)==ret2.end())
10336           {
10337             ret.push_back(*it2);
10338             ret2.insert(*it2);
10339           }
10340     }
10341   return ret;
10342 }
10343
10344 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10345 {
10346   std::vector<std::string> ret;
10347   std::set<std::string> ret2;
10348   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10349     {
10350       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10351       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10352         if(ret2.find(*it2)==ret2.end())
10353           {
10354             ret.push_back(*it2);
10355             ret2.insert(*it2);
10356           }
10357     }
10358   return ret;
10359 }
10360
10361 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10362 {
10363   std::vector<std::string> ret;
10364   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10365     {
10366       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10367       ret.insert(ret.end(),tmp.begin(),tmp.end());
10368     }
10369   return ret;
10370 }
10371
10372 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10373 {
10374   std::vector<std::string> ret;
10375   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10376     {
10377       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10378       ret.insert(ret.end(),tmp.begin(),tmp.end());
10379     }
10380   return ret;
10381 }
10382
10383 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10384 {
10385   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10386     (*it)->changePflsRefsNamesGen2(mapOfModif);
10387 }
10388
10389 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10390 {
10391   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10392     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10393 }
10394
10395 void MEDFileFields::resize(int newSize)
10396 {
10397   _fields.resize(newSize);
10398 }
10399
10400 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10401 {
10402   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10403     pushField(*it);
10404 }
10405
10406 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10407 {
10408   if(!field)
10409     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10410   _fields.push_back(field->getContent());
10411   appendGlobs(*field,1e-12);
10412 }
10413
10414 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10415 {
10416   if(!field)
10417     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10418   if(i>=(int)_fields.size())
10419     _fields.resize(i+1);
10420   _fields[i]=field->getContent();
10421   appendGlobs(*field,1e-12);
10422 }
10423
10424 void MEDFileFields::destroyFieldAtPos(int i)
10425 {
10426   destroyFieldsAtPos(&i,&i+1);
10427 }
10428
10429 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10430 {
10431   std::vector<bool> b(_fields.size(),true);
10432   for(const int *i=startIds;i!=endIds;i++)
10433     {
10434       if(*i<0 || *i>=(int)_fields.size())
10435         {
10436           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10437           throw INTERP_KERNEL::Exception(oss.str());
10438         }
10439       b[*i]=false;
10440     }
10441   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10442   std::size_t j=0;
10443   for(std::size_t i=0;i<_fields.size();i++)
10444     if(b[i])
10445       fields[j++]=_fields[i];
10446   _fields=fields;
10447 }
10448
10449 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10450 {
10451   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10452   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10453   std::vector<bool> b(_fields.size(),true);
10454   int k=bg;
10455   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10456     {
10457       if(k<0 || k>=(int)_fields.size())
10458         {
10459           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10460           throw INTERP_KERNEL::Exception(oss.str());
10461         }
10462       b[k]=false;
10463     }
10464   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10465   std::size_t j=0;
10466   for(std::size_t i=0;i<_fields.size();i++)
10467     if(b[i])
10468       fields[j++]=_fields[i];
10469   _fields=fields;
10470 }
10471
10472 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10473 {
10474   bool ret=false;
10475   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10476     {
10477       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10478       if(cur)
10479         ret=cur->changeMeshNames(modifTab) || ret;
10480     }
10481   return ret;
10482 }
10483
10484 /*!
10485  * \param [in] meshName the name of the mesh that will be renumbered.
10486  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10487  *             This code corresponds to the distribution of types in the corresponding mesh.
10488  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10489  * \param [in] renumO2N the old to new renumber array.
10490  * \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 
10491  *         field in \a this.
10492  */
10493 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10494 {
10495   bool ret=false;
10496   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10497     {
10498       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10499       if(fmts)
10500         {
10501           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10502         }
10503     }
10504   return ret;
10505 }
10506
10507 /*!
10508  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10509  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10510  *
10511  * \return A new object that the caller is responsible to deallocate.
10512  */
10513 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10514 {
10515   if(!mm)
10516     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10517   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10518   int nbFields(getNumberOfFields());
10519   for(int i=0;i<nbFields;i++)
10520     {
10521       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10522       if(!fmts)
10523         {
10524           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10525           throw INTERP_KERNEL::Exception(oss.str());
10526         }
10527       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10528       fsOut->pushField(fmtsOut);
10529     }
10530   return fsOut.retn();
10531 }
10532
10533 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10534 {
10535   if(i<0 || i>=(int)_fields.size())
10536     {
10537       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10538       throw INTERP_KERNEL::Exception(oss.str());
10539     }
10540   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10541   if(!fmts)
10542     return 0;
10543   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10544   const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10545   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10546   if(fmtsC)
10547     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10548   else if(fmtsC2)
10549     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10550   else
10551     {
10552       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10553       throw INTERP_KERNEL::Exception(oss.str());
10554     }
10555   ret->shallowCpyGlobs(*this);
10556   return ret.retn();
10557 }
10558
10559 /*!
10560  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10561  * This method is accessible in python using __getitem__ with a list in input.
10562  * \return a new object that the caller should deal with.
10563  */
10564 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10565 {
10566   MCAuto<MEDFileFields> ret=shallowCpy();
10567   std::size_t sz=std::distance(startIds,endIds);
10568   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10569   int j=0;
10570   for(const int *i=startIds;i!=endIds;i++,j++)
10571     {
10572       if(*i<0 || *i>=(int)_fields.size())
10573         {
10574           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10575           throw INTERP_KERNEL::Exception(oss.str());
10576         }
10577       fields[j]=_fields[*i];
10578     }
10579   ret->_fields=fields;
10580   return ret.retn();
10581 }
10582
10583 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10584 {
10585   return getFieldAtPos(getPosFromFieldName(fieldName));
10586 }
10587
10588 /*!
10589  * This method removes, if any, fields in \a this having no time steps.
10590  * 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.
10591  * 
10592  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10593  */
10594 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10595 {
10596   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10597   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10598     {
10599       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10600       if(elt)
10601         {
10602           if(elt->getNumberOfTS()>0)
10603             newFields.push_back(*it);
10604         }
10605     }
10606   if(_fields.size()==newFields.size())
10607     return false;
10608   _fields=newFields;
10609   return true;
10610 }
10611
10612 /*!
10613  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10614  * This method can be seen as a filter applied on \a this, that returns an object containing
10615  * 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
10616  * shallow copied from \a this.
10617  * 
10618  * \param [in] meshName - the name of the mesh on w
10619  * \return a new object that the caller should deal with.
10620  */
10621 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10622 {
10623   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10624   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10625     {
10626       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10627       if(!cur)
10628         continue;
10629       if(cur->getMeshName()==meshName)
10630         {
10631           cur->incrRef();
10632           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10633           ret->_fields.push_back(cur2);
10634         }
10635     }
10636   ret->shallowCpyOnlyUsedGlobs(*this);
10637   return ret.retn();
10638 }
10639
10640 /*!
10641  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10642  * Input time steps are specified using a pair of integer (iteration, order).
10643  * 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,
10644  * but for each multitimestep only the time steps in \a timeSteps are kept.
10645  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10646  * 
10647  * The returned object points to shallow copy of elements in \a this.
10648  * 
10649  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10650  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10651  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10652  */
10653 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10654 {
10655   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10656   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10657     {
10658       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10659       if(!cur)
10660         continue;
10661       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10662       ret->_fields.push_back(elt);
10663     }
10664   ret->shallowCpyOnlyUsedGlobs(*this);
10665   return ret.retn();
10666 }
10667
10668 /*!
10669  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10670  */
10671 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10672 {
10673   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10674   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10675     {
10676       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10677       if(!cur)
10678         continue;
10679       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10680       if(elt->getNumberOfTS()!=0)
10681         ret->_fields.push_back(elt);
10682     }
10683   ret->shallowCpyOnlyUsedGlobs(*this);
10684   return ret.retn();
10685 }
10686
10687 MEDFileFieldsIterator *MEDFileFields::iterator()
10688 {
10689   return new MEDFileFieldsIterator(this);
10690 }
10691
10692 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10693 {
10694   std::string tmp(fieldName);
10695   std::vector<std::string> poss;
10696   for(std::size_t i=0;i<_fields.size();i++)
10697     {
10698       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10699       if(f)
10700         {
10701           std::string fname(f->getName());
10702           if(tmp==fname)
10703             return i;
10704           else
10705             poss.push_back(fname);
10706         }
10707     }
10708   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10709   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10710   oss << " !";
10711   throw INTERP_KERNEL::Exception(oss.str());
10712 }
10713
10714 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10715 {
10716   if(fs)
10717     {
10718       fs->incrRef();
10719       _nb_iter=fs->getNumberOfFields();
10720     }
10721 }
10722
10723 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10724 {
10725 }
10726
10727 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10728 {
10729   if(_iter_id<_nb_iter)
10730     {
10731       MEDFileFields *fs(_fs);
10732       if(fs)
10733         return fs->getFieldAtPos(_iter_id++);
10734       else
10735         return 0;
10736     }
10737   else
10738     return 0;
10739 }