Salome HOME
52b6b06576bf6a9900def8762dcbe46e21c03b28
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2013  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.
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
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
28
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
31
32 #include <algorithm>
33 #include <iterator>
34
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
39
40 using namespace ParaMEDMEM;
41
42 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
43 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
44
45 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
46 {
47   return new MEDFileFieldLoc(fid,locName);
48 }
49
50 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
51 {
52   return new MEDFileFieldLoc(fid,id);
53 }
54
55 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
56 {
57   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
58 }
59
60 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
61 {
62   med_geometry_type geotype;
63   med_geometry_type sectiongeotype;
64   int nsectionmeshcell;
65   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
66   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67   MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
68   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
69   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
70   _nb_node_per_cell=cm.getNumberOfNodes();
71   _ref_coo.resize(_dim*_nb_node_per_cell);
72   _gs_coo.resize(_dim*_nb_gauss_pt);
73   _w.resize(_nb_gauss_pt);
74   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
75 }
76
77 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
78 {
79   med_geometry_type geotype;
80   med_geometry_type sectiongeotype;
81   int nsectionmeshcell;
82   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
83   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
86   _name=locName;
87   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
88   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
89   _nb_node_per_cell=cm.getNumberOfNodes();
90   _ref_coo.resize(_dim*_nb_node_per_cell);
91   _gs_coo.resize(_dim*_nb_gauss_pt);
92   _w.resize(_nb_gauss_pt);
93   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
94 }
95
96 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
97                                  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),
98                                                                                                                                     _w(w)
99 {
100   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
101   _dim=cm.getDimension();
102   _nb_node_per_cell=cm.getNumberOfNodes();
103   _nb_gauss_pt=_w.size();
104 }
105
106 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
107 {
108   return new MEDFileFieldLoc(*this);
109 }
110
111 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
112 {
113   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
114 }
115
116 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
117 {
118   static const char OFF7[]="\n    ";
119   oss << "\"" << _name << "\"" << OFF7;
120   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
121   oss << "Dimension=" << _dim << OFF7;
122   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
123   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
124   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
125   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
127 }
128
129 void MEDFileFieldLoc::setName(const char *name)
130 {
131   _name=name;
132 }
133
134 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
135 {
136   if(_name!=other._name)
137     return false;
138   if(_dim!=other._dim)
139     return false;
140   if(_nb_gauss_pt!=other._nb_gauss_pt)
141     return false;
142   if(_nb_node_per_cell!=other._nb_node_per_cell)
143     return false;
144   if(_geo_type!=other._geo_type)
145     return false;
146   if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
147     return false;
148   if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
149     return false;
150   if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
151     return false;
152   
153   return true;
154 }
155
156 void MEDFileFieldLoc::writeLL(med_idt fid) const
157 {
158   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);
159 }
160
161 std::string MEDFileFieldLoc::repr() const
162 {
163   std::ostringstream oss; oss.precision(15);
164   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
165   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
166   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
167   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
168   oss << "\n  - Ref coords are : ";
169   int sz=_ref_coo.size();
170   if(sz%_dim==0)
171     {
172       int nbOfTuples=sz/_dim;
173       for(int i=0;i<nbOfTuples;i++)
174         {
175           oss << "(";
176           for(int j=0;j<_dim;j++)
177             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
178           oss << ") ";
179         }
180     }
181   else
182     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
183   oss << "\n  - Gauss coords in reference element : ";
184   sz=_gs_coo.size();
185   if(sz%_dim==0)
186     {
187       int nbOfTuples=sz/_dim;
188       for(int i=0;i<nbOfTuples;i++)
189         {
190           oss << "(";
191           for(int j=0;j<_dim;j++)
192             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193           oss << ") ";
194         }
195     }
196   else
197     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
198   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
199   return oss.str();
200 }
201
202 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
203 {
204   _type=field->getTypeOfField();
205   _start=start;
206   switch(_type)
207     {
208     case ON_CELLS:
209       {
210         getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
211         _end=_start+nbOfCells;
212         _nval=nbOfCells;
213         break;
214       }
215     case ON_GAUSS_NE:
216       {
217         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
218         const int *arrPtr=arr->getConstPointer();
219         getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
220         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
221         _nval=nbOfCells;
222         break;
223       }
224     case ON_GAUSS_PT:
225       {
226         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
227         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
228         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
229         if(!disc2)
230           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
231         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
232         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
233         const int *dai2Ptr=dai2->getConstPointer();
234         int nbi=gsLoc.getWeights().size();
235         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
236         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
237         const int *da3Ptr=da3->getConstPointer();
238         if(da3->getNumberOfTuples()!=nbOfCells)
239           {//profile : for gauss even in NoProfile !!!
240             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
241             _profile=oss.str();
242             da3->setName(_profile.c_str());
243             glob.appendProfile(da3);
244           }
245         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
246         _nval=da3->getNbOfElems();
247         da4->alloc(_nval*nbi,1);
248         int *da4Ptr=da4->getPointer();
249         for(int i=0;i<_nval;i++)
250           {
251             int ref=dai2Ptr[offset+da3Ptr[i]];
252             for(int j=0;j<nbi;j++)
253               *da4Ptr++=ref+j;
254           }
255         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
256         _localization=oss2.str();
257         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
258         _end=_start+_nval*nbi;
259         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
260         break;
261       }
262     default:
263       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
264     }
265   start=_end;
266 }
267
268 /*!
269  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
270  * \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).
271  * \param [in] multiTypePfl is the end user profile specified in high level API
272  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
273  * \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.
274  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
275  * \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.
276  */
277 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(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) throw(INTERP_KERNEL::Exception)
278 {
279   _profile.clear();
280   _type=field->getTypeOfField();
281   std::string pflName(multiTypePfl->getName());
282   std::ostringstream oss; oss << pflName;
283   if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); } else { oss << "_NODE"; }
284   if(locIds)
285     {
286       if(pflName.empty())
287         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
288       if(_type!=ON_GAUSS_PT)
289         {
290           locIds->setName(oss.str().c_str());
291           glob.appendProfile(locIds);
292           _profile=oss.str();
293         }
294     }
295   _start=start;
296   switch(_type)
297     {
298     case ON_NODES:
299       {
300          _nval=idsInPfl->getNumberOfTuples();
301          getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
302          _end=_start+_nval;
303          break;
304       }
305     case ON_CELLS:
306       {
307         _nval=idsInPfl->getNumberOfTuples();
308         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
309         _end=_start+_nval;
310         break;
311       }
312     case ON_GAUSS_NE:
313       {
314         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
315         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
316         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
317         arr3->computeOffsets2();
318         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
319         int trueNval=tmp->getNumberOfTuples();
320         _nval=idsInPfl->getNumberOfTuples();
321         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
322         _end=_start+trueNval;
323         break;
324       }
325     case ON_GAUSS_PT:
326       {
327         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
328         if(!disc2)
329           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
330         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
331         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
332         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
333         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
334         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
335         //
336         MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
337         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
338         //
339         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
340         int trueNval=0;
341         for(const int *pt=da4->begin();pt!=da4->end();pt++)
342           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
343         tmp->alloc(trueNval,1);
344         int *tmpPtr=tmp->getPointer();
345         for(const int *pt=da4->begin();pt!=da4->end();pt++)
346           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
347             *tmpPtr++=j;
348         //
349         _nval=da4->getNumberOfTuples();
350         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
351         _end=_start+trueNval;
352         oss << "_loc_" << _loc_id;
353         if(locIds)
354           {
355             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
356             da5->setName(oss.str().c_str());
357             glob.appendProfile(da5);
358             _profile=oss.str();
359           }
360         else
361           {
362             if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
363               {
364                 da3->setName(oss.str().c_str());
365                 glob.appendProfile(da3);
366                 _profile=oss.str();
367               }
368           }
369         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
370         _localization=oss2.str();
371         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
372         break;
373       }
374     default:
375       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
376     }
377   start=_end;
378 }
379
380 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
381 {
382   _start=start;
383   _nval=arrr->getNumberOfTuples();
384   getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
385   _end=_start+_nval;
386   start=_end;
387 }
388
389 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
390 {
391   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
392 }
393
394 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
395 {
396   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
397 }
398
399 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
400 {
401   return new MEDFileFieldPerMeshPerTypePerDisc(other);
402 }
403
404 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
405 {
406   return _profile.capacity()+_localization.capacity()+5*sizeof(int);
407 }
408
409 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
410 {
411   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
412   ret->_father=father;
413   return ret.retn();
414 }
415
416 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
417 try:_type(atype),_father(fath)
418   {
419   }
420 catch(INTERP_KERNEL::Exception& e)
421 {
422   throw e;
423 }
424
425 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
426 {
427 }
428
429 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& 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),_tmp_work1(other._tmp_work1)
430 {
431 }
432
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
434                                                                        _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
435 {
436 }
437
438 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
439 {
440   return _father;
441 }
442
443 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
444 {
445   INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446   INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447   std::string fieldName=nasc.getName();
448   std::string meshName=getMeshName();
449   int iteration=getIteration();
450   int order=getOrder();
451   TypeOfField type=getType();
452   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
453   int profilesize,nbi;
454   med_geometry_type mgeoti;
455   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
456   _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
457                                   pflname,&profilesize,locname,&nbi);
458   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
459   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
460   _start=start;
461   _end=start+_nval*nbi;
462   start=_end;
463   if(type==ON_CELLS && !_localization.empty())
464     {
465       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
466         setType(ON_GAUSS_PT);
467       else
468         {
469           setType(ON_GAUSS_NE);
470           _localization.clear();
471         }
472     }
473 }
474
475 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
476 {
477   std::string fieldName=nasc.getName();
478   std::string meshName=getMeshName();
479   int iteration=getIteration();
480   int order=getOrder();
481   TypeOfField type=getType();
482   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
483   med_geometry_type mgeoti;
484   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
485   if(_start>_end)
486     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
487   if(_start==_end)
488     return ;
489   DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
490   if(_start<0 || _start>=arr->getNumberOfTuples())
491     {
492       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
493       throw INTERP_KERNEL::Exception(oss.str().c_str());
494     }
495   if(_end<0 || _end>arr->getNumberOfTuples())
496     {
497       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
498       throw INTERP_KERNEL::Exception(oss.str().c_str());
499     }
500   med_int tmp1,nbi;
501   INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
502   med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
503   int nbOfCompo=arr->getNumberOfComponents();
504   if(_end-_start!=nbValsInFile*nbi)
505     {
506       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi <<  " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
507       throw INTERP_KERNEL::Exception(oss.str().c_str());
508     }
509   DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
510   if(arrD)
511     {
512       double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
513       MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
514                                  _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
515       return ;
516     }
517   DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
518   if(arrI)
519     {
520       int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
521       MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
522                                  _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
523       return ;
524     }
525   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
526 }
527
528 /*!
529  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
530  */
531 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
532 {
533   int delta=_end-_start;
534   _start=newValueOfStart;
535   _end=_start+delta;
536 }
537
538 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
539 {
540   return _father->getIteration();
541 }
542
543 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
544 {
545   return _father->getOrder();
546 }
547
548 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
549 {
550   return _father->getTime();
551 }
552
553 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
554 {
555   return _father->getMeshName();
556 }
557
558 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
559 {
560   const char startLine[]="    ## ";
561   std::string startLine2(bkOffset,' ');
562   startLine2+=startLine;
563   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
564   oss << startLine2 << "Localization #" << id << "." << std::endl;
565   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
566   delete tmp;
567   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
568   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
569   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
570 }
571
572 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
573 {
574   return _type;
575 }
576
577 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
578 {
579   types.insert(_type);
580 }
581
582 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
583 {
584   _type=newType;
585 }
586
587 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
588 {
589   return _father->getGeoType();
590 }
591
592 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
593 {
594   return _father->getNumberOfComponents();
595 }
596
597 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
598 {
599   return _end-_start;
600 }
601
602 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
603 {
604   return _father->getOrCreateAndGetArray();
605 }
606
607 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
608 {
609   const MEDFileFieldPerMeshPerType *fath=_father;
610   return fath->getOrCreateAndGetArray();
611 }
612
613 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
614 {
615   return _father->getInfo();
616 }
617
618 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
619 {
620   return _profile;
621 }
622
623 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
624 {
625   _profile=newPflName;
626 }
627
628 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
629 {
630   return _localization;
631 }
632
633 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
634 {
635   _localization=newLocName;
636 }
637
638 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
639 {
640   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
641     {
642       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
643         {
644           _profile=(*it2).second;
645           return;
646         }
647     }
648 }
649
650 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
651 {
652   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
653     {
654       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
655         {
656           _localization=(*it2).second;
657           return;
658         }
659     }
660 }
661
662 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
663 {
664   if(type!=_type)
665     return ;
666   dads.push_back(std::pair<int,int>(_start,_end));
667   geoTypes.push_back(getGeoType());
668   if(_profile.empty())
669     pfls.push_back(0);
670   else
671     {
672       pfls.push_back(glob->getProfile(_profile.c_str()));
673     }
674   if(_localization.empty())
675     locs.push_back(-1);
676   else
677     {
678       locs.push_back(glob->getLocalizationId(_localization.c_str()));
679     }
680 }
681
682 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
683 {
684   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));
685   startEntryId++;
686 }
687
688 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
689 {
690   TypeOfField type=getType();
691   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
692   med_geometry_type mgeoti;
693   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
694   const DataArray *arr=getOrCreateAndGetArray();
695   if(!arr)
696     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
697   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
698   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
699   const unsigned char *locToWrite=0;
700   if(arrD)
701     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
702   else if(arrI)
703     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
704   else
705     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
706   MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
707                              MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
708                              locToWrite);
709 }
710
711 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
712 {
713   type=_type;
714   pfl=_profile;
715   loc=_localization;
716   dad.first=_start; dad.second=_end;
717 }
718
719 /*!
720  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
721  *             This code corresponds to the distribution of types in the corresponding mesh.
722  * \param [out] ptToFill memory zone where the output will be stored.
723  * \return the size of data pushed into output param \a ptToFill
724  */
725 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
726 {
727   _loc_id=offset;
728   std::ostringstream oss;
729   std::size_t nbOfType=codeOfMesh.size()/3;
730   int found=-1;
731   for(std::size_t i=0;i<nbOfType && found==-1;i++)
732     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
733       found=(int)i;
734   if(found==-1)
735     {
736       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
737       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
738       throw INTERP_KERNEL::Exception(oss.str().c_str());
739     }
740   int *work=ptToFill;
741   if(_profile.empty())
742     {
743       if(_nval!=codeOfMesh[3*found+1])
744         {
745           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
746           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
747           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
748           throw INTERP_KERNEL::Exception(oss.str().c_str());
749         }
750       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
751         *work++=ii;
752     }
753   else
754     {
755       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
756       if(pfl->getNumberOfTuples()!=_nval)
757         {
758           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
759           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
760           oss << _nval;
761           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
762           throw INTERP_KERNEL::Exception(oss.str().c_str());
763         }
764       int offset2=codeOfMesh[3*found+2];
765       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
766         {
767           if(*pflId<codeOfMesh[3*found+1])
768             *work++=offset2+*pflId;
769         }
770     }
771   return _nval;
772 }
773
774 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
775 {
776   for(int i=_start;i<_end;i++)
777     *ptToFill++=i;
778   return _end-_start;
779 }
780
781 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
782 {
783   switch(type)
784     {
785     case ON_CELLS:
786       return -2;
787     case ON_GAUSS_NE:
788       return -1;
789     case ON_GAUSS_PT:
790       return locId;
791     default:
792       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
793     }
794 }
795
796 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
797 {
798   int id=0;
799   std::map<std::pair<std::string,TypeOfField>,int> m;
800   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
801   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
802     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
803       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
804   ret.resize(id);
805   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
806     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
807   return ret;
808 }
809
810 /*!
811  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
812  * 
813  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
814  * \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.
815  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
816  * \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)
817  * \param [in,out] glob if necessary by the method, new profiles can be added to it
818  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
819  * \param [out] result All new entries will be appended on it.
820  * \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 !)
821  */
822 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
823                                                        const DataArrayInt *explicitIdsInMesh,
824                                                        const std::vector<int>& newCode,
825                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
826                                                        std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
827 {
828   if(entriesOnSameDisc.empty())
829     return false;
830   TypeOfField type=entriesOnSameDisc[0]->getType();
831   int szEntities=0,szTuples=0;
832   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
833     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
834   int nbi=szTuples/szEntities;
835   if(szTuples%szEntities!=0)
836     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
837   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
838   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
839   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
840   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
841   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
842   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
843   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
844   int id=0;
845   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
846     {
847       int startOfEltIdOfChunk=(*it)->_start;
848       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
849       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
850       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
851       //
852       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
853       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
854       //
855       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
856       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
857     }
858   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
859   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
860   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
861   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
862   //
863   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
864   //
865   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
866   arrPart->renumberInPlace(renumTupleIds->begin());
867   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
868   bool ret=false;
869   const int *idIt=diffVals->begin();
870   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
871   int offset2=0;
872   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
873     {
874       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
875       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
876       int nbEntityElts=subIds->getNumberOfTuples();
877       bool ret2;
878       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
879         NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
880                                     offset+offset2,
881                                     li,glob,ret2);
882       ret=ret || ret2;
883       result.push_back(eltToAdd);
884       offset2+=nbEntityElts*nbi;
885     }
886   ret=ret || li.empty();
887   return ret;
888 }
889
890 /*!
891  * \param [in] typeF type of field of new chunk
892  * \param [in] geoType the geometric type of the chunk
893  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
894  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
895  * \param [in] nbi number of integration points
896  * \param [in] offset The offset in the **global array of data**.
897  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
898  *                 to the new chunk to create.
899  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
900  * \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
901  *              and corresponding entry erased from \a entriesOnSameDisc.
902  * \return a newly allocated chunk
903  */
904 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
905                                                                                                   bool isPfl, int nbi, int offset,
906                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
907                                                                                                   MEDFileFieldGlobsReal& glob,
908                                                                                                   bool &notInExisting) throw(INTERP_KERNEL::Exception)
909 {
910   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
911   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
912   for(;it!=entriesOnSameDisc.end();it++)
913     {
914       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
915         {
916           if(!isPfl)
917             {
918               if((*it)->_profile.empty())
919                 break;
920               else
921                 if(!(*it)->_profile.empty())
922                   {
923                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
924                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
925                       break;
926                   }
927             }
928         }
929     }
930   if(it==entriesOnSameDisc.end())
931     {
932       notInExisting=true;
933       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
934       ret->_type=typeF;
935       ret->_loc_id=(int)geoType;
936       ret->_nval=nbMeshEntities;
937       ret->_start=offset;
938       ret->_end=ret->_start+ret->_nval*nbi;
939       if(isPfl)
940         {
941           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
942           glob.appendProfile(idsOfMeshElt);
943           ret->_profile=idsOfMeshElt->getName();
944         }
945       //tony treatment of localization
946       return ret;
947     }
948   else
949     {
950       notInExisting=false;
951       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
952       ret->_loc_id=(int)geoType;
953       ret->setNewStart(offset);
954       entriesOnSameDisc.erase(it);
955       return ret;
956     }
957   
958 }
959
960 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
961 {
962   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
963 }
964
965 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
966 {
967   return new MEDFileFieldPerMeshPerType(fath,geoType);
968 }
969
970 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
971 {
972   std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
973   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
974     ret+=(*it)->getHeapMemorySize();
975   return ret;
976 }
977
978 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
979 {
980   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
981   ret->_father=father;
982   std::size_t i=0;
983   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
984     {
985       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
986         ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
987     }
988   return ret.retn();
989 }
990
991 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
992 {
993   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
994   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
995     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
996 }
997
998 /*!
999  * This method is the most general one. No optimization is done here.
1000  * \param [in] multiTypePfl is the end user profile specified in high level API
1001  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1002  * \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.
1003  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1004  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1005  * \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.
1006  */
1007 void MEDFileFieldPerMeshPerType::assignFieldProfile(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) throw(INTERP_KERNEL::Exception)
1008 {
1009   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1010   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1011     _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1012 }
1013
1014 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1015 {
1016   _field_pm_pt_pd.resize(1);
1017   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1018   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1019 }
1020
1021 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1022 {
1023   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1024   //
1025   _field_pm_pt_pd.resize(1);
1026   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1027   _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1028 }
1029
1030 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1031 {
1032   TypeOfField type=field->getTypeOfField();
1033   if(type!=ON_GAUSS_PT)
1034     {
1035       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1036       int sz=_field_pm_pt_pd.size();
1037       bool found=false;
1038       for(int j=0;j<sz && !found;j++)
1039         {
1040           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1041             {
1042               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1043               found=true;
1044             }
1045         }
1046       if(!found)
1047         {
1048           _field_pm_pt_pd.resize(sz+1);
1049           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1050         }
1051       std::vector<int> ret(1,0);
1052       return ret;
1053     }
1054   else
1055     {
1056       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1057       int sz2=ret2.size();
1058       std::vector<int> ret3(sz2);
1059       int k=0;
1060       for(int i=0;i<sz2;i++)
1061         {
1062           int sz=_field_pm_pt_pd.size();
1063           int locIdToFind=ret2[i];
1064           bool found=false;
1065           for(int j=0;j<sz && !found;j++)
1066             {
1067               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1068                 {
1069                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1070                   ret3[k++]=j;
1071                   found=true;
1072                 }
1073             }
1074           if(!found)
1075             {
1076               _field_pm_pt_pd.resize(sz+1);
1077               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1078               ret3[k++]=sz;
1079             }
1080         }
1081       return ret3;
1082     }
1083 }
1084
1085 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1086 {
1087   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1088   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1089   if(!disc2)
1090     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1091   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1092   if(!da)
1093     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1094   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1095   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1096   if(retTmp->presenceOfValue(-1))
1097     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1098   std::vector<int> ret(retTmp->begin(),retTmp->end());
1099   return ret;
1100 }
1101
1102 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1103 {
1104   TypeOfField type=field->getTypeOfField();
1105   if(type!=ON_GAUSS_PT)
1106     {
1107       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1108       int sz=_field_pm_pt_pd.size();
1109       bool found=false;
1110       for(int j=0;j<sz && !found;j++)
1111         {
1112           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1113             {
1114               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1115               found=true;
1116             }
1117         }
1118       if(!found)
1119         {
1120           _field_pm_pt_pd.resize(sz+1);
1121           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1122         }
1123       std::vector<int> ret(1,0);
1124       return ret;
1125     }
1126   else
1127     {
1128       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1129       int sz2=ret2.size();
1130       std::vector<int> ret3(sz2);
1131       int k=0;
1132       for(int i=0;i<sz2;i++)
1133         {
1134           int sz=_field_pm_pt_pd.size();
1135           int locIdToFind=ret2[i];
1136           bool found=false;
1137           for(int j=0;j<sz && !found;j++)
1138             {
1139               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1140                 {
1141                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1142                   ret3[k++]=j;
1143                   found=true;
1144                 }
1145             }
1146           if(!found)
1147             {
1148               _field_pm_pt_pd.resize(sz+1);
1149               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1150               ret3[k++]=sz;
1151             }
1152         }
1153       return ret3;
1154     }
1155 }
1156
1157 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1158 {
1159   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1160   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1161   if(!disc2)
1162     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1163   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1164   if(!da)
1165     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1166   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1167   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1168   if(retTmp->presenceOfValue(-1))
1169     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1170   std::vector<int> ret(retTmp->begin(),retTmp->end());
1171   return ret;
1172 }
1173
1174 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1175 {
1176   return _father;
1177 }
1178
1179 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1180 {
1181   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1182   int curDim=(int)cm.getDimension();
1183   dim=std::max(dim,curDim);
1184 }
1185
1186 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1187 {
1188   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1189     {
1190       (*it)->fillTypesOfFieldAvailable(types);
1191     }
1192 }
1193
1194 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 throw(INTERP_KERNEL::Exception)
1195 {
1196   int sz=_field_pm_pt_pd.size();
1197   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1198   for(int i=0;i<sz;i++)
1199     {
1200       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1201     }
1202 }
1203
1204 int MEDFileFieldPerMeshPerType::getIteration() const
1205 {
1206   return _father->getIteration();
1207 }
1208
1209 int MEDFileFieldPerMeshPerType::getOrder() const
1210 {
1211   return _father->getOrder();
1212 }
1213
1214 double MEDFileFieldPerMeshPerType::getTime() const
1215 {
1216   return _father->getTime();
1217 }
1218
1219 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1220 {
1221   return _father->getMeshName();
1222 }
1223
1224 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1225 {
1226   const char startLine[]="  ## ";
1227   std::string startLine2(bkOffset,' ');
1228   std::string startLine3(startLine2);
1229   startLine3+=startLine;
1230   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1231     {
1232       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1233       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1234     }
1235   else
1236     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1237   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1238   int i=0;
1239   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1240     {
1241       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1242       if(cur)
1243         cur->simpleRepr(bkOffset,oss,i);
1244       else
1245         {
1246           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1247         }
1248     }
1249 }
1250
1251 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1252 {
1253   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1254     {
1255       globalSz+=(*it)->getNumberOfTuples();
1256     }
1257   nbOfEntries+=(int)_field_pm_pt_pd.size();
1258 }
1259
1260 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1261 {
1262   return _geo_type;
1263 }
1264
1265
1266 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1267 {
1268   return _father->getNumberOfComponents();
1269 }
1270
1271 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1272 {
1273   return _father->getOrCreateAndGetArray();
1274 }
1275
1276 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1277 {
1278   const MEDFileFieldPerMesh *fath=_father;
1279   return fath->getOrCreateAndGetArray();
1280 }
1281
1282 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1283 {
1284   return _father->getInfo();
1285 }
1286
1287 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1288 {
1289   std::vector<std::string> ret;
1290   std::set<std::string> ret2;
1291   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1292     {
1293       std::string tmp=(*it1)->getProfile();
1294       if(!tmp.empty())
1295         if(ret2.find(tmp)==ret2.end())
1296           {
1297             ret.push_back(tmp);
1298             ret2.insert(tmp);
1299           }
1300     }
1301   return ret;
1302 }
1303
1304 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1305 {
1306   std::vector<std::string> ret;
1307   std::set<std::string> ret2;
1308   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1309     {
1310       std::string tmp=(*it1)->getLocalization();
1311       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1312         if(ret2.find(tmp)==ret2.end())
1313           {
1314             ret.push_back(tmp);
1315             ret2.insert(tmp);
1316           }
1317     }
1318   return ret;
1319 }
1320
1321 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1322 {
1323   std::vector<std::string> ret;
1324   std::set<std::string> ret2;
1325   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1326     {
1327       std::string tmp=(*it1)->getProfile();
1328       if(!tmp.empty())
1329         ret.push_back(tmp);
1330     }
1331   return ret;
1332 }
1333
1334 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1335 {
1336   std::vector<std::string> ret;
1337   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1338     {
1339       std::string tmp=(*it1)->getLocalization();
1340       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1341         ret.push_back(tmp);
1342     }
1343   return ret;
1344 }
1345
1346 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1347 {
1348   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1349     (*it1)->changePflsRefsNamesGen(mapOfModif);
1350 }
1351
1352 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1353 {
1354   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1355     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1356 }
1357
1358 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1359 {
1360   if(_field_pm_pt_pd.empty())
1361     {
1362       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1363       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1364       throw INTERP_KERNEL::Exception(oss.str().c_str());
1365     }
1366   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1367     return _field_pm_pt_pd[locId];
1368   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1369   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1370   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1371   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1372   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1373 }
1374
1375 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1376 {
1377   if(_field_pm_pt_pd.empty())
1378     {
1379       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1380       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1381       throw INTERP_KERNEL::Exception(oss.str().c_str());
1382     }
1383   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1384     return _field_pm_pt_pd[locId];
1385   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1386   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1387   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1388   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1389   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1390 }
1391
1392 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
1393 {
1394   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1395     {
1396       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1397       if(meshDim!=(int)cm.getDimension())
1398         return ;
1399     }
1400   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1401     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1402 }
1403
1404 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1405 {
1406   int i=0;
1407   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1408     {
1409       (*it)->fillValues(i,startEntryId,entries);
1410     }
1411 }
1412
1413 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1414 {
1415   _field_pm_pt_pd=leaves;
1416   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1417     (*it)->setFather(this);
1418 }
1419
1420 /*!
1421  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1422  *  \param [out] its - list of pair (start,stop) kept
1423  *  \return bool - false if the type of field \a tof is not contained in \a this.
1424  */
1425 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1426 {
1427   bool ret=false;
1428   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1429   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1430     if((*it)->getType()==tof)
1431       {
1432         newPmPtPd.push_back(*it);
1433         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1434         (*it)->setNewStart(globalNum);
1435         globalNum=(*it)->getEnd();
1436         its.push_back(bgEnd);
1437         ret=true;
1438       }
1439   if(ret)
1440     _field_pm_pt_pd=newPmPtPd;
1441   return ret;
1442 }
1443
1444 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1445 {
1446 }
1447
1448 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1449 {
1450   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1451   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1452   med_geometry_type mgeoti;
1453   med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1454   int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1455   _field_pm_pt_pd.resize(nbProfiles);
1456   for(int i=0;i<nbProfiles;i++)
1457     {
1458       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1459     }
1460 }
1461
1462 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1463 {
1464   int pflId=0;
1465   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1466     {
1467       (*it)->loadOnlyStructureOfDataRecursively(fid,pflId+1,start,nasc);//tony
1468     }
1469 }
1470
1471 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1472 {
1473   int pflId=0;
1474   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1475     {
1476       (*it)->loadBigArray(fid,pflId+1,nasc);//tony
1477     }
1478 }
1479
1480 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1481 {
1482   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1483     {
1484       (*it)->copyOptionsFrom(*this);
1485       (*it)->writeLL(fid,nasc);
1486     }
1487 }
1488
1489 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1490 {
1491   switch(ikType)
1492     {
1493     case ON_CELLS:
1494       medfGeoType=typmai3[(int)ikGeoType];
1495       return MED_CELL;
1496     case ON_NODES:
1497       medfGeoType=MED_NONE;
1498       return MED_NODE;
1499     case ON_GAUSS_NE:
1500       medfGeoType=typmai3[(int)ikGeoType];
1501       return MED_NODE_ELEMENT;
1502     case ON_GAUSS_PT:
1503       medfGeoType=typmai3[(int)ikGeoType];
1504       return MED_CELL;
1505     default:
1506       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1507     }
1508   return MED_UNDEF_ENTITY_TYPE;
1509 }
1510
1511 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1512 {
1513   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1514 }
1515
1516 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1517 {
1518   return new MEDFileFieldPerMesh(fath,mesh);
1519 }
1520
1521 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1522 {
1523   std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1524   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1525     if((const MEDFileFieldPerMeshPerType *)*it)
1526       ret+=(*it)->getHeapMemorySize();
1527   return ret;
1528 }
1529
1530 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1531 {
1532   MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1533   ret->_father=father;
1534   std::size_t i=0;
1535   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1536     {
1537       if((const MEDFileFieldPerMeshPerType *)*it)
1538         ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1539     }
1540   return ret.retn();
1541 }
1542
1543 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1544 {
1545   std::string startLine(bkOffset,' ');
1546   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1547   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1548   int i=0;
1549   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1550     {
1551       const MEDFileFieldPerMeshPerType *cur=*it;
1552       if(cur)
1553         cur->simpleRepr(bkOffset,oss,i);
1554       else
1555         {
1556           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1557         }
1558     }
1559 }
1560
1561 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1562 {
1563   _mesh_name=mesh->getName();
1564   mesh->getTime(_mesh_iteration,_mesh_order);
1565 }
1566
1567 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1568 {
1569   int nbOfTypes=code.size()/3;
1570   int offset=0;
1571   for(int i=0;i<nbOfTypes;i++)
1572     {
1573       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1574       int nbOfCells=code[3*i+1];
1575       int pos=addNewEntryIfNecessary(type);
1576       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1577       offset+=nbOfCells;
1578     }
1579 }
1580
1581 /*!
1582  * This method is the most general one. No optimization is done here.
1583  * \param [in] multiTypePfl is the end user profile specified in high level API
1584  * \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].
1585  * \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.
1586  * \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.
1587  * \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.
1588  * \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.
1589  */
1590 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) throw(INTERP_KERNEL::Exception)
1591 {
1592   int nbOfTypes=code.size()/3;
1593   for(int i=0;i<nbOfTypes;i++)
1594     {
1595       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1596       int pos=addNewEntryIfNecessary(type);
1597       DataArrayInt *pfl=0;
1598       if(code[3*i+2]!=-1)
1599         pfl=idsPerType[code[3*i+2]];
1600       int nbOfTupes2=code2.size()/3;
1601       int found=0;
1602       for(;found<nbOfTupes2;found++)
1603         if(code[3*i]==code2[3*found])
1604           break;
1605       if(found==nbOfTupes2)
1606         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1607       _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1608     }
1609 }
1610
1611 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1612 {
1613   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1614   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1615 }
1616
1617 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1618 {
1619   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1620   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1621 }
1622
1623 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1624 {
1625   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1626     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1627 }
1628
1629 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1630 {
1631   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1632     (*it)->loadBigArraysRecursively(fid,nasc);
1633 }
1634
1635 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1636 {
1637   int nbOfTypes=_field_pm_pt.size();
1638   for(int i=0;i<nbOfTypes;i++)
1639     {
1640       _field_pm_pt[i]->copyOptionsFrom(*this);
1641       _field_pm_pt[i]->writeLL(fid,nasc);
1642     }
1643 }
1644
1645 void MEDFileFieldPerMesh::getDimension(int& dim) const
1646 {
1647   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1648     (*it)->getDimension(dim);
1649 }
1650
1651 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1652 {
1653   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1654     (*it)->fillTypesOfFieldAvailable(types);
1655 }
1656
1657 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 throw(INTERP_KERNEL::Exception)
1658 {
1659   int sz=_field_pm_pt.size();
1660   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1661   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1662   for(int i=0;i<sz;i++)
1663     {
1664       types[i]=_field_pm_pt[i]->getGeoType();
1665       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1666     }
1667   return ret;
1668 }
1669
1670 double MEDFileFieldPerMesh::getTime() const
1671 {
1672   int tmp1,tmp2;
1673   return _father->getTime(tmp1,tmp2);
1674 }
1675
1676 int MEDFileFieldPerMesh::getIteration() const
1677 {
1678   return _father->getIteration();
1679 }
1680
1681 int MEDFileFieldPerMesh::getOrder() const
1682 {
1683   return _father->getOrder();
1684 }
1685
1686 int MEDFileFieldPerMesh::getNumberOfComponents() const
1687 {
1688   return _father->getNumberOfComponents();
1689 }
1690
1691 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1692 {
1693   if(!_father)
1694     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1695   return _father->getOrCreateAndGetArray();
1696 }
1697
1698 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1699 {
1700   if(!_father)
1701     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1702   return _father->getOrCreateAndGetArray();
1703 }
1704
1705 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1706 {
1707   return _father->getInfo();
1708 }
1709
1710 /*!
1711  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1712  * 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.
1713  * It returns 2 output vectors :
1714  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1715  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1716  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1717  */
1718 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)
1719 {
1720   int notNullPflsSz=0;
1721   int nbOfArrs=geoTypes.size();
1722   for(int i=0;i<nbOfArrs;i++)
1723     if(pfls[i])
1724       notNullPflsSz++;
1725   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1726   int nbOfDiffGeoTypes=geoTypes3.size();
1727   code.resize(3*nbOfDiffGeoTypes);
1728   notNullPfls.resize(notNullPflsSz);
1729   notNullPflsSz=0;
1730   int j=0;
1731   for(int i=0;i<nbOfDiffGeoTypes;i++)
1732     {
1733       int startZone=j;
1734       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1735       std::vector<const DataArrayInt *> notNullTmp;
1736       if(pfls[j])
1737         notNullTmp.push_back(pfls[j]);
1738       j++;
1739       for(;j<nbOfArrs;j++)
1740         if(geoTypes[j]==refType)
1741           {
1742             if(pfls[j])
1743               notNullTmp.push_back(pfls[j]);
1744           }
1745         else
1746           break;
1747       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1748       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1749       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1750       code[3*i]=(int)refType;
1751       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1752       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1753       if(notNullTmp.empty())
1754         code[3*i+2]=-1;
1755       else
1756         {
1757           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1758           code[3*i+2]=notNullPflsSz++;
1759         }
1760     }
1761 }
1762
1763 /*!
1764  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1765  */
1766 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) throw(INTERP_KERNEL::Exception)
1767 {
1768   int sz=dads.size();
1769   int ret=0;
1770   for(int i=0;i<sz;i++)
1771     {
1772       if(locs[i]==-1)
1773         {
1774           if(type!=ON_GAUSS_NE)
1775             ret+=dads[i].second-dads[i].first;
1776           else
1777             {
1778               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1779               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1780             }
1781         }
1782       else
1783         {
1784           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1785           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1786         }
1787     }
1788   return ret;
1789 }
1790
1791 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1792 {
1793   std::vector<std::string> ret;
1794   std::set<std::string> ret2;
1795   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1796     {
1797       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1798       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1799         if(ret2.find(*it2)==ret2.end())
1800           {
1801             ret.push_back(*it2);
1802             ret2.insert(*it2);
1803           }
1804     }
1805   return ret;
1806 }
1807
1808 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1809 {
1810   std::vector<std::string> ret;
1811   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1812     {
1813       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1814       ret.insert(ret.end(),tmp.begin(),tmp.end());
1815     }
1816   return ret;
1817 }
1818
1819 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1820 {
1821   std::vector<std::string> ret;
1822   std::set<std::string> ret2;
1823   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1824     {
1825       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1826       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1827         if(ret2.find(*it2)==ret2.end())
1828           {
1829             ret.push_back(*it2);
1830             ret2.insert(*it2);
1831           }
1832     }
1833   return ret;
1834 }
1835
1836 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1837 {
1838   std::vector<std::string> ret;
1839   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1840     {
1841       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1842       ret.insert(ret.end(),tmp.begin(),tmp.end());
1843     }
1844   return ret;
1845 }
1846
1847 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1848 {
1849   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1850     {
1851       if((*it).first==_mesh_name)
1852         {
1853           _mesh_name=(*it).second;
1854           return true;
1855         }
1856     }
1857   return false;
1858 }
1859
1860 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1861                                                       MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1862 {
1863   if(_mesh_name!=meshName)
1864     return false;
1865   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1866   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1867   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1868   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1869   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1870   getUndergroundDataArrayExt(entries);
1871   DataArray *arr0=getOrCreateAndGetArray();//tony
1872   if(!arr0)
1873     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1874   DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1875   if(!arr0)
1876     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1877   int sz=0;
1878   if(!arr)
1879     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1880   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1881     {
1882       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1883         {
1884           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1885           sz+=(*it).second.second-(*it).second.first;
1886         }
1887       else
1888         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1889     }
1890   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1891   ////////////////////
1892   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1893   int *workI2=explicitIdsOldInMesh->getPointer();
1894   int sz1=0,sz2=0,sid=1;
1895   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1896   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1897   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1898     {
1899       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1900       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1901       int *workI=explicitIdsOldInArr->getPointer();
1902       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1903         {
1904           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1905           (*itL2)->setLocId(sz2);
1906           (*itL2)->_tmp_work1=(*itL2)->getStart();
1907           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1908         }
1909       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1910     }
1911   explicitIdsOldInMesh->reAlloc(sz2);
1912   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1913   ////////////////////
1914   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1915   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1916   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1917   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1918     {
1919       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1920       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1921       otherEntriesNew.back()->setLocId((*it)->getGeoType());
1922     }
1923   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1924   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1925   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1926     {
1927       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1928       int newStart=elt->getLocId();
1929       elt->setLocId((*it)->getGeoType());
1930       elt->setNewStart(newStart);
1931       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1932       entriesKeptNew.push_back(elt);
1933       entriesKeptNew2.push_back(elt);
1934     }
1935   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1936   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1937   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1938   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1939   bool ret=false;
1940   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1941     {
1942       sid=0;
1943       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1944         {
1945           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1946           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1947           }*/
1948       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1949                                                             glob,arr2,otherEntriesNew) || ret;
1950     }
1951   if(!ret)
1952     return false;
1953   // Assign new dispatching
1954   assignNewLeaves(otherEntriesNew);
1955   arr->cpyFrom(*arr2);
1956   return true;
1957 }
1958
1959 /*!
1960  * \param [in,out] globalNum a global numbering counter for the renumbering.
1961  * \param [out] its - list of pair (start,stop) kept
1962  */
1963 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1964 {
1965   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1966   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1967     {
1968       std::vector< std::pair<int,int> > its2;
1969       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
1970         {
1971           ret.push_back(*it);
1972           its.insert(its.end(),its2.begin(),its2.end());
1973         }
1974     }
1975   _field_pm_pt=ret;
1976 }
1977
1978 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1979 {
1980   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1981   for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1982     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1983   //
1984   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1985   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1986   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1987   for(;it1!=types.end();it1++,it2++)
1988     {
1989       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1990       elt->setLeaves((*it1).second);
1991       *it2=elt;
1992     }
1993   _field_pm_pt=fieldPmPt;
1994 }
1995
1996 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1997 {
1998   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1999     (*it)->changePflsRefsNamesGen(mapOfModif);
2000 }
2001
2002 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2003 {
2004   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2005     (*it)->changeLocsRefsNamesGen(mapOfModif);
2006 }
2007
2008 /*!
2009  * \param [in] mesh is the whole mesh
2010  */
2011 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2012 {
2013   if(_field_pm_pt.empty())
2014     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2015   //
2016   std::vector< std::pair<int,int> > dads;
2017   std::vector<const DataArrayInt *> pfls;
2018   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2019   std::vector<int> locs,code;
2020   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2021   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2022     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2023   // Sort by types
2024   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2025   if(code.empty())
2026     {
2027       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2028       throw INTERP_KERNEL::Exception(oss.str().c_str());
2029     }
2030   //
2031   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2032   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2033   if(type!=ON_NODES)
2034     {
2035       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2036       if(!arr)
2037         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2038       else
2039         {
2040           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2041           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2042         }
2043     }
2044   else
2045     {
2046       if(code.size()!=3)
2047         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2048       int nb=code[1];
2049       if(code[2]==-1)
2050         {
2051           if(nb!=mesh->getNumberOfNodes())
2052             {
2053               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2054               oss << " nodes in mesh !";
2055               throw INTERP_KERNEL::Exception(oss.str().c_str());
2056             }
2057           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2058         }
2059       else
2060         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2061     }
2062 }
2063
2064 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2065 {
2066   if(_field_pm_pt.empty())
2067     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2068   //
2069   std::vector<std::pair<int,int> > dads;
2070   std::vector<const DataArrayInt *> pfls;
2071   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2072   std::vector<int> locs,code;
2073   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2074   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2075     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2076   // Sort by types
2077   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2078   if(code.empty())
2079     {
2080       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2081       throw INTERP_KERNEL::Exception(oss.str().c_str());
2082     }
2083   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2084   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2085   if(type!=ON_NODES)
2086     {
2087       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2088       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2089     }
2090   else
2091     {
2092       if(code.size()!=3)
2093         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2094       int nb=code[1];
2095       if(code[2]==-1)
2096         {
2097           if(nb!=mesh->getNumberOfNodes())
2098             {
2099               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2100               oss << " nodes in mesh !";
2101               throw INTERP_KERNEL::Exception(oss.str().c_str());
2102             }
2103         }
2104       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2105     }
2106   //
2107   return 0;
2108 }
2109
2110 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2111 {
2112   int globalSz=0;
2113   int nbOfEntries=0;
2114   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2115     {
2116       (*it)->getSizes(globalSz,nbOfEntries);
2117     }
2118   entries.resize(nbOfEntries);
2119   nbOfEntries=0;
2120   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2121     {
2122       (*it)->fillValues(nbOfEntries,entries);
2123     }
2124 }
2125
2126 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2127 {
2128   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2129     {
2130       if((*it)->getGeoType()==typ)
2131         return (*it)->getLeafGivenLocId(locId);
2132     }
2133   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2134   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2135   oss << "Possiblities are : ";
2136   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2137     {
2138       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2139       oss << "\"" << cm2.getRepr() << "\", ";
2140     }
2141   throw INTERP_KERNEL::Exception(oss.str().c_str());
2142 }
2143
2144 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2145 {
2146   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2147     {
2148       if((*it)->getGeoType()==typ)
2149         return (*it)->getLeafGivenLocId(locId);
2150     }
2151   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2152   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2153   oss << "Possiblities are : ";
2154   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2155     {
2156       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2157       oss << "\"" << cm2.getRepr() << "\", ";
2158     }
2159   throw INTERP_KERNEL::Exception(oss.str().c_str());
2160 }
2161
2162 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2163 {
2164   int i=0;
2165   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2166   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2167   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2168     {
2169       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2170       if(type==curType)
2171         return i;
2172       else
2173         {
2174           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2175           if(pos>pos2)
2176             it2=it+1;
2177         }
2178     }
2179   int ret=std::distance(_field_pm_pt.begin(),it2);
2180   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2181   return ret;
2182 }
2183
2184 /*!
2185  * 'dads' and 'locs' input parameters have the same number of elements
2186  * \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
2187  */
2188 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2189                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2190                                                          const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2191 {
2192   isPfl=false;
2193   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2194   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2195   MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2196   const std::vector<std::string>& infos=getInfo();
2197   da->setInfoOnComponents(infos);
2198   da->setName("");
2199   if(type==ON_GAUSS_PT)
2200     {
2201       int offset=0;
2202       int nbOfArrs=dads.size();
2203       for(int i=0;i<nbOfArrs;i++)
2204         {
2205           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2206           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2207           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2208           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2209           di->alloc(nbOfElems,1);
2210           di->iota(offset);
2211           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2212           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2213           offset+=nbOfElems;
2214         }
2215     }
2216   arrOut=da;
2217   return ret.retn();
2218 }
2219
2220 /*!
2221  * 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.
2222  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2223  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2224  * The order of cells in the returned field is those imposed by the profile.
2225  * \param [in] mesh is the global mesh.
2226  */
2227 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2228                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2229                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2230                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2231 {
2232   if(da->isIdentity())
2233     {
2234       int nbOfTuples=da->getNumberOfTuples();
2235       if(nbOfTuples==mesh->getNumberOfCells())
2236         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2237     }
2238   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2239   m2->setName(mesh->getName());
2240   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2241   isPfl=true;
2242   return ret.retn();
2243 }
2244
2245 /*!
2246  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2247  */
2248 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2249                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2250                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2251 {
2252   if(da->isIdentity())
2253     {
2254       int nbOfTuples=da->getNumberOfTuples();
2255       if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2256         return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2257     }
2258   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2259   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2260   if(meshu)
2261     {
2262       if(meshu->getNodalConnectivity()==0)
2263         {
2264           MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2265           int nb=da->getNbOfElems();
2266           const int *ptr=da->getConstPointer();
2267           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2268           meshuc->allocateCells(nb);
2269           for(int i=0;i<nb;i++)
2270             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2271           meshuc->finishInsertingCells();
2272           ret->setMesh(meshuc);
2273           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2274           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2275           disc->checkCoherencyBetween(meshuc,arrOut);
2276           return ret.retn();
2277         }
2278     }
2279   //
2280   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2281   isPfl=true;
2282   DataArrayInt *arr2=0;
2283   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2284   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2285   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2286   int nnodes=mesh2->getNumberOfNodes();
2287   if(nnodes==(int)da->getNbOfElems())
2288     {
2289       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2290       arrOut->renumberInPlace(da3->getConstPointer());
2291       mesh2->setName(mesh->getName());
2292       ret->setMesh(mesh2);
2293       return ret.retn();
2294     }
2295   else
2296     {
2297       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 !!!";
2298       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2299       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2300       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2301       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2302       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2303       throw INTERP_KERNEL::Exception(oss.str().c_str());
2304     }
2305   return 0;
2306 }
2307
2308 /*!
2309  * This method is the most light method of field retrieving.
2310  */
2311 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2312 {
2313   if(!pflIn)
2314     {
2315       pflOut=DataArrayInt::New();
2316       pflOut->alloc(nbOfElems,1);
2317       pflOut->iota(0);
2318     }
2319   else
2320     {
2321       pflOut=const_cast<DataArrayInt*>(pflIn);
2322       pflOut->incrRef();
2323     }
2324   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2325   MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2326   const std::vector<std::string>& infos=getInfo();
2327   int nbOfComp=infos.size();
2328   for(int i=0;i<nbOfComp;i++)
2329     da->setInfoOnComponent(i,infos[i].c_str());
2330   safePfl->incrRef();
2331   return da.retn();
2332 }
2333
2334 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2335                                                                                                                                                                                                                  _mesh_csit(meshCsit),_father(fath)
2336 {
2337   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2338   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2339   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2340   for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2341     {
2342       int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2343       if(nbProfile>0)
2344         {
2345           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2346           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2347         }
2348       nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2349       if(nbProfile>0)
2350         {
2351           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2352           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2353         }
2354     }
2355   int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2356   if(nbProfile>0)
2357     {
2358       _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2359       _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2360     }
2361 }
2362
2363 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2364 {
2365   copyTinyInfoFrom(mesh);
2366 }
2367
2368 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2369 {
2370   if(id>=(int)_pfls.size())
2371     _pfls.resize(id+1);
2372   _pfls[id]=DataArrayInt::New();
2373   int lgth=MEDprofileSizeByName(fid,pflName);
2374   _pfls[id]->setName(pflName);
2375   _pfls[id]->alloc(lgth,1);
2376   MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2377   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2378 }
2379
2380 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2381 {
2382   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2383   int sz;
2384   MEDprofileInfo(fid,i+1,pflName,&sz);
2385   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2386   if(i>=(int)_pfls.size())
2387     _pfls.resize(i+1);
2388   _pfls[i]=DataArrayInt::New();
2389   _pfls[i]->alloc(sz,1);
2390   _pfls[i]->setName(pflCpp.c_str());
2391   MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2392   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2393 }
2394
2395 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2396 {
2397   int nbOfPfls=_pfls.size();
2398   for(int i=0;i<nbOfPfls;i++)
2399     {
2400       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2401       cpy->applyLin(1,1,0);
2402       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2403       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2404       MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2405     }
2406   //
2407   int nbOfLocs=_locs.size();
2408   for(int i=0;i<nbOfLocs;i++)
2409     _locs[i]->writeLL(fid);
2410 }
2411
2412 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2413 {
2414   std::vector<std::string> pfls=getPfls();
2415   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2416     {
2417       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2418       if(it2==pfls.end())
2419         {
2420           _pfls.push_back(*it);
2421         }
2422       else
2423         {
2424           int id=std::distance(pfls.begin(),it2);
2425           if(!(*it)->isEqual(*_pfls[id]))
2426             {
2427               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2428               throw INTERP_KERNEL::Exception(oss.str().c_str());
2429             }
2430         }
2431     }
2432   std::vector<std::string> locs=getLocs();
2433   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2434     {
2435       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2436       if(it2==locs.end())
2437         {
2438           _locs.push_back(*it);
2439         }
2440       else
2441         {
2442           int id=std::distance(locs.begin(),it2);
2443           if(!(*it)->isEqual(*_locs[id],eps))
2444             {
2445               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2446               throw INTERP_KERNEL::Exception(oss.str().c_str());
2447             }
2448         }
2449     }
2450 }
2451
2452 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2453 {
2454   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2455     getProfile((*it).c_str());
2456 }
2457
2458 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2459 {
2460   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2461     getLocalization((*it).c_str());
2462 }
2463
2464 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2465 {
2466   std::vector<std::string> profiles=real.getPflsReallyUsed();
2467   int sz=profiles.size();
2468   _pfls.resize(sz);
2469   for(int i=0;i<sz;i++)
2470     loadProfileInFile(fid,i,profiles[i].c_str());
2471   //
2472   std::vector<std::string> locs=real.getLocsReallyUsed();
2473   sz=locs.size();
2474   _locs.resize(sz);
2475   for(int i=0;i<sz;i++)
2476     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2477 }
2478
2479 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2480 {
2481   int nProfil=MEDnProfile(fid);
2482   for(int i=0;i<nProfil;i++)
2483     loadProfileInFile(fid,i);
2484   int sz=MEDnLocalization(fid);
2485   _locs.resize(sz);
2486   for(int i=0;i<sz;i++)
2487     {
2488       _locs[i]=MEDFileFieldLoc::New(fid,i);
2489     }
2490 }
2491
2492 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2493 {
2494   return new MEDFileFieldGlobs(fname);
2495 }
2496
2497 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2498 {
2499   return new MEDFileFieldGlobs;
2500 }
2501
2502 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2503 {
2504   std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2505   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2506     ret+=(*it)->getHeapMemorySize();
2507   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2508     ret+=(*it)->getHeapMemorySize();
2509   return ret;
2510 }
2511
2512 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2513 {
2514   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2515   std::size_t i=0;
2516   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2517     {
2518       if((const DataArrayInt *)*it)
2519         ret->_pfls[i]=(*it)->deepCpy();
2520     }
2521   i=0;
2522   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2523     {
2524       if((const MEDFileFieldLoc*)*it)
2525         ret->_locs[i]=(*it)->deepCpy();
2526     }
2527   return ret.retn();
2528 }
2529
2530 /*!
2531  * \throw if a profile in \a pfls in not in \a this.
2532  * \throw if a localization in \a locs in not in \a this.
2533  * \sa MEDFileFieldGlobs::deepCpyPart
2534  */
2535 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2536 {
2537   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2538   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2539     {
2540       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2541       if(!pfl)
2542         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2543       pfl->incrRef();
2544       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2545       ret->_pfls.push_back(pfl2);
2546     }
2547   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2548     {
2549       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2550       if(!loc)
2551         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2552       loc->incrRef();
2553       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2554       ret->_locs.push_back(loc2);
2555     }
2556   ret->setFileName(getFileName());
2557   return ret.retn();
2558 }
2559
2560 /*!
2561  * \throw if a profile in \a pfls in not in \a this.
2562  * \throw if a localization in \a locs in not in \a this.
2563  * \sa MEDFileFieldGlobs::shallowCpyPart
2564  */
2565 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2566 {
2567   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2568   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2569     {
2570       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2571       if(!pfl)
2572         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2573       ret->_pfls.push_back(pfl->deepCpy());
2574     }
2575   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2576     {
2577       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2578       if(!loc)
2579         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2580       ret->_locs.push_back(loc->deepCpy());
2581     }
2582   ret->setFileName(getFileName());
2583   return ret.retn();
2584 }
2585
2586 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2587 {
2588 }
2589
2590 MEDFileFieldGlobs::MEDFileFieldGlobs()
2591 {
2592 }
2593
2594 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2595 {
2596 }
2597
2598 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2599 {
2600   oss << "Profiles :\n";
2601   std::size_t n=_pfls.size();
2602   for(std::size_t i=0;i<n;i++)
2603     {
2604       oss << "  - #" << i << " ";
2605       const DataArrayInt *pfl=_pfls[i];
2606       if(pfl)
2607         oss << "\"" << pfl->getName() << "\"\n";
2608       else
2609         oss << "EMPTY !\n";
2610     }
2611   n=_locs.size();
2612   oss << "Localizations :\n";
2613   for(std::size_t i=0;i<n;i++)
2614     {
2615       oss << "  - #" << i << " ";
2616       const MEDFileFieldLoc *loc=_locs[i];
2617       if(loc)
2618         loc->simpleRepr(oss);
2619       else
2620         oss<< "EMPTY !\n";
2621     }
2622 }
2623
2624 void MEDFileFieldGlobs::setFileName(const char *fileName)
2625 {
2626   _file_name=fileName;
2627 }
2628
2629 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2630 {
2631   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2632     {
2633       DataArrayInt *elt(*it);
2634       if(elt)
2635         {
2636           std::string name(elt->getName());
2637           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2638             {
2639               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2640                 {
2641                   elt->setName((*it2).second.c_str());
2642                   return;
2643                 }
2644             }
2645         }
2646     }
2647 }
2648
2649 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2650 {
2651   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2652     {
2653       MEDFileFieldLoc *elt(*it);
2654       if(elt)
2655         {
2656           std::string name(elt->getName());
2657           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2658             {
2659               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2660                 {
2661                   elt->setName((*it2).second.c_str());
2662                   return;
2663                 }
2664             }
2665         }
2666     }
2667 }
2668
2669 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2670 {
2671   if(locId<0 || locId>=(int)_locs.size())
2672     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2673   return _locs[locId]->getNbOfGaussPtPerCell();
2674 }
2675
2676 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2677 {
2678   return getLocalizationFromId(getLocalizationId(locName));
2679 }
2680
2681 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2682 {
2683   if(locId<0 || locId>=(int)_locs.size())
2684     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2685   return *_locs[locId];
2686 }
2687
2688 namespace ParaMEDMEMImpl
2689 {
2690   class LocFinder
2691   {
2692   public:
2693     LocFinder(const char *loc):_loc(loc) { }
2694     bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2695   private:
2696     const char *_loc;
2697   };
2698
2699   class PflFinder
2700   {
2701   public:
2702     PflFinder(const std::string& pfl):_pfl(pfl) { }
2703     bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2704   private:
2705     const std::string& _pfl;
2706   };
2707 }
2708
2709 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2710 {
2711   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2712   if(it==_locs.end())
2713     {
2714       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2715       for(it=_locs.begin();it!=_locs.end();it++)
2716         oss << "\"" << (*it)->getName() << "\", ";
2717       throw INTERP_KERNEL::Exception(oss.str().c_str());
2718     }
2719   return std::distance(_locs.begin(),it);
2720 }
2721
2722 /*!
2723  * The returned value is never null.
2724  */
2725 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2726 {
2727   std::string pflNameCpp(pflName);
2728   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2729   if(it==_pfls.end())
2730     {
2731       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2732       for(it=_pfls.begin();it!=_pfls.end();it++)
2733         oss << "\"" << (*it)->getName() << "\", ";
2734       throw INTERP_KERNEL::Exception(oss.str().c_str());
2735     }
2736   return *it;
2737 }
2738
2739 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2740 {
2741   if(pflId<0 || pflId>=(int)_pfls.size())
2742     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2743   return _pfls[pflId];
2744 }
2745
2746 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2747 {
2748   if(locId<0 || locId>=(int)_locs.size())
2749     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2750   return *_locs[locId];
2751 }
2752
2753 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2754 {
2755   return getLocalizationFromId(getLocalizationId(locName));
2756 }
2757
2758 /*!
2759  * The returned value is never null.
2760  */
2761 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2762 {
2763   std::string pflNameCpp(pflName);
2764   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2765   if(it==_pfls.end())
2766     {
2767       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2768       for(it=_pfls.begin();it!=_pfls.end();it++)
2769         oss << "\"" << (*it)->getName() << "\", ";
2770       throw INTERP_KERNEL::Exception(oss.str().c_str());
2771     }
2772   return *it;
2773 }
2774
2775 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2776 {
2777   if(pflId<0 || pflId>=(int)_pfls.size())
2778     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2779   return _pfls[pflId];
2780 }
2781
2782 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2783 {
2784   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2785   int i=0;
2786   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2787     {
2788       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2789         newPfls.push_back(*it);
2790     }
2791   _pfls=newPfls;
2792 }
2793
2794 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2795 {
2796   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2797   int i=0;
2798   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2799     {
2800       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2801         newLocs.push_back(*it);
2802     }
2803   _locs=newLocs;
2804 }
2805
2806 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2807 {
2808   int sz=_pfls.size();
2809   std::vector<std::string> ret(sz);
2810   for(int i=0;i<sz;i++)
2811     ret[i]=_pfls[i]->getName();
2812   return ret;
2813 }
2814
2815 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2816 {
2817   int sz=_locs.size();
2818   std::vector<std::string> ret(sz);
2819   for(int i=0;i<sz;i++)
2820     ret[i]=_locs[i]->getName();
2821   return ret;
2822 }
2823
2824 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2825 {
2826   std::vector<std::string> v=getPfls();
2827   std::string s(pflName);
2828   return std::find(v.begin(),v.end(),s)!=v.end();
2829 }
2830
2831 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2832 {
2833   std::vector<std::string> v=getLocs();
2834   std::string s(locName);
2835   return std::find(v.begin(),v.end(),s)!=v.end();
2836 }
2837
2838 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2839 {
2840   std::map<int,std::vector<int> > m;
2841   int i=0;
2842   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2843     {
2844       const DataArrayInt *tmp=(*it);
2845       if(tmp)
2846         {
2847           m[tmp->getHashCode()].push_back(i);
2848         }
2849     }
2850   std::vector< std::vector<int> > ret;
2851   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2852     {
2853       if((*it2).second.size()>1)
2854         {
2855           std::vector<int> ret0;
2856           bool equalityOrNot=false;
2857           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2858             {
2859               std::vector<int>::const_iterator it4=it3; it4++;
2860               for(;it4!=(*it2).second.end();it4++)
2861                 {
2862                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2863                     {
2864                       if(!equalityOrNot)
2865                         ret0.push_back(*it3);
2866                       ret0.push_back(*it4);
2867                       equalityOrNot=true;
2868                     }
2869                 }
2870             }
2871           if(!ret0.empty())
2872             ret.push_back(ret0);
2873         }
2874     }
2875   return ret;
2876 }
2877
2878 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2879 {
2880   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2881 }
2882
2883 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2884 {
2885   std::string name(pfl->getName());
2886   if(name.empty())
2887     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2888   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2889     if(name==(*it)->getName())
2890       {
2891         if(!pfl->isEqual(*(*it)))
2892           {
2893             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2894             throw INTERP_KERNEL::Exception(oss.str().c_str());
2895           }
2896       }
2897   pfl->incrRef();
2898   _pfls.push_back(pfl);
2899 }
2900
2901 void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
2902 {
2903   std::string name(locName);
2904   if(name.empty())
2905     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2906   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2907   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2908     if((*it)->isName(locName))
2909       {
2910         if(!(*it)->isEqual(*obj,1e-12))
2911           {
2912             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2913             throw INTERP_KERNEL::Exception(oss.str().c_str());
2914           }
2915       }
2916   _locs.push_back(obj);
2917 }
2918
2919 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2920 {
2921   std::vector<std::string> names=getPfls();
2922   return CreateNewNameNotIn("NewPfl_",names);
2923 }
2924
2925 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2926 {
2927   std::vector<std::string> names=getLocs();
2928   return CreateNewNameNotIn("NewLoc_",names);
2929 }
2930
2931 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2932 {
2933   for(std::size_t sz=0;sz<100000;sz++)
2934     {
2935       std::ostringstream tryName;
2936       tryName << prefix << sz;
2937       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2938         return tryName.str();
2939     }
2940   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2941 }
2942
2943 /*!
2944  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2945  *  \param [in] fname - the file name.
2946  */
2947 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2948 {
2949 }
2950
2951 /*!
2952  * Creates an empty MEDFileFieldGlobsReal.
2953  */
2954 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2955 {
2956 }
2957
2958 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2959 {
2960   std::size_t ret=0;
2961   if((const MEDFileFieldGlobs *)_globals)
2962     ret+=_globals->getHeapMemorySize();
2963   return ret;
2964 }
2965
2966 /*!
2967  * Returns a string describing profiles and Gauss points held in \a this.
2968  *  \return std::string - the description string.
2969  */
2970 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2971 {
2972   const MEDFileFieldGlobs *glob=_globals;
2973   std::ostringstream oss2; oss2 << glob;
2974   std::string stars(oss2.str().length(),'*');
2975   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
2976   if(glob)
2977     glob->simpleRepr(oss);
2978   else
2979     oss << "NO GLOBAL INFORMATION !\n";
2980 }
2981
2982 void MEDFileFieldGlobsReal::resetContent()
2983 {
2984   _globals=MEDFileFieldGlobs::New();
2985 }
2986
2987 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2988 {
2989 }
2990
2991 /*!
2992  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2993  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2994  */
2995 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2996 {
2997   _globals=other._globals;
2998 }
2999
3000 /*!
3001  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3002  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3003  */
3004 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3005 {
3006   const MEDFileFieldGlobs *otherg(other._globals);
3007   if(!otherg)
3008     return ;
3009   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3010 }
3011
3012 /*!
3013  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3014  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3015  */
3016 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3017 {
3018   const MEDFileFieldGlobs *otherg(other._globals);
3019   if(!otherg)
3020     return ;
3021   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3022 }
3023
3024 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3025 {
3026   _globals=other._globals;
3027   if((const MEDFileFieldGlobs *)_globals)
3028     _globals=other._globals->deepCpy();
3029 }
3030
3031 /*!
3032  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3033  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3034  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3035  *         \a this and \a other MEDFileFieldGlobsReal.
3036  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3037  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3038  */
3039 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3040 {
3041   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3042   if(thisGlobals==otherGlobals)
3043     return ;
3044   if(!thisGlobals)
3045     {
3046       _globals=other._globals;
3047       return ;
3048     }
3049   _globals->appendGlobs(*other._globals,eps);
3050 }
3051
3052 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3053 {
3054   checkGlobsPflsPartCoherency();
3055   checkGlobsLocsPartCoherency();
3056 }
3057
3058 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3059 {
3060   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3061 }
3062
3063 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3064 {
3065   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3066 }
3067
3068 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3069 {
3070   contentNotNull()->loadProfileInFile(fid,id,pflName);
3071 }
3072
3073 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3074 {
3075   contentNotNull()->loadProfileInFile(fid,id);
3076 }
3077
3078 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3079 {
3080   contentNotNull()->loadGlobals(fid,*this);
3081 }
3082
3083 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3084 {
3085   contentNotNull()->loadAllGlobals(fid);
3086 }
3087
3088 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3089 {
3090   contentNotNull()->writeGlobals(fid,opt);
3091 }
3092
3093 /*!
3094  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3095  * or getPflsReallyUsedMulti().
3096  *  \return std::vector<std::string> - a sequence of names of all profiles.
3097  */
3098 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3099 {
3100   return contentNotNull()->getPfls();
3101 }
3102
3103 /*!
3104  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3105  * or getLocsReallyUsedMulti().
3106  *  \return std::vector<std::string> - a sequence of names of all localizations.
3107  */
3108 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3109 {
3110   return contentNotNull()->getLocs();
3111 }
3112
3113 /*!
3114  * Checks if the profile with a given name exists.
3115  *  \param [in] pflName - the profile name of interest.
3116  *  \return bool - \c true if the profile named \a pflName exists.
3117  */
3118 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3119 {
3120   return contentNotNull()->existsPfl(pflName);
3121 }
3122
3123 /*!
3124  * Checks if the localization with a given name exists.
3125  *  \param [in] locName - the localization name of interest.
3126  *  \return bool - \c true if the localization named \a locName exists.
3127  */
3128 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3129 {
3130   return contentNotNull()->existsLoc(locName);
3131 }
3132
3133 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3134 {
3135   return contentNotNull()->createNewNameOfPfl();
3136 }
3137
3138 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3139 {
3140   return contentNotNull()->createNewNameOfLoc();
3141 }
3142
3143 /*!
3144  * Sets the name of a MED file.
3145  *  \param [inout] fileName - the file name.
3146  */
3147 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3148 {
3149   contentNotNull()->setFileName(fileName);
3150 }
3151
3152 /*!
3153  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3154  * in the same order.
3155  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3156  *          Each item of this sequence is a vector containing ids of equal profiles.
3157  */
3158 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3159 {
3160   return contentNotNull()->whichAreEqualProfiles();
3161 }
3162
3163 /*!
3164  * Finds equal localizations.
3165  *  \param [in] eps - a precision used to compare real values of the localizations.
3166  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3167  *          Each item of this sequence is a vector containing ids of equal localizations.
3168  */
3169 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3170 {
3171   return contentNotNull()->whichAreEqualLocs(eps);
3172 }
3173
3174 /*!
3175  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3176  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3177  *        this sequence is a pair whose 
3178  *        - the first item is a vector of profile names to replace by the second item,
3179  *        - the second item is a profile name to replace every profile name of the first item.
3180  */
3181 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3182 {
3183   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3184 }
3185
3186 /*!
3187  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3188  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3189  *        this sequence is a pair whose 
3190  *        - the first item is a vector of localization names to replace by the second item,
3191  *        - the second item is a localization name to replace every localization name of the first item.
3192  */
3193 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3194 {
3195   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3196 }
3197
3198 /*!
3199  * Replaces references to some profiles (a reference is a profile name) by references
3200  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3201  * them-selves accordingly. <br>
3202  * This method is a generalization of changePflName().
3203  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3204  *        this sequence is a pair whose 
3205  *        - the first item is a vector of profile names to replace by the second item,
3206  *        - the second item is a profile name to replace every profile of the first item.
3207  * \sa changePflsRefsNamesGen()
3208  * \sa changePflName()
3209  */
3210 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3211 {
3212   changePflsRefsNamesGen(mapOfModif);
3213   changePflsNamesInStruct(mapOfModif);
3214 }
3215
3216 /*!
3217  * Replaces references to some localizations (a reference is a localization name) by references
3218  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3219  * them-selves accordingly. <br>
3220  * This method is a generalization of changeLocName().
3221  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3222  *        this sequence is a pair whose 
3223  *        - the first item is a vector of localization names to replace by the second item,
3224  *        - the second item is a localization name to replace every localization of the first item.
3225  * \sa changeLocsRefsNamesGen()
3226  * \sa changeLocName()
3227  */
3228 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3229 {
3230   changeLocsRefsNamesGen(mapOfModif);
3231   changeLocsNamesInStruct(mapOfModif);
3232 }
3233
3234 /*!
3235  * Renames the profile having a given name and updates references to this profile.
3236  *  \param [in] oldName - the name of the profile to rename.
3237  *  \param [in] newName - a new name of the profile.
3238  * \sa changePflsNames().
3239  */
3240 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3241 {
3242   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3243   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3244   mapOfModif[0]=p;
3245   changePflsNames(mapOfModif);
3246 }
3247
3248 /*!
3249  * Renames the localization having a given name and updates references to this localization.
3250  *  \param [in] oldName - the name of the localization to rename.
3251  *  \param [in] newName - a new name of the localization.
3252  * \sa changeLocsNames().
3253  */
3254 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3255 {
3256   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3257   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3258   mapOfModif[0]=p;
3259   changeLocsNames(mapOfModif);
3260 }
3261
3262 /*!
3263  * Removes duplicated profiles. Returns a map used to update references to removed 
3264  * profiles via changePflsRefsNamesGen().
3265  * Equal profiles are found using whichAreEqualProfiles().
3266  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3267  *          a sequence describing the performed replacements of profiles. Each element of
3268  *          this sequence is a pair whose
3269  *          - the first item is a vector of profile names replaced by the second item,
3270  *          - the second item is a profile name replacing every profile of the first item.
3271  */
3272 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3273 {
3274   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3275   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3276   int i=0;
3277   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3278     {
3279       std::vector< std::string > tmp((*it).size());
3280       int j=0;
3281       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3282         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3283       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3284       ret[i]=p;
3285       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3286       killProfileIds(tmp2);
3287     }
3288   changePflsRefsNamesGen(ret);
3289   return ret;
3290 }
3291
3292 /*!
3293  * Removes duplicated localizations. Returns a map used to update references to removed 
3294  * localizations via changeLocsRefsNamesGen().
3295  * Equal localizations are found using whichAreEqualLocs().
3296  *  \param [in] eps - a precision used to compare real values of the localizations.
3297  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3298  *          a sequence describing the performed replacements of localizations. Each element of
3299  *          this sequence is a pair whose
3300  *          - the first item is a vector of localization names replaced by the second item,
3301  *          - the second item is a localization name replacing every localization of the first item.
3302  */
3303 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3304 {
3305   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3306   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3307   int i=0;
3308   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3309     {
3310       std::vector< std::string > tmp((*it).size());
3311       int j=0;
3312       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3313         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3314       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3315       ret[i]=p;
3316       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3317       killLocalizationIds(tmp2);
3318     }
3319   changeLocsRefsNamesGen(ret);
3320   return ret;
3321 }
3322
3323 /*!
3324  * Returns number of Gauss points per cell in a given localization.
3325  *  \param [in] locId - an id of the localization of interest.
3326  *  \return int - the number of the Gauss points per cell.
3327  */
3328 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3329 {
3330   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3331 }
3332
3333 /*!
3334  * Returns an id of a localization by its name.
3335  *  \param [in] loc - the localization name of interest.
3336  *  \return int - the id of the localization.
3337  *  \throw If there is no a localization named \a loc.
3338  */
3339 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3340 {
3341   return contentNotNull()->getLocalizationId(loc);
3342 }
3343
3344 /*!
3345  * Returns the name of the MED file.
3346  *  \return const char * - the MED file name.
3347  */
3348 const char *MEDFileFieldGlobsReal::getFileName() const
3349 {
3350   return contentNotNull()->getFileName();
3351 }
3352
3353 std::string MEDFileFieldGlobsReal::getFileName2() const
3354 {
3355   return contentNotNull()->getFileName2();
3356 }
3357
3358 /*!
3359  * Returns a localization object by its name.
3360  *  \param [in] locName - the name of the localization of interest.
3361  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3362  *  \throw If there is no a localization named \a locName.
3363  */
3364 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3365 {
3366   return contentNotNull()->getLocalization(locName);
3367 }
3368
3369 /*!
3370  * Returns a localization object by its id.
3371  *  \param [in] locId - the id of the localization of interest.
3372  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3373  *  \throw If there is no a localization with id \a locId.
3374  */
3375 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3376 {
3377   return contentNotNull()->getLocalizationFromId(locId);
3378 }
3379
3380 /*!
3381  * Returns a profile array by its name.
3382  *  \param [in] pflName - the name of the profile of interest.
3383  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3384  *  \throw If there is no a profile named \a pflName.
3385  */
3386 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3387 {
3388   return contentNotNull()->getProfile(pflName);
3389 }
3390
3391 /*!
3392  * Returns a profile array by its id.
3393  *  \param [in] pflId - the id of the profile of interest.
3394  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3395  *  \throw If there is no a profile with id \a pflId.
3396  */
3397 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3398 {
3399   return contentNotNull()->getProfileFromId(pflId);
3400 }
3401
3402 /*!
3403  * Returns a localization object, apt for modification, by its id.
3404  *  \param [in] locId - the id of the localization of interest.
3405  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3406  *          having the id \a locId.
3407  *  \throw If there is no a localization with id \a locId.
3408  */
3409 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3410 {
3411   return contentNotNull()->getLocalizationFromId(locId);
3412 }
3413
3414 /*!
3415  * Returns a localization object, apt for modification, by its name.
3416  *  \param [in] locName - the name of the localization of interest.
3417  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3418  *          having the name \a locName.
3419  *  \throw If there is no a localization named \a locName.
3420  */
3421 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3422 {
3423   return contentNotNull()->getLocalization(locName);
3424 }
3425
3426 /*!
3427  * Returns a profile array, apt for modification, by its name.
3428  *  \param [in] pflName - the name of the profile of interest.
3429  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3430  *  \throw If there is no a profile named \a pflName.
3431  */
3432 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3433 {
3434   return contentNotNull()->getProfile(pflName);
3435 }
3436
3437 /*!
3438  * Returns a profile array, apt for modification, by its id.
3439  *  \param [in] pflId - the id of the profile of interest.
3440  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3441  *  \throw If there is no a profile with id \a pflId.
3442  */
3443 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3444 {
3445   return contentNotNull()->getProfileFromId(pflId);
3446 }
3447
3448 /*!
3449  * Removes profiles given by their ids. No data is updated to track this removal.
3450  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3451  */
3452 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3453 {
3454   contentNotNull()->killProfileIds(pflIds);
3455 }
3456
3457 /*!
3458  * Removes localizations given by their ids. No data is updated to track this removal.
3459  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3460  */
3461 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3462 {
3463   contentNotNull()->killLocalizationIds(locIds);
3464 }
3465
3466 /*!
3467  * Stores a profile array.
3468  *  \param [in] pfl - the profile array to store.
3469  *  \throw If the name of \a pfl is empty.
3470  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3471  *         different ids.
3472  */
3473 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3474 {
3475   contentNotNull()->appendProfile(pfl);
3476 }
3477
3478 /*!
3479  * Adds a new localization of Gauss points.
3480  *  \param [in] locName - the name of the new localization.
3481  *  \param [in] geoType - a geometrical type of the reference cell.
3482  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3483  *         must be \c nbOfNodesPerCell * \c dimOfType.
3484  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3485  *         must be  _wg_.size() * \c dimOfType.
3486  *  \param [in] w - the weights of Gauss points.
3487  *  \throw If \a locName is empty.
3488  *  \throw If a localization with the name \a locName already exists but is
3489  *         different form the new one.
3490  */
3491 void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
3492 {
3493   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3494 }
3495
3496 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3497 {
3498   MEDFileFieldGlobs *g(_globals);
3499   if(!g)
3500     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3501   return g;
3502 }
3503
3504 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3505 {
3506   const MEDFileFieldGlobs *g(_globals);
3507   if(!g)
3508     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3509   return g;
3510 }
3511
3512 //= MEDFileFieldNameScope
3513
3514 MEDFileFieldNameScope::MEDFileFieldNameScope()
3515 {
3516 }
3517
3518 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3519 {
3520 }
3521
3522 /*!
3523  * Returns the name of \a this field.
3524  *  \return std::string - a string containing the field name.
3525  */
3526 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3527 {
3528   return _name;
3529 }
3530
3531 /*!
3532  * Sets name of \a this field
3533  *  \param [in] name - the new field name.
3534  */
3535 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3536 {
3537   _name=fieldName;
3538 }
3539
3540 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3541 {
3542   return _dt_unit;
3543 }
3544
3545 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3546 {
3547   _dt_unit=dtUnit;
3548 }
3549
3550 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3551 {
3552   _name=other._name;
3553   _dt_unit=other._dt_unit;
3554 }
3555
3556 //= MEDFileAnyTypeField1TSWithoutSDA
3557
3558 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3559 {
3560   _field_per_mesh.resize(other._field_per_mesh.size());
3561   std::size_t i=0;
3562   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3563     {
3564       if((const MEDFileFieldPerMesh *)*it)
3565         _field_per_mesh[i]=(*it)->deepCpy(this);
3566     }
3567 }
3568
3569 /*!
3570  * Prints a string describing \a this field into a stream. This string is outputted 
3571  * by \c print Python command.
3572  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3573  *  \param [in,out] oss - the out stream.
3574  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3575  *          info id printed, else, not.
3576  */
3577 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3578 {
3579   std::string startOfLine(bkOffset,' ');
3580   oss << startOfLine << "Field ";
3581   if(bkOffset==0)
3582     oss << "[Type=" << getTypeStr() << "] ";
3583   oss << "on One time Step ";
3584   if(f1tsId>=0)
3585     oss << "(" << f1tsId << ") ";
3586   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3587   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3588   const DataArray *arr=getUndergroundDataArray();
3589   if(arr)
3590     {
3591       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3592       if(f1tsId<0)
3593         {
3594           oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3595           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3596           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3597             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3598         }
3599       if(arr->isAllocated())
3600         {
3601           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3602         }
3603       else
3604         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3605     }
3606   else
3607     {
3608       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3609     }
3610   oss << startOfLine << "----------------------" << std::endl;
3611   if(!_field_per_mesh.empty())
3612     {
3613       int i=0;
3614       for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3615         {
3616           const MEDFileFieldPerMesh *cur=(*it2);
3617           if(cur)
3618             cur->simpleRepr(bkOffset,oss,i);
3619           else
3620             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3621         }
3622     }
3623   else
3624     {
3625       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3626     }
3627   oss << startOfLine << "----------------------" << std::endl;
3628 }
3629
3630 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3631 {
3632   const DataArray *arr(getUndergroundDataArray());
3633   if(!arr)
3634     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3635   int nbOfCompo=arr->getNumberOfComponents();
3636   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3637   for(int i=0;i<nbOfCompo;i++)
3638     {
3639       ret[i]=deepCpy();
3640       std::vector<int> v(1,i);
3641       MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3642       ret[i]->setArray(arr2);
3643     }
3644   return ret;
3645 }
3646
3647 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3648 {
3649 }
3650
3651 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3652 {
3653 }
3654
3655 /*!
3656  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3657  * empty. Returns -1 if this in on nodes.
3658  *  \return int - the dimension of \a this.
3659  */
3660 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3661 {
3662   int ret=-2;
3663   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3664     (*it)->getDimension(ret);
3665   return ret;
3666 }
3667
3668 /*!
3669  * Returns the mesh name.
3670  *  \return std::string - a string holding the mesh name.
3671  *  \throw If \c _field_per_mesh.empty()
3672  */
3673 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3674 {
3675   if(_field_per_mesh.empty())
3676     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3677   return _field_per_mesh[0]->getMeshName();
3678 }
3679
3680 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3681 {
3682   std::string oldName(getMeshName());
3683   std::vector< std::pair<std::string,std::string> > v(1);
3684   v[0].first=oldName; v[0].second=newMeshName;
3685   changeMeshNames(v);
3686 }
3687
3688 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3689 {
3690   bool ret=false;
3691   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3692     {
3693       MEDFileFieldPerMesh *cur(*it);
3694       if(cur)
3695         ret=cur->changeMeshNames(modifTab) || ret;
3696     }
3697   return ret;
3698 }
3699
3700 /*!
3701  * Returns the number of iteration of the state of underlying mesh.
3702  *  \return int - the iteration number.
3703  *  \throw If \c _field_per_mesh.empty()
3704  */
3705 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3706 {
3707   if(_field_per_mesh.empty())
3708     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3709   return _field_per_mesh[0]->getMeshIteration();
3710 }
3711
3712 /*!
3713  * Returns the order number of iteration of the state of underlying mesh.
3714  *  \return int - the order number.
3715  *  \throw If \c _field_per_mesh.empty()
3716  */
3717 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3718 {
3719   if(_field_per_mesh.empty())
3720     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3721   return _field_per_mesh[0]->getMeshOrder();
3722 }
3723
3724 /*!
3725  * Checks if \a this field is tagged by a given iteration number and a given
3726  * iteration order number.
3727  *  \param [in] iteration - the iteration number of interest.
3728  *  \param [in] order - the iteration order number of interest.
3729  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
3730  *          \a this->getOrder() == \a order.
3731  */
3732 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3733 {
3734   return iteration==_iteration && order==_order;
3735 }
3736
3737 /*!
3738  * Returns number of iteration and order number of iteration when
3739  * \a this field has been calculated.
3740  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
3741  *          order number.
3742  */
3743 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3744 {
3745   std::pair<int,int> p;
3746   fillIteration(p);
3747   return p;
3748 }
3749
3750 /*!
3751  * Returns number of iteration and order number of iteration when
3752  * \a this field has been calculated.
3753  *  \param [in,out] p - a pair returning the iteration number and the iteration
3754  *          order number.
3755  */
3756 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3757 {
3758   p.first=_iteration;
3759   p.second=_order;
3760 }
3761
3762 /*!
3763  * Returns all types of spatial discretization of \a this field.
3764  *  \param [in,out] types - a sequence of types of \a this field.
3765  */
3766 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3767 {
3768   std::set<TypeOfField> types2;
3769   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3770     {
3771       (*it)->fillTypesOfFieldAvailable(types2);
3772     }
3773   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3774   std::copy(types2.begin(),types2.end(),bi);
3775 }
3776
3777 /*!
3778  * Returns all types of spatial discretization of \a this field.
3779  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3780  *          of \a this field.
3781  */
3782 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3783 {
3784   std::vector<TypeOfField> ret;
3785   fillTypesOfFieldAvailable(ret);
3786   return ret;
3787 }
3788
3789 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3790 {
3791   std::vector<std::string> ret;
3792   std::set<std::string> ret2;
3793   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3794     {
3795       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3796       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3797         if(ret2.find(*it2)==ret2.end())
3798           {
3799             ret.push_back(*it2);
3800             ret2.insert(*it2);
3801           }
3802     }
3803   return ret;
3804 }
3805
3806 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3807 {
3808   std::vector<std::string> ret;
3809   std::set<std::string> ret2;
3810   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3811     {
3812       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3813       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3814         if(ret2.find(*it2)==ret2.end())
3815           {
3816             ret.push_back(*it2);
3817             ret2.insert(*it2);
3818           }
3819     }
3820   return ret;
3821 }
3822
3823 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3824 {
3825   std::vector<std::string> ret;
3826   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3827     {
3828       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3829       ret.insert(ret.end(),tmp.begin(),tmp.end());
3830     }
3831   return ret;
3832 }
3833
3834 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3835 {
3836   std::vector<std::string> ret;
3837   std::set<std::string> ret2;
3838   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3839     {
3840       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3841       ret.insert(ret.end(),tmp.begin(),tmp.end());
3842     }
3843   return ret;
3844 }
3845
3846 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3847 {
3848   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3849     (*it)->changePflsRefsNamesGen(mapOfModif);
3850 }
3851
3852 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3853 {
3854   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3855     (*it)->changeLocsRefsNamesGen(mapOfModif);
3856 }
3857
3858 /*!
3859  * Returns all attributes of parts of \a this field lying on a given mesh.
3860  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3861  * item of every of returned sequences refers to the _i_-th part of \a this field.
3862  * Thus all sequences returned by this method are of the same length equal to number
3863  * of different types of supporting entities.<br>
3864  * A field part can include sub-parts with several different spatial discretizations,
3865  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3866  * for example. Hence, some of the returned sequences contains nested sequences, and an item
3867  * of a nested sequence corresponds to a type of spatial discretization.<br>
3868  * This method allows for iteration over MEDFile DataStructure without any overhead.
3869  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3870  *          for the case with only one underlying mesh. (Actually, the number of meshes is
3871  *          not checked if \a mname == \c NULL).
3872  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3873  *          a field part is returned. 
3874  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3875  *          This sequence is of the same length as \a types. 
3876  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3877  *          discretization. A profile name can be empty.
3878  *          Length of this and of nested sequences is the same as that of \a typesF.
3879  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
3880  *          discretization. A localization name can be empty.
3881  *          Length of this and of nested sequences is the same as that of \a typesF.
3882  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3883  *          of ids of tuples within the data array, per each type of spatial
3884  *          discretization within one mesh entity type. 
3885  *          Length of this and of nested sequences is the same as that of \a typesF.
3886  *  \throw If no field is lying on \a mname.
3887  */
3888 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception)
3889 {
3890   int meshId=0;
3891   if(mname)
3892     meshId=getMeshIdFromMeshName(mname);
3893   else
3894     if(_field_per_mesh.empty())
3895       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3896   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3897 }
3898
3899 /*!
3900  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3901  * maximal absolute dimension and values returned via the out parameter \a levs are 
3902  * dimensions relative to the maximal absolute dimension. <br>
3903  * This method is designed for MEDFileField1TS instances that have a discretization
3904  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS", 
3905  * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT", 
3906  * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3907  * Only these 3 discretizations will be taken into account here. If \a this is
3908  * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3909  * This method is useful to make the link between the dimension of the underlying mesh
3910  * and the levels of \a this, because it is possible that the highest dimension of \a this
3911  * field is not equal to the dimension of the underlying mesh.
3912  * 
3913  * Let's consider the following case:
3914  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3915  * TETRA4, HEXA8, TRI3 and SEG2.
3916  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3917  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3918  *
3919  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3920  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3921  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3922  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3923  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3924  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3925  * For example<br>
3926  * to retrieve the highest level of
3927  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
3928  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3929  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3930  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3931  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3932  *          for the case with only one underlying mesh. (Actually, the number of meshes is
3933  *          not checked if \a mname == \c NULL).
3934  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3935  *          absolute one. They are in decreasing order. This sequence is cleared before
3936  *          filling it in.
3937  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
3938  *  \throw If no field is lying on \a mname.
3939  */
3940 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3941 {
3942   levs.clear();
3943   int meshId=getMeshIdFromMeshName(mname);
3944   std::vector<INTERP_KERNEL::NormalizedCellType> types;
3945   std::vector< std::vector<TypeOfField> > typesF;
3946   std::vector< std::vector<std::string> > pfls, locs;
3947   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3948   if(types.empty())
3949     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3950   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3951   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3952     return -1;
3953   st.erase(INTERP_KERNEL::NORM_ERROR);
3954   std::set<int> ret1;
3955   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3956     {
3957       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3958       ret1.insert((int)cm.getDimension());
3959     }
3960   int ret=*std::max_element(ret1.begin(),ret1.end());
3961   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3962   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3963   return ret;
3964 }
3965
3966 /*!
3967  * \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.
3968  * \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.
3969  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
3970  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3971  */
3972 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3973 {
3974   int mid=getMeshIdFromMeshName(mName);
3975   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3976 }
3977
3978 /*!
3979  * \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.
3980  * \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.
3981  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
3982  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3983  */
3984 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3985 {
3986   int mid=getMeshIdFromMeshName(mName);
3987   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3988 }
3989
3990 /*!
3991  * \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.
3992  */
3993 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3994 {
3995   if(_field_per_mesh.empty())
3996     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3997   if(mName==0)
3998     return 0;
3999   std::string mName2(mName);
4000   int ret=0;
4001   std::vector<std::string> msg;
4002   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4003     if(mName2==(*it)->getMeshName())
4004       return ret;
4005     else
4006       msg.push_back((*it)->getMeshName());
4007   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4008   oss << "Possible meshes are : ";
4009   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4010     oss << "\"" << (*it2) << "\" ";
4011   throw INTERP_KERNEL::Exception(oss.str().c_str());
4012 }
4013
4014 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4015 {
4016   if(!mesh)
4017     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4018   std::string tmp(mesh->getName());
4019   if(tmp.empty())
4020     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4021   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4022   int i=0;
4023   for(;it!=_field_per_mesh.end();it++,i++)
4024     {
4025       if((*it)->getMeshName()==tmp)
4026         return i;
4027     }
4028   int sz=_field_per_mesh.size();
4029   _field_per_mesh.resize(sz+1);
4030   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4031   return sz;
4032 }
4033
4034 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4035                                                             MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4036 {
4037   bool ret=false;
4038   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4039     {
4040       MEDFileFieldPerMesh *fpm(*it);
4041       if(fpm)
4042         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4043     }
4044   return ret;
4045 }
4046
4047 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4048 {
4049   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4050   std::vector< std::vector<TypeOfField> > typesF;
4051   std::vector< std::vector<std::string> > pfls,locs;
4052   std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4053   std::set<TypeOfField> allEnt;
4054   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4055     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4056       allEnt.insert(*it2);
4057   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4058   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4059   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4060     {
4061       std::vector< std::pair<int,int> > its;
4062       ret[i]=shallowCpy();
4063       int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4064       ret[i]->updateData(newLgth,its);
4065     }
4066   return ret;
4067 }
4068
4069 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4070 {
4071   int globalCounter=0;
4072   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4073     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4074   return globalCounter;
4075 }
4076
4077 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4078 {
4079   if(_nb_of_tuples_to_be_allocated>=0)
4080     {
4081       _nb_of_tuples_to_be_allocated=newLgth;
4082       return ;
4083     }
4084   if(_nb_of_tuples_to_be_allocated==-1)
4085     return ;
4086   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4087     {
4088       const DataArray *oldArr=getUndergroundDataArray();
4089       if(!oldArr || !oldArr->isAllocated())
4090         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4091       MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4092       newArr->alloc(newLgth,getNumberOfComponents());
4093       int pos=0;
4094       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4095         {
4096           if((*it).second<(*it).first)
4097             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4098           newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4099           pos+=(*it).second-(*it).first;
4100         }
4101       setArray(newArr);
4102       return ;
4103     }
4104   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4105 }
4106
4107 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4108 {
4109   if(_field_per_mesh.empty())
4110     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4111   if(_field_per_mesh.size()>1)
4112     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4113   _field_per_mesh[0]->copyOptionsFrom(opts);
4114   _field_per_mesh[0]->writeLL(fid,nasc);
4115 }
4116
4117 /*!
4118  * 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.
4119  * If false is returned the memory allocation is not required.
4120  */
4121 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4122 {
4123   if(_nb_of_tuples_to_be_allocated>=0)
4124     {
4125       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4126       _nb_of_tuples_to_be_allocated=-2;
4127       return true;
4128     }
4129   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4130     return false;
4131   if(_nb_of_tuples_to_be_allocated==-1)
4132     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4133   if(_nb_of_tuples_to_be_allocated<-3)
4134     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4135   
4136 }
4137
4138 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4139 {
4140   med_int numdt,numit;
4141   med_float dt;
4142   med_int nmesh;
4143   med_bool localMesh;
4144   med_int meshnumdt,meshnumit;
4145   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4146   MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4147   MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4148   if(_iteration!=numdt || _order!=numit)
4149     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4150   _field_per_mesh.resize(nmesh);
4151   for(int i=0;i<nmesh;i++)
4152     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4153   _nb_of_tuples_to_be_allocated=0;
4154   for(int i=0;i<nmesh;i++)
4155     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4156 }
4157
4158 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4159 {
4160   allocIfNecessaryTheArrayToReceiveDataFromFile();
4161   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4162     (*it)->loadBigArraysRecursively(fid,nasc);
4163 }
4164
4165 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4166 {
4167   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4168     for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4169       (*it)->loadBigArraysRecursively(fid,nasc);
4170 }
4171
4172 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4173 {
4174   loadOnlyStructureOfDataRecursively(fid,nasc);
4175   loadBigArraysRecursively(fid,nasc);
4176 }
4177
4178 void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
4179 {
4180   DataArray *thisArr(getUndergroundDataArray());
4181   if(thisArr && thisArr->isAllocated())
4182     {
4183       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4184       thisArr->desallocate();
4185     }
4186 }
4187
4188 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4189 {
4190   std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4191   if(getUndergroundDataArray())
4192     ret+=getUndergroundDataArray()->getHeapMemorySize();
4193   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4194     ret+=(*it)->getHeapMemorySize();
4195   return ret;
4196 }
4197
4198 /*!
4199  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4200  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4201  * "Sort By Type"), if not, an exception is thrown. 
4202  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4203  *  \param [in] arr - the array of values.
4204  *  \param [in,out] glob - the global data where profiles and localization present in
4205  *          \a field, if any, are added.
4206  *  \throw If the name of \a field is empty.
4207  *  \throw If the data array of \a field is not set.
4208  *  \throw If \a this->_arr is already allocated but has different number of components
4209  *         than \a field.
4210  *  \throw If the underlying mesh of \a field has no name.
4211  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4212  */
4213 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4214 {
4215   const MEDCouplingMesh *mesh=field->getMesh();
4216   //
4217   TypeOfField type=field->getTypeOfField();
4218   std::vector<DataArrayInt *> dummy;
4219   int start=copyTinyInfoFrom(field,arr);
4220   int pos=addNewEntryIfNecessary(mesh);
4221   if(type!=ON_NODES)
4222     {
4223       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4224       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4225     }
4226   else
4227     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4228 }
4229
4230 /*!
4231  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4232  * of a given mesh are used as the support of the given field (a real support is not used). 
4233  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4234  * Order of underlying mesh entities of the given field specified by \a profile parameter
4235  * is not prescribed; this method permutes field values to have them sorted by element
4236  * type as required for writing to MED file. A new profile is added only if no equal
4237  * profile is missing. 
4238  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4239  *  \param [in] arrOfVals - the values of the field \a field used.
4240  *  \param [in] mesh - the supporting mesh of \a field.
4241  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4242  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4243  *  \param [in,out] glob - the global data where profiles and localization present in
4244  *          \a field, if any, are added.
4245  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4246  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4247  *  \throw If the data array of \a field is not set.
4248  *  \throw If \a this->_arr is already allocated but has different number of components
4249  *         than \a field.
4250  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4251  *  \sa setFieldNoProfileSBT()
4252  */
4253 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4254 {
4255   TypeOfField type=field->getTypeOfField();
4256   int start=copyTinyInfoFrom(field,arrOfVals);
4257   std::vector<DataArrayInt *> idsInPflPerType;
4258   std::vector<DataArrayInt *> idsPerType;
4259   std::vector<int> code,code2;
4260   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4261   if(type!=ON_NODES)
4262     {
4263       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4264       code2=m->getDistributionOfTypes();
4265       //
4266       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4267       for(std::size_t i=0;i<idsInPflPerType.size();i++)
4268         idsInPflPerType2[i]=idsInPflPerType[i];
4269       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4270       for(std::size_t i=0;i<idsPerType.size();i++)
4271         idsPerType2[i]=idsPerType[i];
4272       //
4273       int pos=addNewEntryIfNecessary(m);
4274       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4275     }
4276   else
4277     {
4278       int pos=addNewEntryIfNecessary(m);
4279       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4280     }
4281 }
4282
4283 /*!
4284  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4285  */
4286 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4287 {
4288   if(_nb_of_tuples_to_be_allocated>=0)
4289     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 !");
4290   DataArray *arr(getOrCreateAndGetArray());
4291   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4292   _nb_of_tuples_to_be_allocated=-3;
4293 }
4294
4295 /*!
4296  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4297  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4298  * larger by the size of \a field. Returns an id of the first not filled
4299  * tuple of \a this->_arr.
4300  *  \param [in] field - the field to copy the info on components and the name from.
4301  *  \return int - the id of first not initialized tuple of \a this->_arr.
4302  *  \throw If the name of \a field is empty.
4303  *  \throw If the data array of \a field is not set.
4304  *  \throw If \a this->_arr is already allocated but has different number of components
4305  *         than \a field.
4306  */
4307 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4308 {
4309   if(!field)
4310     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4311   std::string name(field->getName());
4312   setName(name.c_str());
4313   setDtUnit(field->getTimeUnit());
4314   if(name.empty())
4315     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4316   if(!arr)
4317     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4318   if(!arr->isAllocated())
4319     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4320   _dt=field->getTime(_iteration,_order);
4321   int nbOfComponents=arr->getNumberOfComponents();
4322   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4323   if(!getOrCreateAndGetArray()->isAllocated())
4324     {
4325       allocNotFromFile(arr->getNumberOfTuples());
4326       return 0;
4327     }
4328   else
4329     {
4330       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4331       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4332       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4333       _nb_of_tuples_to_be_allocated=-3;
4334       return oldNbOfTuples;
4335     }
4336 }
4337
4338 /*!
4339  * Returns number of components in \a this field
4340  *  \return int - the number of components.
4341  */
4342 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4343 {
4344   return getOrCreateAndGetArray()->getNumberOfComponents();
4345 }
4346
4347 /*!
4348  * Change info on components in \a this.
4349  * \throw If size of \a infos is not equal to the number of components already in \a this.
4350  */
4351 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4352 {
4353   DataArray *arr=getOrCreateAndGetArray();
4354   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4355 }
4356
4357 /*!
4358  * Returns info on components of \a this field.
4359  *  \return const std::vector<std::string>& - a sequence of strings each being an
4360  *          information on _i_-th component.
4361  */
4362 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4363 {
4364   const DataArray *arr=getOrCreateAndGetArray();
4365   return arr->getInfoOnComponents();
4366 }
4367
4368 /*!
4369  * Returns a mutable info on components of \a this field.
4370  *  \return std::vector<std::string>& - a sequence of strings each being an
4371  *          information on _i_-th component.
4372  */
4373 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4374 {
4375   DataArray *arr=getOrCreateAndGetArray();
4376   return arr->getInfoOnComponents();
4377 }
4378
4379 /*!
4380  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4381  *  \param [in] type - a spatial discretization of the new field.
4382  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4383  *  \param [in] mName - a name of the supporting mesh.
4384  *  \param [in] renumPol - specifies how to permute values of the result field according to
4385  *          the optional numbers of cells and nodes, if any. The valid values are
4386  *          - 0 - do not permute.
4387  *          - 1 - permute cells.
4388  *          - 2 - permute nodes.
4389  *          - 3 - permute cells and nodes.
4390  *
4391  *  \param [in] glob - the global data storing profiles and localization.
4392  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4393  *          caller is to delete this field using decrRef() as it is no more needed. 
4394  *  \throw If the MED file is not readable.
4395  *  \throw If there is no mesh named \a mName in the MED file.
4396  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4397  *  \throw If no field of \a this is lying on the mesh \a mName.
4398  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4399  */
4400 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4401 {
4402   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4403   if(mName==0)
4404     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4405   else
4406     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4407   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4408 }
4409
4410 /*!
4411  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4412  *  \param [in] type - a spatial discretization of the new field.
4413  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4414  *  \param [in] renumPol - specifies how to permute values of the result field according to
4415  *          the optional numbers of cells and nodes, if any. The valid values are
4416  *          - 0 - do not permute.
4417  *          - 1 - permute cells.
4418  *          - 2 - permute nodes.
4419  *          - 3 - permute cells and nodes.
4420  *
4421  *  \param [in] glob - the global data storing profiles and localization.
4422  *  \param [in] mesh - the supporting mesh.
4423  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4424  *          caller is to delete this field using decrRef() as it is no more needed. 
4425  *  \throw If the MED file is not readable.
4426  *  \throw If no field of \a this is lying on \a mesh.
4427  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4428  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4429  */
4430 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4431 {
4432   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4433   const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4434   const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4435   if(meshDimRelToMax==1)
4436     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4437   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4438 }
4439
4440 /*!
4441  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4442  * given mesh. 
4443  *  \param [in] type - a spatial discretization of the new field.
4444  *  \param [in] mName - a name of the supporting mesh.
4445  *  \param [in] renumPol - specifies how to permute values of the result field according to
4446  *          the optional numbers of cells and nodes, if any. The valid values are
4447  *          - 0 - do not permute.
4448  *          - 1 - permute cells.
4449  *          - 2 - permute nodes.
4450  *          - 3 - permute cells and nodes.
4451  *
4452  *  \param [in] glob - the global data storing profiles and localization.
4453  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4454  *          caller is to delete this field using decrRef() as it is no more needed. 
4455  *  \throw If the MED file is not readable.
4456  *  \throw If there is no mesh named \a mName in the MED file.
4457  *  \throw If there are no mesh entities in the mesh.
4458  *  \throw If no field values of the given \a type are available.
4459  */
4460 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4461 {
4462    MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4463   if(mName==0)
4464     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4465   else
4466     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4467   int absDim=getDimension();
4468   int meshDimRelToMax=absDim-mm->getMeshDimension();
4469   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4470 }
4471
4472 /*!
4473  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4474  *  \param [in] type - a spatial discretization of the new field.
4475  *  \param [in] renumPol - specifies how to permute values of the result field according to
4476  *          the optional numbers of cells and nodes, if any. The valid values are
4477  *          - 0 - do not permute.
4478  *          - 1 - permute cells.
4479  *          - 2 - permute nodes.
4480  *          - 3 - permute cells and nodes.
4481  *
4482  *  \param [in] glob - the global data storing profiles and localization.
4483  *  \param [in] mesh - the supporting mesh.
4484  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4485  *         field according to \a renumPol.
4486  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4487  *         field according to \a renumPol.
4488  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4489  *          caller is to delete this field using decrRef() as it is no more needed. 
4490  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4491  *  \throw If no field of \a this is lying on \a mesh.
4492  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4493  */
4494 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4495 {
4496   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4497   int meshId=getMeshIdFromMeshName(mesh->getName());
4498   bool isPfl=false;
4499   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4500   switch(renumPol)
4501     {
4502     case 0:
4503       {
4504         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4505         return ret.retn();
4506       }
4507     case 3:
4508     case 1:
4509       {
4510         if(isPfl)
4511           throw INTERP_KERNEL::Exception(msg1);
4512         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4513         if(cellRenum)
4514           {
4515             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4516               {
4517                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4518                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4519                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4520               }
4521             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4522             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4523             std::vector<DataArray *> arrOut2(1,arrOut);
4524             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4525             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4526             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4527           }
4528         if(renumPol==1)
4529           return ret.retn();
4530       }
4531     case 2:
4532       {
4533         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4534         if(isPfl)
4535           throw INTERP_KERNEL::Exception(msg1);
4536         if(nodeRenum)
4537           {
4538             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4539               {
4540                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4541                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4542                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4543               }
4544             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4545             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4546               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4547             ret->renumberNodes(nodeRenumSafe->getConstPointer());
4548           }
4549         return ret.retn();
4550       }
4551     default:
4552       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4553     }
4554 }
4555
4556 /*!
4557  * Returns values and a profile of the field of a given type lying on a given support.
4558  *  \param [in] type - a spatial discretization of the field.
4559  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4560  *  \param [in] mesh - the supporting mesh.
4561  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4562  *          field of interest lies on. If the field lies on all entities of the given
4563  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
4564  *          using decrRef() as it is no more needed.  
4565  *  \param [in] glob - the global data storing profiles and localization.
4566  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4567  *          field. The caller is to delete this array using decrRef() as it is no more needed.
4568  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4569  *  \throw If no field of \a this is lying on \a mesh.
4570  *  \throw If no field values of the given \a type are available.
4571  */
4572 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4573 {
4574   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4575   int meshId=getMeshIdFromMeshName(mesh->getName());
4576   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4577   ret->setName(nasc.getName().c_str());
4578   return ret.retn();
4579 }
4580
4581 //= MEDFileField1TSWithoutSDA
4582
4583 /*!
4584  * Throws if a given value is not a valid (non-extended) relative dimension.
4585  *  \param [in] meshDimRelToMax - the relative dimension value.
4586  *  \throw If \a meshDimRelToMax > 0.
4587  */
4588 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4589 {
4590   if(meshDimRelToMax>0)
4591     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4592 }
4593
4594 /*!
4595  * Checks if elements of a given mesh are in the order suitable for writing 
4596  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4597  * vector describing types of elements and their number.
4598  *  \param [in] mesh - the mesh to check.
4599  *  \return std::vector<int> - a vector holding for each element type (1) item of
4600  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
4601  *          These values are in full-interlace mode.
4602  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4603  */
4604 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4605 {
4606   if(!mesh)
4607     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4608   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4609   int nbOfTypes=geoTypes.size();
4610   std::vector<int> code(3*nbOfTypes);
4611   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4612   arr1->alloc(nbOfTypes,1);
4613   int *arrPtr=arr1->getPointer();
4614   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4615   for(int i=0;i<nbOfTypes;i++,it++)
4616     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4617   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4618   const int *arrPtr2=arr2->getConstPointer();
4619   int i=0;
4620   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4621     {
4622       int pos=arrPtr2[i];
4623       int nbCells=mesh->getNumberOfCellsWithType(*it);
4624       code[3*pos]=(int)(*it);
4625       code[3*pos+1]=nbCells;
4626       code[3*pos+2]=-1;//no profiles
4627     }
4628   std::vector<const DataArrayInt *> idsPerType;//no profiles
4629   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4630   if(da)
4631     {
4632       da->decrRef();
4633       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4634     }
4635   return code;
4636 }
4637
4638 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4639 {
4640   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4641 }
4642
4643 /*!
4644  * Returns all attributes and values of parts of \a this field lying on a given mesh.
4645  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4646  * item of every of returned sequences refers to the _i_-th part of \a this field.
4647  * Thus all sequences returned by this method are of the same length equal to number
4648  * of different types of supporting entities.<br>
4649  * A field part can include sub-parts with several different spatial discretizations,
4650  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4651  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4652  * of a nested sequence corresponds to a type of spatial discretization.<br>
4653  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4654  * The overhead is due to selecting values into new instances of DataArrayDouble.
4655  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4656  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4657  *          not checked if \a mname == \c NULL).
4658  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4659  *          a field part is returned. 
4660  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4661  *          A field part can include sub-parts with several different spatial discretizations,
4662  *          \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and 
4663  *          \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4664  *          This sequence is of the same length as \a types. 
4665  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4666  *          discretization. A profile name can be empty.
4667  *          Length of this and of nested sequences is the same as that of \a typesF.
4668  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4669  *          discretization. A localization name can be empty.
4670  *          Length of this and of nested sequences is the same as that of \a typesF.
4671  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4672  *          per each type of spatial discretization within one mesh entity type.
4673  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4674  *          Length of this and of nested sequences is the same as that of \a typesF.
4675  *  \throw If no field is lying on \a mname.
4676  */
4677 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *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 throw(INTERP_KERNEL::Exception)
4678 {
4679   int meshId=0;
4680   if(mname)
4681     meshId=getMeshIdFromMeshName(mname);
4682   else
4683     if(_field_per_mesh.empty())
4684       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4685   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4686   int nbOfRet=ret0.size();
4687   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4688   for(int i=0;i<nbOfRet;i++)
4689     {
4690       const std::vector< std::pair<int,int> >& p=ret0[i];
4691       int nbOfRet1=p.size();
4692       ret[i].resize(nbOfRet1);
4693       for(int j=0;j<nbOfRet1;j++)
4694         {
4695           DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4696           ret[i][j]=tmp;
4697         }
4698     }
4699   return ret;
4700 }
4701
4702 /*!
4703  * Returns a pointer to the underground DataArrayDouble instance. So the
4704  * caller should not decrRef() it. This method allows for a direct access to the field
4705  * values. This method is quite unusable if there is more than a nodal field or a cell
4706  * field on single geometric cell type. 
4707  *  \return DataArrayDouble * - the pointer to the field values array.
4708  */
4709 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4710 {
4711   const DataArrayDouble *ret=_arr;
4712   if(ret)
4713     return const_cast<DataArrayDouble *>(ret);
4714   else
4715     return 0;
4716 }
4717
4718 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4719 {
4720   return TYPE_STR;
4721 }
4722
4723 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4724 {
4725   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4726   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4727   ret->deepCpyLeavesFrom(*this);
4728   const DataArrayDouble *arr(_arr);
4729   if(arr)
4730     {
4731       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4732       ret->setArray(arr2);
4733     }
4734   return ret.retn();
4735 }
4736
4737 /*!
4738  * Returns a pointer to the underground DataArrayDouble instance. So the
4739  * caller should not decrRef() it. This method allows for a direct access to the field
4740  * values. This method is quite unusable if there is more than a nodal field or a cell
4741  * field on single geometric cell type. 
4742  *  \return DataArrayDouble * - the pointer to the field values array.
4743  */
4744 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4745 {
4746   return getUndergroundDataArrayDouble();
4747 }
4748
4749 /*!
4750  * Returns a pointer to the underground DataArrayDouble instance and a
4751  * sequence describing parameters of a support of each part of \a this field. The
4752  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4753  * direct access to the field values. This method is intended for the field lying on one
4754  * mesh only.
4755  *  \param [in,out] entries - the sequence describing parameters of a support of each
4756  *         part of \a this field. Each item of this sequence consists of two parts. The
4757  *         first part describes a type of mesh entity and an id of discretization of a
4758  *         current field part. The second part describes a range of values [begin,end)
4759  *         within the returned array relating to the current field part.
4760  *  \return DataArrayDouble * - the pointer to the field values array.
4761  *  \throw If the number of underlying meshes is not equal to 1.
4762  *  \throw If no field values are available.
4763  *  \sa getUndergroundDataArray()
4764  */
4765 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4766 {
4767   if(_field_per_mesh.size()!=1)
4768     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4769   if(_field_per_mesh[0]==0)
4770     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4771   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4772   return getUndergroundDataArrayDouble();
4773 }
4774
4775 /*!
4776  * Returns a pointer to the underground DataArrayDouble instance and a
4777  * sequence describing parameters of a support of each part of \a this field. The
4778  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4779  * direct access to the field values. This method is intended for the field lying on one
4780  * mesh only.
4781  *  \param [in,out] entries - the sequence describing parameters of a support of each
4782  *         part of \a this field. Each item of this sequence consists of two parts. The
4783  *         first part describes a type of mesh entity and an id of discretization of a
4784  *         current field part. The second part describes a range of values [begin,end)
4785  *         within the returned array relating to the current field part.
4786  *  \return DataArrayDouble * - the pointer to the field values array.
4787  *  \throw If the number of underlying meshes is not equal to 1.
4788  *  \throw If no field values are available.
4789  *  \sa getUndergroundDataArray()
4790  */
4791 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4792 {
4793   return getUndergroundDataArrayDoubleExt(entries);
4794 }
4795
4796 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4797                                                      const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4798 {
4799   DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4800   arr->setInfoAndChangeNbOfCompo(infos);
4801 }
4802
4803 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4804 {
4805 }
4806
4807 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4808 {
4809   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4810   ret->deepCpyLeavesFrom(*this);
4811   return ret.retn();
4812 }
4813
4814 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4815 {
4816   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4817   if((const DataArrayDouble *)_arr)
4818     ret->_arr=_arr->deepCpy();
4819   return ret.retn();
4820 }
4821
4822 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4823 {
4824   if(!arr)
4825     {
4826       _nb_of_tuples_to_be_allocated=-1;
4827       _arr=0;
4828       return ;
4829     }
4830   DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4831   if(!arrC)
4832     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4833   else
4834     _nb_of_tuples_to_be_allocated=-3;
4835   arrC->incrRef();
4836   _arr=arrC;
4837 }
4838
4839 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4840 {
4841   return DataArrayDouble::New();
4842 }
4843
4844 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4845 {
4846   DataArrayDouble *ret=_arr;
4847   if(ret)
4848     return ret;
4849   _arr=DataArrayDouble::New();
4850   return _arr;
4851 }
4852
4853 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4854 {
4855   return getOrCreateAndGetArrayDouble();
4856 }
4857
4858 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4859 {
4860   const DataArrayDouble *ret=_arr;
4861   if(ret)
4862     return ret;
4863   DataArrayDouble *ret2=DataArrayDouble::New();
4864   const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4865   return ret2;
4866 }
4867
4868 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4869 {
4870   return getOrCreateAndGetArrayDouble();
4871 }
4872
4873 //= MEDFileIntField1TSWithoutSDA
4874
4875 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4876                                                                 const std::vector<std::string>& infos)
4877 {
4878   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4879 }
4880
4881 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4882 {
4883 }
4884
4885 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4886                                                            const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4887 {
4888   DataArrayInt *arr=getOrCreateAndGetArrayInt();
4889   arr->setInfoAndChangeNbOfCompo(infos);
4890 }
4891
4892 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4893 {
4894   return TYPE_STR;
4895 }
4896
4897 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4898 {
4899   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4900   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4901   ret->deepCpyLeavesFrom(*this);
4902   const DataArrayInt *arr(_arr);
4903   if(arr)
4904     {
4905       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4906       ret->setArray(arr2);
4907     }
4908   return ret.retn();
4909 }
4910
4911 /*!
4912  * Returns a pointer to the underground DataArrayInt instance. So the
4913  * caller should not decrRef() it. This method allows for a direct access to the field
4914  * values. This method is quite unusable if there is more than a nodal field or a cell
4915  * field on single geometric cell type. 
4916  *  \return DataArrayInt * - the pointer to the field values array.
4917  */
4918 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4919 {
4920   return getUndergroundDataArrayInt();
4921 }
4922
4923 /*!
4924  * Returns a pointer to the underground DataArrayInt instance. So the
4925  * caller should not decrRef() it. This method allows for a direct access to the field
4926  * values. This method is quite unusable if there is more than a nodal field or a cell
4927  * field on single geometric cell type. 
4928  *  \return DataArrayInt * - the pointer to the field values array.
4929  */
4930 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4931 {
4932   const DataArrayInt *ret=_arr;
4933   if(ret)
4934     return const_cast<DataArrayInt *>(ret);
4935   else
4936     return 0;
4937 }
4938
4939 /*!
4940  * Returns a pointer to the underground DataArrayInt instance and a
4941  * sequence describing parameters of a support of each part of \a this field. The
4942  * caller should not decrRef() the returned DataArrayInt. This method allows for a
4943  * direct access to the field values. This method is intended for the field lying on one
4944  * mesh only.
4945  *  \param [in,out] entries - the sequence describing parameters of a support of each
4946  *         part of \a this field. Each item of this sequence consists of two parts. The
4947  *         first part describes a type of mesh entity and an id of discretization of a
4948  *         current field part. The second part describes a range of values [begin,end)
4949  *         within the returned array relating to the current field part.
4950  *  \return DataArrayInt * - the pointer to the field values array.
4951  *  \throw If the number of underlying meshes is not equal to 1.
4952  *  \throw If no field values are available.
4953  *  \sa getUndergroundDataArray()
4954  */
4955 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4956 {
4957   return getUndergroundDataArrayIntExt(entries);
4958 }
4959
4960 /*!
4961  * Returns a pointer to the underground DataArrayInt instance and a
4962  * sequence describing parameters of a support of each part of \a this field. The
4963  * caller should not decrRef() the returned DataArrayInt. This method allows for a
4964  * direct access to the field values. This method is intended for the field lying on one
4965  * mesh only.
4966  *  \param [in,out] entries - the sequence describing parameters of a support of each
4967  *         part of \a this field. Each item of this sequence consists of two parts. The
4968  *         first part describes a type of mesh entity and an id of discretization of a
4969  *         current field part. The second part describes a range of values [begin,end)
4970  *         within the returned array relating to the current field part.
4971  *  \return DataArrayInt * - the pointer to the field values array.
4972  *  \throw If the number of underlying meshes is not equal to 1.
4973  *  \throw If no field values are available.
4974  *  \sa getUndergroundDataArray()
4975  */
4976 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4977 {
4978   if(_field_per_mesh.size()!=1)
4979     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4980   if(_field_per_mesh[0]==0)
4981     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4982   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4983   return getUndergroundDataArrayInt();
4984 }
4985
4986 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4987 {
4988   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4989   ret->deepCpyLeavesFrom(*this);
4990   return ret.retn();
4991 }
4992
4993 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4994 {
4995   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4996   if((const DataArrayInt *)_arr)
4997     ret->_arr=_arr->deepCpy();
4998   return ret.retn();
4999 }
5000
5001 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5002 {
5003   if(!arr)
5004     {
5005       _nb_of_tuples_to_be_allocated=-1;
5006       _arr=0;
5007       return ;
5008     }
5009   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5010   if(!arrC)
5011     throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5012   else
5013     _nb_of_tuples_to_be_allocated=-3;
5014   arrC->incrRef();
5015   _arr=arrC;
5016 }
5017
5018 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5019 {
5020   return DataArrayInt::New();
5021 }
5022
5023 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5024 {
5025   DataArrayInt *ret=_arr;
5026   if(ret)
5027     return ret;
5028   _arr=DataArrayInt::New();
5029   return _arr;
5030 }
5031
5032 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5033 {
5034   return getOrCreateAndGetArrayInt();
5035 }
5036
5037 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5038 {
5039   const DataArrayInt *ret=_arr;
5040   if(ret)
5041     return ret;
5042   DataArrayInt *ret2=DataArrayInt::New();
5043   const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5044   return ret2;
5045 }
5046
5047 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5048 {
5049   return getOrCreateAndGetArrayInt();
5050 }
5051
5052 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5053 {
5054 }
5055
5056 //= MEDFileAnyTypeField1TS
5057
5058 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5059 {
5060   med_field_type typcha;
5061   //
5062   std::vector<std::string> infos;
5063   std::string dtunit,fieldName;
5064   LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5065   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5066   switch(typcha)
5067     {
5068     case MED_FLOAT64:
5069       {
5070         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5071         break;
5072       }
5073     case MED_INT32:
5074       {
5075         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5076         break;
5077       }
5078     default:
5079       {
5080         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] !";
5081         throw INTERP_KERNEL::Exception(oss.str().c_str());
5082       }
5083     }
5084   ret->setDtUnit(dtunit.c_str());
5085   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5086   //
5087   med_int numdt,numit;
5088   med_float dt;
5089   MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5090   ret->setTime(numdt,numit,dt);
5091   ret->_csit=1;
5092   if(loadAll)
5093     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5094   else
5095     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5096   return ret.retn();
5097 }
5098
5099 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5100 try:MEDFileFieldGlobsReal(fileName)
5101 {
5102   MEDFileUtilities::CheckFileForRead(fileName);
5103   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5104   _content=BuildContentFrom(fid,fileName,loadAll);
5105   loadGlobals(fid);
5106 }
5107 catch(INTERP_KERNEL::Exception& e)
5108   {
5109     throw e;
5110   }
5111
5112 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5113 {
5114   med_field_type typcha;
5115   std::vector<std::string> infos;
5116   std::string dtunit;
5117   int iii=-1;
5118   int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5119   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5120   switch(typcha)
5121     {
5122     case MED_FLOAT64:
5123       {
5124         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5125         break;
5126       }
5127     case MED_INT32:
5128       {
5129         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5130         break;
5131       }
5132     default:
5133       {
5134         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] !";
5135         throw INTERP_KERNEL::Exception(oss.str().c_str());
5136       }
5137     }
5138   ret->setDtUnit(dtunit.c_str());
5139   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5140   //
5141   if(nbSteps<1)
5142     {
5143       std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5144       throw INTERP_KERNEL::Exception(oss.str().c_str());
5145     }
5146   //
5147   med_int numdt,numit;
5148   med_float dt;
5149   MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5150   ret->setTime(numdt,numit,dt);
5151   ret->_csit=1;
5152   if(loadAll)
5153     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5154   else
5155     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5156   return ret.retn();
5157 }
5158
5159 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5160 try:MEDFileFieldGlobsReal(fileName)
5161 {
5162   MEDFileUtilities::CheckFileForRead(fileName);
5163   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5164   _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5165   loadGlobals(fid);
5166 }
5167 catch(INTERP_KERNEL::Exception& e)
5168   {
5169     throw e;
5170   }
5171
5172 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5173 {
5174   if(!c)
5175     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5176   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5177     {
5178       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5179       ret->setFileName(fileName);
5180       ret->_content=c; c->incrRef();
5181       return ret.retn();
5182     }
5183   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5184     {
5185       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5186       ret->setFileName(fileName);
5187       ret->_content=c; c->incrRef();
5188       return ret.retn();
5189     }
5190   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5191 }
5192
5193 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5194 {
5195   MEDFileUtilities::CheckFileForRead(fileName);
5196   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5197   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5198   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5199   ret->loadGlobals(fid);
5200   return ret.retn();
5201 }
5202
5203 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5204 {
5205   MEDFileUtilities::CheckFileForRead(fileName);
5206   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5207   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5208   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5209   ret->loadGlobals(fid);
5210   return ret.retn();
5211 }
5212
5213 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5214 {
5215   MEDFileUtilities::CheckFileForRead(fileName);
5216   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5217   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5218   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5219   ret->loadGlobals(fid);
5220   return ret.retn();
5221 }
5222
5223 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5224 {
5225   med_field_type typcha;
5226   std::vector<std::string> infos;
5227   std::string dtunit;
5228   int iii=-1;
5229   int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5230   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5231   switch(typcha)
5232     {
5233     case MED_FLOAT64:
5234       {
5235         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5236         break;
5237       }
5238     case MED_INT32:
5239       {
5240         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5241         break;
5242       }
5243     default:
5244       {
5245         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] !";
5246         throw INTERP_KERNEL::Exception(oss.str().c_str());
5247       }
5248     }
5249   ret->setDtUnit(dtunit.c_str());
5250   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5251   //
5252   bool found=false;
5253   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5254   for(int i=0;i<nbOfStep2 && !found;i++)
5255     {
5256       med_int numdt,numit;
5257       med_float dt;
5258       MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5259       if(numdt==iteration && numit==order)
5260         {
5261           found=true;
5262           ret->_csit=i+1;
5263         }
5264       else
5265         dtits[i]=std::pair<int,int>(numdt,numit);
5266     }
5267   if(!found)
5268     {
5269       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5270       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5271         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5272       throw INTERP_KERNEL::Exception(oss.str().c_str());
5273     }
5274   if(loadAll)
5275     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5276   else
5277     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5278   return ret.retn();
5279 }
5280
5281 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5282 try:MEDFileFieldGlobsReal(fileName)
5283 {
5284   MEDFileUtilities::CheckFileForRead(fileName);
5285   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5286   _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5287   loadGlobals(fid);
5288 }
5289 catch(INTERP_KERNEL::Exception& e)
5290   {
5291     throw e;
5292   }
5293
5294 /*!
5295  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5296  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5297  *
5298  * \warning this is a shallow copy constructor
5299  */
5300 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5301 {
5302   if(!shallowCopyOfContent)
5303     {
5304       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5305       otherPtr->incrRef();
5306       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5307     }
5308   else
5309     {
5310       _content=other.shallowCpy();
5311     }
5312 }
5313
5314 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5315 {
5316   if(checkFieldId)
5317     {
5318       int nbFields=MEDnField(fid);
5319       if(fieldIdCFormat>=nbFields)
5320         {
5321           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5322           throw INTERP_KERNEL::Exception(oss.str().c_str());
5323         }
5324     }
5325   int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5326   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5327   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5328   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5329   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5330   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5331   med_bool localMesh;
5332   int nbOfStep;
5333   MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5334   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5335   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5336   infos.clear(); infos.resize(ncomp);
5337   for(int j=0;j<ncomp;j++)
5338     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5339   return nbOfStep;
5340 }
5341
5342 /*!
5343  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5344  * 
5345  * \param [out]
5346  * \return in case of success the number of time steps available for the field with name \a fieldName.
5347  */
5348 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5349 {
5350   int nbFields=MEDnField(fid);
5351   bool found=false;
5352   std::vector<std::string> fns(nbFields);
5353   int nbOfStep2=-1;
5354   for(int i=0;i<nbFields && !found;i++)
5355     {
5356       std::string tmp;
5357       nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5358       fns[i]=tmp;
5359       found=(tmp==fieldName);
5360       if(found)
5361         posCFormat=i;
5362     }
5363   if(!found)
5364     {
5365       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5366       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5367         oss << "\"" << *it << "\" ";
5368       throw INTERP_KERNEL::Exception(oss.str().c_str());
5369     }
5370   return nbOfStep2;
5371 }
5372
5373 /*!
5374  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5375  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5376  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5377  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5378  * to keep a valid instance.
5379  * 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.
5380  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5381  * 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.
5382  *
5383  * \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.
5384  * \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.
5385  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5386  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5387  * \param [in] newLocName is the new localization name.
5388  * \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.
5389  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5390  */
5391 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5392 {
5393   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5394   std::string oldPflName=disc->getProfile();
5395   std::vector<std::string> vv=getPflsReallyUsedMulti();
5396   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5397   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5398     {
5399       disc->setProfile(newPflName);
5400       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5401       pfl->setName(newPflName);
5402     }
5403   else
5404     {
5405       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5406       throw INTERP_KERNEL::Exception(oss.str().c_str());
5407     }
5408 }
5409
5410 /*!
5411  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5412  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5413  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5414  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5415  * to keep a valid instance.
5416  * 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.
5417  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5418  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5419  * 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.
5420  *
5421  * \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.
5422  * \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.
5423  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5424  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5425  * \param [in] newLocName is the new localization name.
5426  * \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.
5427  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5428  */
5429 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5430 {
5431   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5432   std::string oldLocName=disc->getLocalization();
5433   std::vector<std::string> vv=getLocsReallyUsedMulti();
5434   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5435   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5436     {
5437       disc->setLocalization(newLocName);
5438       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5439       loc.setName(newLocName);
5440     }
5441   else
5442     {
5443       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5444       throw INTERP_KERNEL::Exception(oss.str().c_str());
5445     }
5446 }
5447
5448 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5449 {
5450   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5451   if(!ret)
5452     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5453   return ret;
5454 }
5455
5456 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5457 {
5458   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5459   if(!ret)
5460     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5461   return ret;
5462 }
5463
5464 /*!
5465  * Writes \a this field into a MED file specified by its name.
5466  *  \param [in] fileName - the MED file name.
5467  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5468  * - 2 - erase; an existing file is removed.
5469  * - 1 - append; same data should not be present in an existing file.
5470  * - 0 - overwrite; same data present in an existing file is overwritten.
5471  *  \throw If the field name is not set.
5472  *  \throw If no field data is set.
5473  *  \throw If \a mode == 1 and the same data is present in an existing file.
5474  */
5475 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5476 {
5477   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5478   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5479   writeLL(fid);
5480 }
5481
5482 /*!
5483  * This method alloc the arrays and load potentially huge arrays contained in this field.
5484  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5485  * This method can be also called to refresh or reinit values from a file.
5486  * 
5487  * \throw If the fileName is not set or points to a non readable MED file.
5488  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5489  */
5490 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5491 {
5492   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5493   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5494 }
5495
5496 /*!
5497  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5498  * But once data loaded once, this method does nothing.
5499  * 
5500  * \throw If the fileName is not set or points to a non readable MED file.
5501  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays
5502  */
5503 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5504 {
5505   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5506   contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5507 }
5508
5509 /*!
5510  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5511  * This method does not release arrays set outside the context of a MED file.
5512  * 
5513  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5514  */
5515 void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception)
5516 {
5517   contentNotNullBase()->releaseArrays();
5518 }
5519
5520 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5521 {
5522   int nbComp=getNumberOfComponents();
5523   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5524   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5525   for(int i=0;i<nbComp;i++)
5526     {
5527       std::string info=getInfo()[i];
5528       std::string c,u;
5529       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5530       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5531       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5532     }
5533   if(getName().empty())
5534     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5535   MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5536   writeGlobals(fid,*this);
5537   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5538 }
5539
5540 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5541 {
5542   std::size_t ret=0;
5543   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5544     ret+=_content->getHeapMemorySize();
5545   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5546 }
5547
5548 /*!
5549  * Returns a string describing \a this field. This string is outputted 
5550  * by \c print Python command.
5551  */
5552 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5553 {
5554   std::ostringstream oss;
5555   contentNotNullBase()->simpleRepr(0,oss,-1);
5556   simpleReprGlobs(oss);
5557   return oss.str();
5558 }
5559
5560 /*!
5561  * This method returns all profiles whose name is non empty used.
5562  * \b WARNING If profile is used several times it will be reported \b only \b once.
5563  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5564  */
5565 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5566 {
5567   return contentNotNullBase()->getPflsReallyUsed2();
5568 }
5569
5570 /*!
5571  * This method returns all localizations whose name is non empty used.
5572  * \b WARNING If localization is used several times it will be reported \b only \b once.
5573  */
5574 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5575 {
5576   return contentNotNullBase()->getLocsReallyUsed2();
5577 }
5578
5579 /*!
5580  * This method returns all profiles whose name is non empty used.
5581  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5582  */
5583 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5584 {
5585   return contentNotNullBase()->getPflsReallyUsedMulti2();
5586 }
5587
5588 /*!
5589  * This method returns all localizations whose name is non empty used.
5590  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5591  */
5592 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5593 {
5594   return contentNotNullBase()->getLocsReallyUsedMulti2();
5595 }
5596
5597 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5598 {
5599   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5600 }
5601
5602 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5603 {
5604   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5605 }
5606
5607 int MEDFileAnyTypeField1TS::getDimension() const
5608 {
5609   return contentNotNullBase()->getDimension();
5610 }
5611
5612 int MEDFileAnyTypeField1TS::getIteration() const
5613 {
5614   return contentNotNullBase()->getIteration();
5615 }
5616
5617 int MEDFileAnyTypeField1TS::getOrder() const
5618 {
5619   return contentNotNullBase()->getOrder();
5620 }
5621
5622 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5623 {
5624   return contentNotNullBase()->getTime(iteration,order);
5625 }
5626
5627 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5628 {
5629   contentNotNullBase()->setTime(iteration,order,val);
5630 }
5631
5632 std::string MEDFileAnyTypeField1TS::getName() const
5633 {
5634   return contentNotNullBase()->getName();
5635 }
5636
5637 void MEDFileAnyTypeField1TS::setName(const char *name)
5638 {
5639   contentNotNullBase()->setName(name);
5640 }
5641
5642 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5643 {
5644   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5645 }
5646
5647 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5648 {
5649   return contentNotNullBase()->getDtUnit();
5650 }
5651
5652 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5653 {
5654   contentNotNullBase()->setDtUnit(dtUnit);
5655 }
5656
5657 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5658 {
5659   return contentNotNullBase()->getMeshName();
5660 }
5661
5662 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5663 {
5664   contentNotNullBase()->setMeshName(newMeshName);
5665 }
5666
5667 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5668 {
5669   return contentNotNullBase()->changeMeshNames(modifTab);
5670 }
5671
5672 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5673 {
5674   return contentNotNullBase()->getMeshIteration();
5675 }
5676
5677 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5678 {
5679   return contentNotNullBase()->getMeshOrder();
5680 }
5681
5682 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5683 {
5684   return contentNotNullBase()->getNumberOfComponents();
5685 }
5686
5687 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5688 {
5689   return contentNotNullBase()->isDealingTS(iteration,order);
5690 }
5691
5692 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5693 {
5694   return contentNotNullBase()->getDtIt();
5695 }
5696
5697 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5698 {
5699   contentNotNullBase()->fillIteration(p);
5700 }
5701
5702 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5703 {
5704   contentNotNullBase()->fillTypesOfFieldAvailable(types);
5705 }
5706
5707 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5708 {
5709   contentNotNullBase()->setInfo(infos);
5710 }
5711
5712 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5713 {
5714   return contentNotNullBase()->getInfo();
5715 }
5716 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5717 {
5718   return contentNotNullBase()->getInfo();
5719 }
5720
5721 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5722 {
5723   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5724 }
5725
5726 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5727 {
5728   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5729 }
5730
5731 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5732 {
5733   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5734 }
5735
5736 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5737 {
5738   return contentNotNullBase()->getTypesOfFieldAvailable();
5739 }
5740
5741 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5742                                                                                        std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5743 {
5744   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5745 }
5746
5747 /*!
5748  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5749  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5750  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5751  */
5752 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5753 {
5754   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5755   if(!content)
5756     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5757   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5758   std::size_t sz(contentsSplit.size());
5759   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5760   for(std::size_t i=0;i<sz;i++)
5761     {
5762       ret[i]=shallowCpy();
5763       ret[i]->_content=contentsSplit[i];
5764     }
5765   return ret;
5766 }
5767
5768 /*!
5769  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5770  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5771  */
5772 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5773 {
5774   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5775   if(!content)
5776     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5777   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5778   std::size_t sz(contentsSplit.size());
5779   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5780   for(std::size_t i=0;i<sz;i++)
5781     {
5782       ret[i]=shallowCpy();
5783       ret[i]->_content=contentsSplit[i];
5784     }
5785   return ret;
5786 }
5787
5788 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5789 {
5790   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5791   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5792     ret->_content=_content->deepCpy();
5793   ret->deepCpyGlobs(*this);
5794   return ret.retn();
5795 }
5796
5797 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5798 {
5799   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5800 }
5801
5802 //= MEDFileField1TS
5803
5804 /*!
5805  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
5806  * the first field that has been read from a specified MED file.
5807  *  \param [in] fileName - the name of the MED file to read.
5808  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5809  *          is to delete this field using decrRef() as it is no more needed.
5810  *  \throw If reading the file fails.
5811  */
5812 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5813 {
5814   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5815   ret->contentNotNull();
5816   return ret.retn();
5817 }
5818
5819 /*!
5820  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
5821  * a given field that has been read from a specified MED file.
5822  *  \param [in] fileName - the name of the MED file to read.
5823  *  \param [in] fieldName - the name of the field to read.
5824  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5825  *          is to delete this field using decrRef() as it is no more needed.
5826  *  \throw If reading the file fails.
5827  *  \throw If there is no field named \a fieldName in the file.
5828  */
5829 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5830 {
5831   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5832   ret->contentNotNull();
5833   return ret.retn();
5834 }
5835
5836 /*!
5837  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
5838  * a given field that has been read from a specified MED file.
5839  *  \param [in] fileName - the name of the MED file to read.
5840  *  \param [in] fieldName - the name of the field to read.
5841  *  \param [in] iteration - the iteration number of a required time step.
5842  *  \param [in] order - the iteration order number of required time step.
5843  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5844  *          is to delete this field using decrRef() as it is no more needed.
5845  *  \throw If reading the file fails.
5846  *  \throw If there is no field named \a fieldName in the file.
5847  *  \throw If the required time step is missing from the file.
5848  */
5849 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5850 {
5851   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5852   ret->contentNotNull();
5853   return ret.retn();
5854 }
5855
5856 /*!
5857  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5858  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5859  *
5860  * Returns a new instance of MEDFileField1TS holding either a shallow copy
5861  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5862  * \warning this is a shallow copy constructor
5863  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5864  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5865  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5866  *          is to delete this field using decrRef() as it is no more needed.
5867  */
5868 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5869 {
5870   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5871   ret->contentNotNull();
5872   return ret.retn();
5873 }
5874
5875 /*!
5876  * Returns a new empty instance of MEDFileField1TS.
5877  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5878  *          is to delete this field using decrRef() as it is no more needed.
5879  */
5880 MEDFileField1TS *MEDFileField1TS::New()
5881 {
5882   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5883   ret->contentNotNull();
5884   return ret.retn();
5885 }
5886
5887 /*!
5888  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5889  * following the given input policy.
5890  *
5891  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5892  *                            By default (true) the globals are deeply copied.
5893  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5894  */
5895 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5896 {
5897   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5898   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5899   if(content)
5900     {
5901       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5902       if(!contc)
5903         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5904       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5905       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5906     }
5907   else
5908     ret=MEDFileIntField1TS::New();
5909   if(deepCpyGlobs)
5910     ret->deepCpyGlobs(*this);
5911   else
5912     ret->shallowCpyGlobs(*this);
5913   return ret.retn();
5914 }
5915
5916 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5917 {
5918   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5919   if(!pt)
5920     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5921   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5922   if(!ret)
5923     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 !");
5924   return ret;
5925 }
5926
5927 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5928 {
5929   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5930   if(!pt)
5931     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5932   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5933   if(!ret)
5934     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 !");
5935   return ret;
5936 }
5937
5938 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5939 {
5940   if(!f)
5941     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5942   if(!((DataArray*)arr))
5943     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5944   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5945   if(!arrOutC)
5946     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5947   f->setArray(arrOutC);
5948 }
5949
5950 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5951 {
5952   if(!((DataArray*)arr))
5953     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5954   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5955   if(!arrOutC)
5956     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5957   arrOutC->incrRef();
5958   return arrOutC;
5959 }
5960
5961 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5962 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5963 {
5964 }
5965 catch(INTERP_KERNEL::Exception& e)
5966   { throw e; }
5967
5968 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5969 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5970 {
5971 }
5972 catch(INTERP_KERNEL::Exception& e)
5973   { throw e; }
5974
5975 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5976 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
5977 {
5978 }
5979 catch(INTERP_KERNEL::Exception& e)
5980   { throw e; }
5981
5982 /*!
5983  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5984  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5985  *
5986  * \warning this is a shallow copy constructor
5987  */
5988 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5989 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5990 {
5991 }
5992 catch(INTERP_KERNEL::Exception& e)
5993   { throw e; }
5994
5995 MEDFileField1TS::MEDFileField1TS()
5996 {
5997   _content=new MEDFileField1TSWithoutSDA;
5998 }
5999
6000 /*!
6001  * Returns a new MEDCouplingFieldDouble of a given type lying on
6002  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6003  * has not been constructed via file reading, an exception is thrown.
6004  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6005  *  \param [in] type - a spatial discretization of interest.
6006  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6007  *  \param [in] renumPol - specifies how to permute values of the result field according to
6008  *          the optional numbers of cells and nodes, if any. The valid values are
6009  *          - 0 - do not permute.
6010  *          - 1 - permute cells.
6011  *          - 2 - permute nodes.
6012  *          - 3 - permute cells and nodes.
6013  *
6014  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6015  *          caller is to delete this field using decrRef() as it is no more needed. 
6016  *  \throw If \a this field has not been constructed via file reading.
6017  *  \throw If the MED file is not readable.
6018  *  \throw If there is no mesh in the MED file.
6019  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6020  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6021  *  \sa getFieldOnMeshAtLevel()
6022  */
6023 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6024 {
6025   if(getFileName2().empty())
6026     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6027   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6028   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6029   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6030   return ret.retn();
6031 }
6032
6033 /*!
6034  * Returns a new MEDCouplingFieldDouble of a given type lying on
6035  * the top level cells of the first mesh in MED file. If \a this field 
6036  * has not been constructed via file reading, an exception is thrown.
6037  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6038  *  \param [in] type - a spatial discretization of interest.
6039  *  \param [in] renumPol - specifies how to permute values of the result field according to
6040  *          the optional numbers of cells and nodes, if any. The valid values are
6041  *          - 0 - do not permute.
6042  *          - 1 - permute cells.
6043  *          - 2 - permute nodes.
6044  *          - 3 - permute cells and nodes.
6045  *
6046  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6047  *          caller is to delete this field using decrRef() as it is no more needed. 
6048  *  \throw If \a this field has not been constructed via file reading.
6049  *  \throw If the MED file is not readable.
6050  *  \throw If there is no mesh in the MED file.
6051  *  \throw If no field values of the given \a type.
6052  *  \throw If no field values lying on the top level support.
6053  *  \sa getFieldAtLevel()
6054  */
6055 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6056 {
6057   if(getFileName2().empty())
6058     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6059   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6060   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6061   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6062   return ret.retn();
6063 }
6064
6065 /*!
6066  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6067  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6068  *  \param [in] type - a spatial discretization of the new field.
6069  *  \param [in] mesh - the supporting mesh.
6070  *  \param [in] renumPol - specifies how to permute values of the result field according to
6071  *          the optional numbers of cells and nodes, if any. The valid values are
6072  *          - 0 - do not permute.
6073  *          - 1 - permute cells.
6074  *          - 2 - permute nodes.
6075  *          - 3 - permute cells and nodes.
6076  *
6077  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6078  *          caller is to delete this field using decrRef() as it is no more needed. 
6079  *  \throw If no field of \a this is lying on \a mesh.
6080  *  \throw If the mesh is empty.
6081  *  \throw If no field values of the given \a type are available.
6082  *  \sa getFieldAtLevel()
6083  *  \sa getFieldOnMeshAtLevel() 
6084  */
6085 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6086 {
6087   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6088   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6089   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6090   return ret.retn();
6091 }
6092
6093 /*!
6094  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6095  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6096  *  \param [in] type - a spatial discretization of interest.
6097  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6098  *  \param [in] mesh - the supporting mesh.
6099  *  \param [in] renumPol - specifies how to permute values of the result field according to
6100  *          the optional numbers of cells and nodes, if any. The valid values are
6101  *          - 0 - do not permute.
6102  *          - 1 - permute cells.
6103  *          - 2 - permute nodes.
6104  *          - 3 - permute cells and nodes.
6105  *
6106  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6107  *          caller is to delete this field using decrRef() as it is no more needed. 
6108  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6109  *  \throw If no field of \a this is lying on \a mesh.
6110  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6111  *  \sa getFieldAtLevel()
6112  *  \sa getFieldOnMeshAtLevel() 
6113  */
6114 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6115 {
6116   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6117   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6118   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6119   return ret.retn();
6120 }
6121
6122 /*!
6123  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6124  * This method is called "Old" because in MED3 norm a field has only one meshName
6125  * attached, so this method is for readers of MED2 files. If \a this field 
6126  * has not been constructed via file reading, an exception is thrown.
6127  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6128  *  \param [in] type - a spatial discretization of interest.
6129  *  \param [in] mName - a name of the supporting mesh.
6130  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6131  *  \param [in] renumPol - specifies how to permute values of the result field according to
6132  *          the optional numbers of cells and nodes, if any. The valid values are
6133  *          - 0 - do not permute.
6134  *          - 1 - permute cells.
6135  *          - 2 - permute nodes.
6136  *          - 3 - permute cells and nodes.
6137  *
6138  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6139  *          caller is to delete this field using decrRef() as it is no more needed. 
6140  *  \throw If the MED file is not readable.
6141  *  \throw If there is no mesh named \a mName in the MED file.
6142  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6143  *  \throw If \a this field has not been constructed via file reading.
6144  *  \throw If no field of \a this is lying on the mesh named \a mName.
6145  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6146  *  \sa getFieldAtLevel()
6147  */
6148 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6149 {
6150   if(getFileName2().empty())
6151     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6152   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6153   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6154   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6155   return ret.retn();
6156 }
6157
6158 /*!
6159  * Returns values and a profile of the field of a given type lying on a given support.
6160  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6161  *  \param [in] type - a spatial discretization of the field.
6162  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6163  *  \param [in] mesh - the supporting mesh.
6164  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6165  *          field of interest lies on. If the field lies on all entities of the given
6166  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6167  *          using decrRef() as it is no more needed.  
6168  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6169  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6170  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6171  *  \throw If no field of \a this is lying on \a mesh.
6172  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6173  */
6174 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6175 {
6176   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6177   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6178 }
6179
6180 /*!
6181  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6182  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6183  * "Sort By Type"), if not, an exception is thrown. 
6184  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6185  *  \param [in] field - the field to add to \a this.
6186  *  \throw If the name of \a field is empty.
6187  *  \throw If the data array of \a field is not set.
6188  *  \throw If the data array is already allocated but has different number of components
6189  *         than \a field.
6190  *  \throw If the underlying mesh of \a field has no name.
6191  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6192  */
6193 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6194 {
6195   setFileName("");
6196   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6197 }
6198
6199 /*!
6200  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6201  * of a given mesh are used as the support of the given field (a real support is not used). 
6202  * Elements of the given mesh must be sorted suitable for writing to MED file.
6203  * Order of underlying mesh entities of the given field specified by \a profile parameter
6204  * is not prescribed; this method permutes field values to have them sorted by element
6205  * type as required for writing to MED file. A new profile is added only if no equal
6206  * profile is missing.
6207  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6208  *  \param [in] field - the field to add to \a this.
6209  *  \param [in] mesh - the supporting mesh of \a field.
6210  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6211  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6212  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6213  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6214  *  \throw If the data array of \a field is not set.
6215  *  \throw If the data array of \a this is already allocated but has different number of
6216  *         components than \a field.
6217  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6218  *  \sa setFieldNoProfileSBT()
6219  */
6220 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6221 {
6222   setFileName("");
6223   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6224 }
6225
6226 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6227 {
6228   return new MEDFileField1TS(*this);
6229 }
6230
6231 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6232 {
6233   return contentNotNull()->getUndergroundDataArrayDouble();
6234 }
6235
6236 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6237 {
6238   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6239 }
6240
6241 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6242                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6243 {
6244   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6245 }
6246
6247 //= MEDFileIntField1TS
6248
6249 MEDFileIntField1TS *MEDFileIntField1TS::New()
6250 {
6251   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6252   ret->contentNotNull();
6253   return ret.retn();
6254 }
6255
6256 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6257 {
6258   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6259   ret->contentNotNull();
6260   return ret.retn();
6261 }
6262
6263 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6264 {
6265   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6266   ret->contentNotNull();
6267   return ret.retn();
6268 }
6269
6270 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6271 {
6272   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6273   ret->contentNotNull();
6274   return ret.retn();
6275 }
6276
6277 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6278 {
6279   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6280   ret->contentNotNull();
6281   return ret.retn();
6282 }
6283
6284 MEDFileIntField1TS::MEDFileIntField1TS()
6285 {
6286   _content=new MEDFileIntField1TSWithoutSDA;
6287 }
6288
6289 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6290 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6291 {
6292 }
6293 catch(INTERP_KERNEL::Exception& e)
6294   { throw e; }
6295
6296 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6297 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6298 {
6299 }
6300 catch(INTERP_KERNEL::Exception& e)
6301   { throw e; }
6302
6303 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6304 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6305 {
6306 }
6307 catch(INTERP_KERNEL::Exception& e)
6308   { throw e; }
6309
6310 /*!
6311  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6312  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6313  *
6314  * \warning this is a shallow copy constructor
6315  */
6316 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6317 {
6318 }
6319
6320 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6321 {
6322   return new MEDFileIntField1TS(*this);
6323 }
6324
6325 /*!
6326  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6327  * following the given input policy.
6328  *
6329  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6330  *                            By default (true) the globals are deeply copied.
6331  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6332  */
6333 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6334 {
6335   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6336   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6337   if(content)
6338     {
6339       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6340       if(!contc)
6341         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6342       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6343       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6344     }
6345   else
6346     ret=MEDFileField1TS::New();
6347   if(deepCpyGlobs)
6348     ret->deepCpyGlobs(*this);
6349   else
6350     ret->shallowCpyGlobs(*this);
6351   return ret.retn();
6352 }
6353
6354 /*!
6355  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6356  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6357  * "Sort By Type"), if not, an exception is thrown. 
6358  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6359  *  \param [in] field - the field to add to \a this. The field double values are ignored.
6360  *  \param [in] arrOfVals - the values of the field \a field used.
6361  *  \throw If the name of \a field is empty.
6362  *  \throw If the data array of \a field is not set.
6363  *  \throw If the data array is already allocated but has different number of components
6364  *         than \a field.
6365  *  \throw If the underlying mesh of \a field has no name.
6366  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6367  */
6368 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6369 {
6370   setFileName("");
6371   contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6372 }
6373
6374 /*!
6375  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6376  * of a given mesh are used as the support of the given field (a real support is not used). 
6377  * Elements of the given mesh must be sorted suitable for writing to MED file.
6378  * Order of underlying mesh entities of the given field specified by \a profile parameter
6379  * is not prescribed; this method permutes field values to have them sorted by element
6380  * type as required for writing to MED file. A new profile is added only if no equal
6381  * profile is missing.
6382  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6383  *  \param [in] field - the field to add to \a this. The field double values are ignored.
6384  *  \param [in] arrOfVals - the values of the field \a field used.
6385  *  \param [in] mesh - the supporting mesh of \a field.
6386  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6387  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6388  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6389  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6390  *  \throw If the data array of \a field is not set.
6391  *  \throw If the data array of \a this is already allocated but has different number of
6392  *         components than \a field.
6393  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6394  *  \sa setFieldNoProfileSBT()
6395  */
6396 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6397 {
6398   setFileName("");
6399   contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6400 }
6401
6402 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6403 {
6404   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6405   if(!pt)
6406     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6407   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6408   if(!ret)
6409     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 !");
6410   return ret;
6411 }
6412
6413 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6414 {
6415   if(getFileName2().empty())
6416     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6417   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6418   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6419   DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6420   if(!arrOutC)
6421     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6422   arrOut=arrOutC;
6423   return ret.retn();
6424 }
6425
6426 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6427 {
6428   if(!((DataArray *)arr))
6429     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6430   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6431   if(!arrC)
6432     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6433   arrC->incrRef();
6434   return arrC;
6435 }
6436
6437 /*!
6438  * Returns a new MEDCouplingFieldDouble of a given type lying on
6439  * the top level cells of the first mesh in MED file. If \a this field 
6440  * has not been constructed via file reading, an exception is thrown.
6441  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6442  *  \param [in] type - a spatial discretization of interest.
6443  *  \param [out] arrOut - the DataArrayInt containing values of field.
6444  *  \param [in] renumPol - specifies how to permute values of the result field according to
6445  *          the optional numbers of cells and nodes, if any. The valid values are
6446  *          - 0 - do not permute.
6447  *          - 1 - permute cells.
6448  *          - 2 - permute nodes.
6449  *          - 3 - permute cells and nodes.
6450  *
6451  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6452  *          caller is to delete this field using decrRef() as it is no more needed. 
6453  *  \throw If \a this field has not been constructed via file reading.
6454  *  \throw If the MED file is not readable.
6455  *  \throw If there is no mesh in the MED file.
6456  *  \throw If no field values of the given \a type.
6457  *  \throw If no field values lying on the top level support.
6458  *  \sa getFieldAtLevel()
6459  */
6460 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6461 {
6462   if(getFileName2().empty())
6463     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6464   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6465   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6466   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6467   return ret.retn();
6468 }
6469
6470 /*!
6471  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6472  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6473  *  \param [in] type - a spatial discretization of the new field.
6474  *  \param [in] mesh - the supporting mesh.
6475  *  \param [out] arrOut - the DataArrayInt containing values of field.
6476  *  \param [in] renumPol - specifies how to permute values of the result field according to
6477  *          the optional numbers of cells and nodes, if any. The valid values are
6478  *          - 0 - do not permute.
6479  *          - 1 - permute cells.
6480  *          - 2 - permute nodes.
6481  *          - 3 - permute cells and nodes.
6482  *
6483  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6484  *          caller is to delete this field using decrRef() as it is no more needed. 
6485  *  \throw If no field of \a this is lying on \a mesh.
6486  *  \throw If the mesh is empty.
6487  *  \throw If no field values of the given \a type are available.
6488  *  \sa getFieldAtLevel()
6489  *  \sa getFieldOnMeshAtLevel() 
6490  */
6491 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6492 {
6493   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6494   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6495   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6496   return ret.retn();
6497 }
6498
6499 /*!
6500  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6501  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6502  *  \param [in] type - a spatial discretization of interest.
6503  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6504  *  \param [out] arrOut - the DataArrayInt containing values of field.
6505  *  \param [in] mesh - the supporting mesh.
6506  *  \param [in] renumPol - specifies how to permute values of the result field according to
6507  *          the optional numbers of cells and nodes, if any. The valid values are
6508  *          - 0 - do not permute.
6509  *          - 1 - permute cells.
6510  *          - 2 - permute nodes.
6511  *          - 3 - permute cells and nodes.
6512  *
6513  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6514  *          caller is to delete this field using decrRef() as it is no more needed. 
6515  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6516  *  \throw If no field of \a this is lying on \a mesh.
6517  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6518  *  \sa getFieldAtLevel()
6519  *  \sa getFieldOnMeshAtLevel() 
6520  */
6521 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6522 {
6523   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6524   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6525   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6526   return ret.retn();
6527 }
6528
6529 /*!
6530  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6531  * This method is called "Old" because in MED3 norm a field has only one meshName
6532  * attached, so this method is for readers of MED2 files. If \a this field 
6533  * has not been constructed via file reading, an exception is thrown.
6534  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6535  *  \param [in] type - a spatial discretization of interest.
6536  *  \param [in] mName - a name of the supporting mesh.
6537  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6538  *  \param [out] arrOut - the DataArrayInt containing values of field.
6539  *  \param [in] renumPol - specifies how to permute values of the result field according to
6540  *          the optional numbers of cells and nodes, if any. The valid values are
6541  *          - 0 - do not permute.
6542  *          - 1 - permute cells.
6543  *          - 2 - permute nodes.
6544  *          - 3 - permute cells and nodes.
6545  *
6546  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6547  *          caller is to delete this field using decrRef() as it is no more needed. 
6548  *  \throw If the MED file is not readable.
6549  *  \throw If there is no mesh named \a mName in the MED file.
6550  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6551  *  \throw If \a this field has not been constructed via file reading.
6552  *  \throw If no field of \a this is lying on the mesh named \a mName.
6553  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6554  *  \sa getFieldAtLevel()
6555  */
6556 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6557 {
6558   if(getFileName2().empty())
6559     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6560   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6561   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6562   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6563   return ret.retn();
6564 }
6565
6566 /*!
6567  * Returns values and a profile of the field of a given type lying on a given support.
6568  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6569  *  \param [in] type - a spatial discretization of the field.
6570  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6571  *  \param [in] mesh - the supporting mesh.
6572  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6573  *          field of interest lies on. If the field lies on all entities of the given
6574  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6575  *          using decrRef() as it is no more needed.  
6576  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6577  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6578  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6579  *  \throw If no field of \a this is lying on \a mesh.
6580  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6581  */
6582 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6583 {
6584   MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6585   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6586 }
6587
6588 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6589 {
6590   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6591   if(!pt)
6592     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6593   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6594   if(!ret)
6595     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 !");
6596   return ret;
6597 }
6598
6599 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6600 {
6601   return contentNotNull()->getUndergroundDataArrayInt();
6602 }
6603
6604 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6605
6606 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6607 {
6608 }
6609
6610 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6611 {
6612 }
6613
6614 /*!
6615  * \param [in] fieldId field id in C mode
6616  */
6617 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6618 {
6619   med_field_type typcha;
6620   std::string dtunitOut;
6621   int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6622   setDtUnit(dtunitOut.c_str());
6623   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6624 }
6625
6626 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
6627 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6628 {
6629   setDtUnit(dtunit.c_str());
6630   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6631 }
6632 catch(INTERP_KERNEL::Exception& e)
6633 {
6634   throw e;
6635 }
6636
6637 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6638 {
6639   std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6640   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6641     ret+=(*it).capacity();
6642   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6643     if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6644       ret+=(*it)->getHeapMemorySize();
6645   return ret;
6646 }
6647
6648 /*!
6649  * 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
6650  * NULL.
6651  */
6652 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6653 {
6654   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6655   ret->setInfo(_infos);
6656   int sz=(int)_time_steps.size();
6657   for(const int *id=startIds;id!=endIds;id++)
6658     {
6659       if(*id>=0 && *id<sz)
6660         {
6661           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6662           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6663           if(tse)
6664             {
6665               tse->incrRef();
6666               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6667             }
6668           ret->pushBackTimeStep(tse2);
6669         }
6670       else
6671         {
6672           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6673           oss << " ! Should be in [0," << sz << ") !";
6674           throw INTERP_KERNEL::Exception(oss.str().c_str());
6675         }
6676     }
6677   if(ret->getNumberOfTS()>0)
6678     ret->synchronizeNameScope();
6679   ret->copyNameScope(*this);
6680   return ret.retn();
6681 }
6682
6683 /*!
6684  * 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
6685  * NULL.
6686  */
6687 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6688 {
6689   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6690   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6691   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6692   ret->setInfo(_infos);
6693   int sz=(int)_time_steps.size();
6694   int j=bg;
6695   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6696     {
6697       if(j>=0 && j<sz)
6698         {
6699           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6700           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6701           if(tse)
6702             {
6703               tse->incrRef();
6704               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6705             }
6706           ret->pushBackTimeStep(tse2);
6707         }
6708       else
6709         {
6710           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6711           oss << " ! Should be in [0," << sz << ") !";
6712           throw INTERP_KERNEL::Exception(oss.str().c_str());
6713         }
6714     }
6715   if(ret->getNumberOfTS()>0)
6716     ret->synchronizeNameScope();
6717   ret->copyNameScope(*this);
6718   return ret.retn();
6719 }
6720
6721 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6722 {
6723   int id=0;
6724   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6725   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6726     {
6727       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6728       if(!cur)
6729         continue;
6730       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6731       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6732         ids->pushBackSilent(id);
6733     }
6734   return buildFromTimeStepIds(ids->begin(),ids->end());
6735 }
6736
6737 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6738 {
6739   int id=0;
6740   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6741   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6742     {
6743       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6744       if(!cur)
6745         continue;
6746       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6747       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6748         ids->pushBackSilent(id);
6749     }
6750   return buildFromTimeStepIds(ids->begin(),ids->end());
6751 }
6752
6753 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6754 {
6755   return _infos;
6756 }
6757
6758 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6759 {
6760   _infos=info;
6761 }
6762
6763 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6764 {
6765   int ret=0;
6766   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6767     {
6768       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6769       if(pt->isDealingTS(iteration,order))
6770         return ret;
6771     }
6772   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6773   std::vector< std::pair<int,int> > vp=getIterations();
6774   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6775     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6776   throw INTERP_KERNEL::Exception(oss.str().c_str());
6777 }
6778
6779 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6780 {
6781   return *_time_steps[getTimeStepPos(iteration,order)];
6782 }
6783
6784 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6785 {
6786   return *_time_steps[getTimeStepPos(iteration,order)];
6787 }
6788
6789 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6790 {
6791   if(_time_steps.empty())
6792     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6793   return _time_steps[0]->getMeshName();
6794 }
6795
6796 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6797 {
6798   std::string oldName(getMeshName());
6799   std::vector< std::pair<std::string,std::string> > v(1);
6800   v[0].first=oldName; v[0].second=newMeshName;
6801   changeMeshNames(v);
6802 }
6803
6804 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6805 {
6806   bool ret=false;
6807   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6808     {
6809       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6810       if(cur)
6811         ret=cur->changeMeshNames(modifTab) || ret;
6812     }
6813   return ret;
6814 }
6815
6816 /*!
6817  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6818  */
6819 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6820 {
6821   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6822 }
6823
6824 /*!
6825  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6826  */
6827 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6828 {
6829   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6830 }
6831
6832 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6833                                                                 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6834 {
6835   bool ret=false;
6836   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6837     {
6838       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6839       if(f1ts)
6840         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6841     }
6842   return ret;
6843 }
6844
6845 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6846 {
6847   std::string startLine(bkOffset,' ');
6848   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6849   if(fmtsId>=0)
6850     oss << " (" << fmtsId << ")";
6851   oss << " has the following name: \"" << _name << "\"." << std::endl;
6852   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6853   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6854     {
6855       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
6856     }
6857   int i=0;
6858   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6859     {
6860       std::string chapter(17,'0'+i);
6861       oss << startLine << chapter << std::endl;
6862       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6863       if(cur)
6864         cur->simpleRepr(bkOffset+2,oss,i);
6865       else
6866         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
6867       oss << startLine << chapter << std::endl;
6868     }
6869 }
6870
6871 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6872 {
6873   std::size_t sz=_time_steps.size();
6874   std::vector< std::pair<int,int> > ret(sz);
6875   ret1.resize(sz);
6876   for(std::size_t i=0;i<sz;i++)
6877     {
6878       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6879       if(f1ts)
6880         {
6881           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6882         }
6883       else
6884         {
6885           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6886           throw INTERP_KERNEL::Exception(oss.str().c_str());
6887         }
6888     }
6889   return ret;
6890 }
6891
6892 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6893 {
6894   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6895   if(!tse2)
6896     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6897   checkCoherencyOfType(tse2);
6898   if(_time_steps.empty())
6899     {
6900       setName(tse2->getName().c_str());
6901       setInfo(tse2->getInfo());
6902     }
6903   checkThatComponentsMatch(tse2->getInfo());
6904   _time_steps.push_back(tse);
6905 }
6906
6907 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6908 {
6909   std::size_t nbOfCompo=_infos.size();
6910   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6911     {
6912       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6913       if(cur)
6914         {
6915           if((cur->getInfo()).size()!=nbOfCompo)
6916             {
6917               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6918               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6919               throw INTERP_KERNEL::Exception(oss.str().c_str());
6920             }
6921           cur->copyNameScope(*this);
6922         }
6923     }
6924 }
6925
6926 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6927 {
6928   _time_steps.resize(nbPdt);
6929   for(int i=0;i<nbPdt;i++)
6930     {
6931       std::vector< std::pair<int,int> > ts;
6932       med_int numdt=0,numo=0;
6933       med_int meshIt=0,meshOrder=0;
6934       med_float dt=0.0;
6935       MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6936       switch(fieldTyp)
6937         {
6938         case MED_FLOAT64:
6939           {
6940             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6941             break;
6942           }
6943         case MED_INT32:
6944           {
6945             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6946             break;
6947           }
6948         default:
6949           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6950         }
6951       if(loadAll)
6952         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6953       else
6954         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6955     }
6956 }
6957
6958 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6959 {
6960   if(_time_steps.empty())
6961     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6962   checkThatNbOfCompoOfTSMatchThis();
6963   std::vector<std::string> infos(getInfo());
6964   int nbComp=infos.size();
6965   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6966   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6967   for(int i=0;i<nbComp;i++)
6968     {
6969       std::string info=infos[i];
6970       std::string c,u;
6971       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6972       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6973       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6974     }
6975   if(_name.empty())
6976     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6977   MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6978   int nbOfTS=_time_steps.size();
6979   for(int i=0;i<nbOfTS;i++)
6980     _time_steps[i]->writeLL(fid,opts,*this);
6981 }
6982
6983 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
6984 {
6985   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6986     {
6987       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6988       if(elt)
6989         elt->loadBigArraysRecursively(fid,nasc);
6990     }
6991 }
6992   
6993 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
6994 {
6995   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6996     {
6997       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6998       if(elt)
6999         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7000     }
7001 }
7002
7003 void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
7004 {
7005   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7006     {
7007       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7008       if(elt)
7009         elt->releaseArrays();
7010     }
7011 }
7012
7013 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7014 {
7015   return _time_steps.size();
7016 }
7017
7018 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7019 {
7020   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7021   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7022     {
7023       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7024       if(tmp)
7025         newTS.push_back(*it);
7026     }
7027   _time_steps=newTS;
7028 }
7029
7030 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7031 {
7032   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7033   int maxId=(int)_time_steps.size();
7034   int ii=0;
7035   std::set<int> idsToDel;
7036   for(const int *id=startIds;id!=endIds;id++,ii++)
7037     {
7038       if(*id>=0 && *id<maxId)
7039         {
7040           idsToDel.insert(*id);
7041         }
7042       else
7043         {
7044           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7045           throw INTERP_KERNEL::Exception(oss.str().c_str());
7046         }
7047     }
7048   for(int iii=0;iii<maxId;iii++)
7049     if(idsToDel.find(iii)==idsToDel.end())
7050       newTS.push_back(_time_steps[iii]);
7051   _time_steps=newTS;
7052 }
7053
7054 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7055 {
7056   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7057   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7058   if(nbOfEntriesToKill==0)
7059     return ;
7060   std::size_t sz=_time_steps.size();
7061   std::vector<bool> b(sz,true);
7062   int j=bg;
7063   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7064     b[j]=false;
7065   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7066   for(std::size_t i=0;i<sz;i++)
7067     if(b[i])
7068       newTS.push_back(_time_steps[i]);
7069   _time_steps=newTS;
7070 }
7071
7072 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7073 {
7074   int ret=0;
7075   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7076   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7077     {
7078       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7079       if(tmp)
7080         {
7081           int it2,ord;
7082           tmp->getTime(it2,ord);
7083           if(it2==iteration && order==ord)
7084             return ret;
7085           else
7086             oss << "(" << it2 << ","  << ord << "), ";
7087         }
7088     }
7089   throw INTERP_KERNEL::Exception(oss.str().c_str());
7090 }
7091
7092 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7093 {
7094   int ret=0;
7095   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7096   oss.precision(15);
7097   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7098     {
7099       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7100       if(tmp)
7101         {
7102           int it2,ord;
7103           double ti=tmp->getTime(it2,ord);
7104           if(fabs(time-ti)<eps)
7105             return ret;
7106           else
7107             oss << ti << ", ";
7108         }
7109     }
7110   throw INTERP_KERNEL::Exception(oss.str().c_str());
7111 }
7112
7113 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7114 {
7115   int lgth=_time_steps.size();
7116   std::vector< std::pair<int,int> > ret(lgth);
7117   for(int i=0;i<lgth;i++)
7118     _time_steps[i]->fillIteration(ret[i]);
7119   return ret;
7120 }
7121
7122 /*!
7123  * 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'
7124  * This method returns two things.
7125  * - The absolute dimension of 'this' in first parameter. 
7126  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7127  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7128  *
7129  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7130  * Only these 3 discretizations will be taken into account here.
7131  *
7132  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7133  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7134  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7135  *
7136  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7137  * 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'.
7138  * 
7139  * Let's consider the typical following case :
7140  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7141  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7142  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7143  *   TETRA4 and SEG2
7144  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7145  *
7146  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7147  * 
7148  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7149  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7150  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7151  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7152  */
7153 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7154 {
7155   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7156 }
7157
7158 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7159 {
7160   if(pos<0 || pos>=(int)_time_steps.size())
7161     {
7162       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7163       throw INTERP_KERNEL::Exception(oss.str().c_str());
7164     }
7165   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7166   if(item==0)
7167     {
7168       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7169       oss << "\nTry to use following method eraseEmptyTS !";
7170       throw INTERP_KERNEL::Exception(oss.str().c_str());
7171     }
7172   return item;
7173 }
7174
7175 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7176 {
7177   if(pos<0 || pos>=(int)_time_steps.size())
7178     {
7179       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7180       throw INTERP_KERNEL::Exception(oss.str().c_str());
7181     }
7182   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7183   if(item==0)
7184     {
7185       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7186       oss << "\nTry to use following method eraseEmptyTS !";
7187       throw INTERP_KERNEL::Exception(oss.str().c_str());
7188     }
7189   return item;
7190 }
7191
7192 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7193 {
7194   std::vector<std::string> ret;
7195   std::set<std::string> ret2;
7196   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7197     {
7198       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7199       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7200         if(ret2.find(*it2)==ret2.end())
7201           {
7202             ret.push_back(*it2);
7203             ret2.insert(*it2);
7204           }
7205     }
7206   return ret;
7207 }
7208
7209 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7210 {
7211   std::vector<std::string> ret;
7212   std::set<std::string> ret2;
7213   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7214     {
7215       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7216       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7217         if(ret2.find(*it2)==ret2.end())
7218           {
7219             ret.push_back(*it2);
7220             ret2.insert(*it2);
7221           }
7222     }
7223   return ret;
7224 }
7225
7226 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7227 {
7228   std::vector<std::string> ret;
7229   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7230     {
7231       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7232       ret.insert(ret.end(),tmp.begin(),tmp.end());
7233     }
7234   return ret;
7235 }
7236
7237 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7238 {
7239   std::vector<std::string> ret;
7240   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7241     {
7242       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7243       ret.insert(ret.end(),tmp.begin(),tmp.end());
7244     }
7245   return ret;
7246 }
7247
7248 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7249 {
7250   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7251     (*it)->changePflsRefsNamesGen2(mapOfModif);
7252 }
7253
7254 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7255 {
7256   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7257     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7258 }
7259
7260 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7261 {
7262   int lgth=_time_steps.size();
7263   std::vector< std::vector<TypeOfField> > ret(lgth);
7264   for(int i=0;i<lgth;i++)
7265     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7266   return ret;
7267 }
7268
7269 /*!
7270  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7271  */
7272 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7273 {
7274   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7275 }
7276
7277 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7278 {
7279   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7280   std::size_t i=0;
7281   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7282     {
7283       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7284         ret->_time_steps[i]=(*it)->deepCpy();
7285     }
7286   return ret.retn();
7287 }
7288
7289 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7290 {
7291   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7292   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7293   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7294   for(std::size_t i=0;i<sz;i++)
7295     {
7296       ret[i]=shallowCpy();
7297       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7298     }
7299   for(std::size_t i=0;i<sz2;i++)
7300     {
7301       std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7302       if(ret1.size()!=sz)
7303         {
7304           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7305           throw INTERP_KERNEL::Exception(oss.str().c_str());
7306         }
7307       ts[i]=ret1;
7308     }
7309   for(std::size_t i=0;i<sz;i++)
7310     for(std::size_t j=0;j<sz2;j++)
7311       ret[i]->_time_steps[j]=ts[j][i];
7312   return ret;
7313 }
7314
7315 /*!
7316  * This method splits into discretization each time steps in \a this.
7317  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7318  */
7319 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7320 {
7321   std::size_t sz(_time_steps.size());
7322   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7323   for(std::size_t i=0;i<sz;i++)
7324     {
7325       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7326       if(!timeStep)
7327         {
7328           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7329           throw INTERP_KERNEL::Exception(oss.str().c_str());
7330         }
7331       items[i]=timeStep->splitDiscretizations();  
7332     }
7333   //
7334   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7335   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7336   std::vector< TypeOfField > types;
7337   for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7338     for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7339       {
7340         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7341         if(ts.size()!=1)
7342           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7343         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7344         if(it2==types.end())
7345           types.push_back(ts[0]);
7346       }
7347   ret.resize(types.size()); ret2.resize(types.size());
7348   for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7349     for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7350       {
7351         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7352         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7353         ret2[pos].push_back(*it1);
7354       }
7355   for(std::size_t i=0;i<types.size();i++)
7356     {
7357       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7358       for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7359         elt->pushBackTimeStep(*it1);//also updates infos in elt
7360       ret[i]=elt;
7361       elt->MEDFileFieldNameScope::operator=(*this);
7362     }
7363   return ret;
7364 }
7365
7366 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7367 {
7368   _name=field->getName();
7369   if(_name.empty())
7370     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7371   if(!arr)
7372     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7373   _infos=arr->getInfoOnComponents();
7374 }
7375
7376 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7377 {
7378   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7379   if(_name!=field->getName())
7380     {
7381       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7382       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7383       throw INTERP_KERNEL::Exception(oss.str().c_str());
7384     }
7385   if(!arr)
7386     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7387   checkThatComponentsMatch(arr->getInfoOnComponents());
7388 }
7389
7390 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7391 {
7392   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7393   if(getInfo().size()!=compos.size())
7394     {
7395       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7396       oss << " number of components of element to append (" << compos.size() << ") !";
7397       throw INTERP_KERNEL::Exception(oss.str().c_str());
7398     }
7399   if(_infos!=compos)
7400     {
7401       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7402       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7403       oss << " But compo in input fields are : ";
7404       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7405       oss << " !";
7406       throw INTERP_KERNEL::Exception(oss.str().c_str());
7407     }
7408 }
7409
7410 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7411 {
7412   std::size_t sz=_infos.size();
7413   int j=0;
7414   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7415     {
7416       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7417       if(elt)
7418         if(elt->getInfo().size()!=sz)
7419           {
7420             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7421             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7422             throw INTERP_KERNEL::Exception(oss.str().c_str());
7423           }
7424     }
7425 }
7426
7427 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7428 {
7429   if(!field)
7430     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7431   if(!_time_steps.empty())
7432     checkCoherencyOfTinyInfo(field,arr);
7433   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7434   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7435   objC->setFieldNoProfileSBT(field,arr,glob,*this);
7436   copyTinyInfoFrom(field,arr);
7437   _time_steps.push_back(obj);
7438 }
7439
7440 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7441 {
7442   if(!field)
7443     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7444   if(!_time_steps.empty())
7445     checkCoherencyOfTinyInfo(field,arr);
7446   MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7447   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7448   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7449   copyTinyInfoFrom(field,arr);
7450   _time_steps.push_back(obj);
7451 }
7452
7453 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7454 {
7455   int sz=(int)_time_steps.size();
7456   if(i<0 || i>=sz)
7457     {
7458       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7459       throw INTERP_KERNEL::Exception(oss.str().c_str());
7460     }
7461   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7462   if(tsPtr)
7463     {
7464       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7465         {
7466           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
7467           throw INTERP_KERNEL::Exception(oss.str().c_str());
7468         }
7469     }
7470   _time_steps[i]=ts;
7471 }
7472
7473 //= MEDFileFieldMultiTSWithoutSDA
7474
7475 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7476 {
7477   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7478 }
7479
7480 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7481 {
7482 }
7483
7484 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7485 {
7486 }
7487
7488 /*!
7489  * \param [in] fieldId field id in C mode
7490  */
7491 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7492 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7493 {
7494 }
7495 catch(INTERP_KERNEL::Exception& e)
7496   { throw e; }
7497
7498 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7499 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7500 {
7501 }
7502 catch(INTERP_KERNEL::Exception& e)
7503 { throw e; }
7504
7505 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7506 {
7507   return new MEDFileField1TSWithoutSDA;
7508 }
7509
7510 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7511 {
7512   if(!f1ts)
7513     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7514   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7515   if(!f1tsC)
7516     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7517 }
7518
7519 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7520 {
7521   return MEDFileField1TSWithoutSDA::TYPE_STR;
7522 }
7523
7524 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7525 {
7526   return new MEDFileFieldMultiTSWithoutSDA(*this);
7527 }
7528
7529 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7530 {
7531   return new MEDFileFieldMultiTSWithoutSDA;
7532 }
7533
7534 /*!
7535  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7536  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7537  */
7538 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7539 {
7540   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7541   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7542   if(!myF1TSC)
7543     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7544   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7545 }
7546
7547 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7548 {
7549   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7550   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7551   int i=0;
7552   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7553     {
7554       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7555       if(eltToConv)
7556         {
7557           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7558           if(!eltToConvC)
7559             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7560           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7561           ret->setIteration(i,elt);
7562         }
7563     }
7564   return ret.retn();
7565 }
7566
7567 //= MEDFileAnyTypeFieldMultiTS
7568
7569 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7570 {
7571 }
7572
7573 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7574 try:MEDFileFieldGlobsReal(fileName)
7575 {
7576   MEDFileUtilities::CheckFileForRead(fileName);
7577   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7578   _content=BuildContentFrom(fid,fileName,loadAll);
7579   loadGlobals(fid);
7580 }
7581 catch(INTERP_KERNEL::Exception& e)
7582   {
7583     throw e;
7584   }
7585
7586 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7587 {
7588   med_field_type typcha;
7589   std::vector<std::string> infos;
7590   std::string dtunit;
7591   int i=-1;
7592   MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7593   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7594   switch(typcha)
7595     {
7596     case MED_FLOAT64:
7597       {
7598         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7599         break;
7600       }
7601     case MED_INT32:
7602       {
7603         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7604         break;
7605       }
7606     default:
7607       {
7608         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] !";
7609         throw INTERP_KERNEL::Exception(oss.str().c_str());
7610       }
7611     }
7612   ret->setDtUnit(dtunit.c_str());
7613   return ret.retn();
7614 }
7615
7616 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7617 {
7618   med_field_type typcha;
7619   //
7620   std::vector<std::string> infos;
7621   std::string dtunit,fieldName;
7622   MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7623   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7624   switch(typcha)
7625     {
7626     case MED_FLOAT64:
7627       {
7628         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7629         break;
7630       }
7631     case MED_INT32:
7632       {
7633         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7634         break;
7635       }
7636     default:
7637       {
7638         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] !";
7639         throw INTERP_KERNEL::Exception(oss.str().c_str());
7640       }
7641     }
7642   ret->setDtUnit(dtunit.c_str());
7643   return ret.retn();
7644 }
7645
7646 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7647 {
7648   if(!c)
7649     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7650   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7651     {
7652       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7653       ret->setFileName(fileName);
7654       ret->_content=c;  c->incrRef();
7655       return ret.retn();
7656     }
7657   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7658     {
7659       MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7660       ret->setFileName(fileName);
7661       ret->_content=c;  c->incrRef();
7662       return ret.retn();
7663     }
7664   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7665 }
7666
7667 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7668 try:MEDFileFieldGlobsReal(fileName)
7669 {
7670   MEDFileUtilities::CheckFileForRead(fileName);
7671   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7672   _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7673   loadGlobals(fid);
7674 }
7675 catch(INTERP_KERNEL::Exception& e)
7676   {
7677     throw e;
7678   }
7679
7680 //= MEDFileIntFieldMultiTSWithoutSDA
7681
7682 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7683 {
7684   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7685 }
7686
7687 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7688 {
7689 }
7690
7691 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7692 {
7693 }
7694
7695 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7696 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7697 {
7698 }
7699 catch(INTERP_KERNEL::Exception& e)
7700 { throw e; }
7701
7702 /*!
7703  * \param [in] fieldId field id in C mode
7704  */
7705 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7706 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7707 {
7708 }
7709 catch(INTERP_KERNEL::Exception& e)
7710   { throw e; }
7711
7712 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7713 {
7714   return new MEDFileIntField1TSWithoutSDA;
7715 }
7716
7717 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7718 {
7719   if(!f1ts)
7720     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7721   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7722   if(!f1tsC)
7723     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7724 }
7725
7726 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7727 {
7728   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7729 }
7730
7731 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7732 {
7733   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7734 }
7735
7736 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7737 {
7738   return new MEDFileIntFieldMultiTSWithoutSDA;
7739 }
7740
7741 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7742 {
7743   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7744   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7745   int i=0;
7746   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7747     {
7748       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7749       if(eltToConv)
7750         {
7751           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7752           if(!eltToConvC)
7753             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7754           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7755           ret->setIteration(i,elt);
7756         }
7757     }
7758   return ret.retn();
7759 }
7760
7761 //= MEDFileAnyTypeFieldMultiTS
7762
7763 /*!
7764  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7765  * that has been read from a specified MED file.
7766  *  \param [in] fileName - the name of the MED file to read.
7767  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7768  *          is to delete this field using decrRef() as it is no more needed.
7769  *  \throw If reading the file fails.
7770  */
7771 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7772 {
7773   MEDFileUtilities::CheckFileForRead(fileName);
7774   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7775   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7776   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7777   ret->loadGlobals(fid);
7778   return ret.retn();
7779 }
7780
7781 /*!
7782  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7783  * that has been read from a specified MED file.
7784  *  \param [in] fileName - the name of the MED file to read.
7785  *  \param [in] fieldName - the name of the field to read.
7786  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7787  *          is to delete this field using decrRef() as it is no more needed.
7788  *  \throw If reading the file fails.
7789  *  \throw If there is no field named \a fieldName in the file.
7790  */
7791 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7792 {
7793   MEDFileUtilities::CheckFileForRead(fileName);
7794   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7795   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7796   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7797   ret->loadGlobals(fid);
7798   return ret.retn();
7799 }
7800
7801 /*!
7802  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7803  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7804  *
7805  * \warning this is a shallow copy constructor
7806  */
7807 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7808 {
7809   if(!shallowCopyOfContent)
7810     {
7811       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7812       otherPtr->incrRef();
7813       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7814     }
7815   else
7816     {
7817       _content=other.shallowCpy();
7818     }
7819 }
7820
7821 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7822 {
7823   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7824   if(!ret)
7825     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7826   return ret;
7827 }
7828
7829 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7830 {
7831   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7832   if(!ret)
7833     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7834   return ret;
7835 }
7836
7837 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7838 {
7839   return contentNotNullBase()->getPflsReallyUsed2();
7840 }
7841
7842 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7843 {
7844   return contentNotNullBase()->getLocsReallyUsed2();
7845 }
7846
7847 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7848 {
7849   return contentNotNullBase()->getPflsReallyUsedMulti2();
7850 }
7851
7852 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7853 {
7854   return contentNotNullBase()->getLocsReallyUsedMulti2();
7855 }
7856
7857 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7858 {
7859   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7860 }
7861
7862 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7863 {
7864   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7865 }
7866
7867 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7868 {
7869   return contentNotNullBase()->getNumberOfTS();
7870 }
7871
7872 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7873 {
7874   contentNotNullBase()->eraseEmptyTS();
7875 }
7876
7877 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7878 {
7879   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7880 }
7881
7882 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7883 {
7884   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7885 }
7886
7887 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7888 {
7889   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7890   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7891   ret->_content=c;
7892   return ret.retn();
7893 }
7894
7895 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7896 {
7897   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7898   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7899   ret->_content=c;
7900   return ret.retn();
7901 }
7902
7903 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7904 {
7905   return contentNotNullBase()->getIterations();
7906 }
7907
7908 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7909 {
7910   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7911     pushBackTimeStep(*it);
7912 }
7913
7914 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7915 {
7916   if(!f1ts)
7917     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7918   checkCoherencyOfType(f1ts);
7919   f1ts->incrRef();
7920   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7921   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7922   c->incrRef();
7923   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7924   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7925     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7926   _content->pushBackTimeStep(cSafe);
7927   appendGlobs(*f1ts,1e-12);
7928 }
7929
7930 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7931 {
7932   contentNotNullBase()->synchronizeNameScope();
7933 }
7934
7935 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7936 {
7937   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7938 }
7939
7940 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7941 {
7942   return contentNotNullBase()->getPosGivenTime(time,eps);
7943 }
7944
7945 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7946 {
7947   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7948 }
7949
7950 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7951 {
7952   return contentNotNullBase()->getTypesOfFieldAvailable();
7953 }
7954
7955 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7956 {
7957   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7958 }
7959
7960 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7961 {
7962   return contentNotNullBase()->getName();
7963 }
7964
7965 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7966 {
7967   contentNotNullBase()->setName(name);
7968 }
7969
7970 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7971 {
7972   return contentNotNullBase()->getDtUnit();
7973 }
7974
7975 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7976 {
7977   contentNotNullBase()->setDtUnit(dtUnit);
7978 }
7979
7980 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7981 {
7982   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7983 }
7984
7985 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7986 {
7987   return contentNotNullBase()->getTimeSteps(ret1);
7988 }
7989
7990 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7991 {
7992   return contentNotNullBase()->getMeshName();
7993 }
7994
7995 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7996 {
7997   contentNotNullBase()->setMeshName(newMeshName);
7998 }
7999
8000 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8001 {
8002   return contentNotNullBase()->changeMeshNames(modifTab);
8003 }
8004
8005 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8006 {
8007   return contentNotNullBase()->getInfo();
8008 }
8009
8010 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8011 {
8012   return contentNotNullBase()->setInfo(info);
8013 }
8014
8015 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8016 {
8017   const std::vector<std::string> ret=getInfo();
8018   return (int)ret.size();
8019 }
8020
8021 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8022 {
8023   writeGlobals(fid,*this);
8024   contentNotNullBase()->writeLL(fid,*this);
8025 }
8026
8027 /*!
8028  * Writes \a this field into a MED file specified by its name.
8029  *  \param [in] fileName - the MED file name.
8030  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8031  * - 2 - erase; an existing file is removed.
8032  * - 1 - append; same data should not be present in an existing file.
8033  * - 0 - overwrite; same data present in an existing file is overwritten.
8034  *  \throw If the field name is not set.
8035  *  \throw If no field data is set.
8036  *  \throw If \a mode == 1 and the same data is present in an existing file.
8037  */
8038 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8039 {
8040   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8041   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8042   writeLL(fid);
8043 }
8044
8045 /*!
8046  * This method alloc the arrays and load potentially huge arrays contained in this field.
8047  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8048  * This method can be also called to refresh or reinit values from a file.
8049  * 
8050  * \throw If the fileName is not set or points to a non readable MED file.
8051  */
8052 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8053 {
8054   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8055   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8056 }
8057
8058 /*!
8059  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8060  * But once data loaded once, this method does nothing.
8061  * 
8062  * \throw If the fileName is not set or points to a non readable MED file.
8063  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays
8064  */
8065 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8066 {
8067   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8068   contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8069 }
8070
8071 /*!
8072  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8073  * This method does not release arrays set outside the context of a MED file.
8074  * 
8075  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8076  */
8077 void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception)
8078 {
8079   contentNotNullBase()->releaseArrays();
8080 }
8081
8082 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8083 {
8084   std::ostringstream oss;
8085   contentNotNullBase()->simpleRepr(0,oss,-1);
8086   simpleReprGlobs(oss);
8087   return oss.str();
8088 }
8089
8090 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8091 {
8092   std::size_t ret=0;
8093   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8094     ret+=_content->getHeapMemorySize();
8095   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8096 }
8097
8098 /*!
8099  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8100  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8101  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8102  */
8103 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8104 {
8105   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8106   if(!content)
8107     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8108   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8109   std::size_t sz(contentsSplit.size());
8110   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8111   for(std::size_t i=0;i<sz;i++)
8112     {
8113       ret[i]=shallowCpy();
8114       ret[i]->_content=contentsSplit[i];
8115     }
8116   return ret;
8117 }
8118
8119 /*!
8120  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8121  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8122  */
8123 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8124 {
8125   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8126   if(!content)
8127     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8128   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8129   std::size_t sz(contentsSplit.size());
8130   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8131   for(std::size_t i=0;i<sz;i++)
8132     {
8133       ret[i]=shallowCpy();
8134       ret[i]->_content=contentsSplit[i];
8135     }
8136   return ret;
8137 }
8138
8139 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8140 {
8141   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8142   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8143     ret->_content=_content->deepCpy();
8144   ret->deepCpyGlobs(*this);
8145   return ret.retn();
8146 }
8147
8148 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8149 {
8150   return _content;
8151 }
8152
8153 /*!
8154  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8155  *  \param [in] iteration - the iteration number of a required time step.
8156  *  \param [in] order - the iteration order number of required time step.
8157  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8158  *          delete this field using decrRef() as it is no more needed.
8159  *  \throw If there is no required time step in \a this field.
8160  */
8161 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8162 {
8163   int pos=getPosOfTimeStep(iteration,order);
8164   return getTimeStepAtPos(pos);
8165 }
8166
8167 /*!
8168  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8169  *  \param [in] time - the time of the time step of interest.
8170  *  \param [in] eps - a precision used to compare time values.
8171  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8172  *          delete this field using decrRef() as it is no more needed.
8173  *  \throw If there is no required time step in \a this field.
8174  */
8175 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8176 {
8177   int pos=getPosGivenTime(time,eps);
8178   return getTimeStepAtPos(pos);
8179 }
8180
8181 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8182 {
8183   return new MEDFileAnyTypeFieldMultiTSIterator(this);
8184 }
8185
8186 //= MEDFileFieldMultiTS
8187
8188 /*!
8189  * Returns a new empty instance of MEDFileFieldMultiTS.
8190  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8191  *          is to delete this field using decrRef() as it is no more needed.
8192  */
8193 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8194 {
8195   return new MEDFileFieldMultiTS;
8196 }
8197
8198 /*!
8199  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8200  * that has been read from a specified MED file.
8201  *  \param [in] fileName - the name of the MED file to read.
8202  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8203  *          is to delete this field using decrRef() as it is no more needed.
8204  *  \throw If reading the file fails.
8205  */
8206 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8207 {
8208   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8209   ret->contentNotNull();//to check that content type matches with \a this type.
8210   return ret.retn();
8211 }
8212
8213 /*!
8214  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8215  * that has been read from a specified MED file.
8216  *  \param [in] fileName - the name of the MED file to read.
8217  *  \param [in] fieldName - the name of the field to read.
8218  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8219  *          is to delete this field using decrRef() as it is no more needed.
8220  *  \throw If reading the file fails.
8221  *  \throw If there is no field named \a fieldName in the file.
8222  */
8223 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8224 {
8225   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8226   ret->contentNotNull();//to check that content type matches with \a this type.
8227   return ret.retn();
8228 }
8229
8230 /*!
8231  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8232  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8233  *
8234  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8235  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8236  * \warning this is a shallow copy constructor
8237  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8238  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8239  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8240  *          is to delete this field using decrRef() as it is no more needed.
8241  */
8242 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8243 {
8244   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8245 }
8246
8247 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8248 {
8249   return new MEDFileFieldMultiTS(*this);
8250 }
8251
8252 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8253 {
8254   if(!f1ts)
8255     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8256   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8257   if(!f1tsC)
8258     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8259 }
8260
8261 /*!
8262  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8263  * following the given input policy.
8264  *
8265  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8266  *                            By default (true) the globals are deeply copied.
8267  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8268  */
8269 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8270 {
8271   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8272   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8273   if(content)
8274     {
8275       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8276       if(!contc)
8277         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8278       MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8279       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8280     }
8281   else
8282     ret=MEDFileIntFieldMultiTS::New();
8283   if(deepCpyGlobs)
8284     ret->deepCpyGlobs(*this);
8285   else
8286     ret->shallowCpyGlobs(*this);
8287   return ret.retn();
8288 }
8289
8290 /*!
8291  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8292  *  \param [in] pos - a time step id.
8293  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8294  *          delete this field using decrRef() as it is no more needed.
8295  *  \throw If \a pos is not a valid time step id.
8296  */
8297 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8298 {
8299   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8300   if(!item)
8301     {
8302       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8303       throw INTERP_KERNEL::Exception(oss.str().c_str());
8304     }
8305   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8306   if(itemC)
8307     {
8308       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8309       ret->shallowCpyGlobs(*this);
8310       return ret.retn();
8311     }
8312   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8313   throw INTERP_KERNEL::Exception(oss.str().c_str());
8314 }
8315
8316 /*!
8317  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8318  * mesh entities of a given dimension of the first mesh in MED file.
8319  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8320  *  \param [in] type - a spatial discretization of interest.
8321  *  \param [in] iteration - the iteration number of a required time step.
8322  *  \param [in] order - the iteration order number of required time step.
8323  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8324  *  \param [in] renumPol - specifies how to permute values of the result field according to
8325  *          the optional numbers of cells and nodes, if any. The valid values are
8326  *          - 0 - do not permute.
8327  *          - 1 - permute cells.
8328  *          - 2 - permute nodes.
8329  *          - 3 - permute cells and nodes.
8330  *
8331  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8332  *          caller is to delete this field using decrRef() as it is no more needed. 
8333  *  \throw If the MED file is not readable.
8334  *  \throw If there is no mesh in the MED file.
8335  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8336  *  \throw If no field values of the required parameters are available.
8337  */
8338 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8339 {
8340   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8341   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8342   if(!myF1TSC)
8343     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8344   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8345   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8346   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8347   return ret.retn();
8348 }
8349
8350 /*!
8351  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8352  * the top level cells of the first mesh in MED file.
8353  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8354  *  \param [in] type - a spatial discretization of interest.
8355  *  \param [in] iteration - the iteration number of a required time step.
8356  *  \param [in] order - the iteration order number of required time step.
8357  *  \param [in] renumPol - specifies how to permute values of the result field according to
8358  *          the optional numbers of cells and nodes, if any. The valid values are
8359  *          - 0 - do not permute.
8360  *          - 1 - permute cells.
8361  *          - 2 - permute nodes.
8362  *          - 3 - permute cells and nodes.
8363  *
8364  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8365  *          caller is to delete this field using decrRef() as it is no more needed. 
8366  *  \throw If the MED file is not readable.
8367  *  \throw If there is no mesh in the MED file.
8368  *  \throw If no field values of the required parameters are available.
8369  */
8370 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8371 {
8372   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8373   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8374   if(!myF1TSC)
8375     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8376   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8377   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8378   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8379   return ret.retn();
8380 }
8381
8382 /*!
8383  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8384  * a given support.
8385  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8386  *  \param [in] type - a spatial discretization of interest.
8387  *  \param [in] iteration - the iteration number of a required time step.
8388  *  \param [in] order - the iteration order number of required time step.
8389  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8390  *  \param [in] mesh - the supporting mesh.
8391  *  \param [in] renumPol - specifies how to permute values of the result field according to
8392  *          the optional numbers of cells and nodes, if any. The valid values are
8393  *          - 0 - do not permute.
8394  *          - 1 - permute cells.
8395  *          - 2 - permute nodes.
8396  *          - 3 - permute cells and nodes.
8397  *
8398  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8399  *          caller is to delete this field using decrRef() as it is no more needed. 
8400  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8401  *  \throw If no field of \a this is lying on \a mesh.
8402  *  \throw If no field values of the required parameters are available.
8403  */
8404 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8405 {
8406   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8407   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8408   if(!myF1TSC)
8409     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8410   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8411   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8412   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8413   return ret.retn();
8414 }
8415
8416 /*!
8417  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8418  * given support. 
8419  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8420  *  \param [in] type - a spatial discretization of the new field.
8421  *  \param [in] iteration - the iteration number of a required time step.
8422  *  \param [in] order - the iteration order number of required time step.
8423  *  \param [in] mesh - the supporting mesh.
8424  *  \param [in] renumPol - specifies how to permute values of the result field according to
8425  *          the optional numbers of cells and nodes, if any. The valid values are
8426  *          - 0 - do not permute.
8427  *          - 1 - permute cells.
8428  *          - 2 - permute nodes.
8429  *          - 3 - permute cells and nodes.
8430  *
8431  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8432  *          caller is to delete this field using decrRef() as it is no more needed. 
8433  *  \throw If no field of \a this is lying on \a mesh.
8434  *  \throw If no field values of the required parameters are available.
8435  */
8436 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8437 {
8438   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8439   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8440   if(!myF1TSC)
8441     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8442   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8443   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8444   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8445   return ret.retn();
8446 }
8447
8448 /*!
8449  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8450  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8451  * This method is useful for MED2 file format when field on different mesh was autorized.
8452  */
8453 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8454 {
8455   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8456   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8457   if(!myF1TSC)
8458     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8459   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8460   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8461   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8462   return ret.retn();
8463 }
8464
8465 /*!
8466  * Returns values and a profile of the field of a given type, of a given time step,
8467  * lying on a given support.
8468  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8469  *  \param [in] type - a spatial discretization of the field.
8470  *  \param [in] iteration - the iteration number of a required time step.
8471  *  \param [in] order - the iteration order number of required time step.
8472  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8473  *  \param [in] mesh - the supporting mesh.
8474  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8475  *          field of interest lies on. If the field lies on all entities of the given
8476  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
8477  *          using decrRef() as it is no more needed.  
8478  *  \param [in] glob - the global data storing profiles and localization.
8479  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8480  *          field. The caller is to delete this array using decrRef() as it is no more needed.
8481  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8482  *  \throw If no field of \a this is lying on \a mesh.
8483  *  \throw If no field values of the required parameters are available.
8484  */
8485 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8486 {
8487   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8488   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8489   if(!myF1TSC)
8490     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8491   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8492   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8493 }
8494
8495 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8496 {
8497   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8498   if(!pt)
8499     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8500   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8501   if(!ret)
8502     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 !");
8503   return ret;
8504 }
8505
8506  MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8507 {
8508   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8509   if(!pt)
8510     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8511   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8512   if(!ret)
8513     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 !");
8514   return ret;
8515 }
8516
8517 /*!
8518  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8519  * the given field is checked if its elements are sorted suitable for writing to MED file
8520  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
8521  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8522  *  \param [in] field - the field to add to \a this.
8523  *  \throw If the name of \a field is empty.
8524  *  \throw If the data array of \a field is not set.
8525  *  \throw If existing time steps have different name or number of components than \a field.
8526  *  \throw If the underlying mesh of \a field has no name.
8527  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8528  */
8529 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8530 {
8531   const DataArrayDouble *arr=0;
8532   if(field)
8533     arr=field->getArray();
8534   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8535 }
8536
8537 /*!
8538  * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8539  * a given dimension of a given mesh are used as the support of the given field.
8540  * Elements of the given mesh must be sorted suitable for writing to MED file. 
8541  * Order of underlying mesh entities of the given field specified by \a profile parameter
8542  * is not prescribed; this method permutes field values to have them sorted by element
8543  * type as required for writing to MED file.  
8544  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8545  *  \param [in] field - the field to add to \a this.
8546  *  \param [in] mesh - the supporting mesh of \a field.
8547  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8548  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
8549  *  \throw If either \a field or \a mesh or \a profile has an empty name.
8550  *  \throw If existing time steps have different name or number of components than \a field.
8551  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8552  *  \throw If the data array of \a field is not set.
8553  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8554  */
8555 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8556 {
8557   const DataArrayDouble *arr=0;
8558   if(field)
8559     arr=field->getArray();
8560   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8561 }
8562
8563 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8564 {
8565   _content=new MEDFileFieldMultiTSWithoutSDA;
8566 }
8567
8568 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8569 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8570 {
8571 }
8572 catch(INTERP_KERNEL::Exception& e)
8573   { throw e; }
8574
8575 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8576 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8577 {
8578 }
8579 catch(INTERP_KERNEL::Exception& e)
8580   { throw e; }
8581
8582 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8583 {
8584 }
8585
8586 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
8587 {
8588   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8589 }
8590
8591 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8592 {
8593   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8594 }
8595
8596 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
8597 {
8598   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8599 }
8600
8601 //= MEDFileAnyTypeFieldMultiTSIterator
8602
8603 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8604 {
8605   if(fmts)
8606     {
8607       fmts->incrRef();
8608       _nb_iter=fmts->getNumberOfTS();
8609     }
8610 }
8611
8612 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
8613 {
8614 }
8615
8616 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8617 {
8618   if(_iter_id<_nb_iter)
8619     {
8620       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8621       if(fmts)
8622         return fmts->getTimeStepAtPos(_iter_id++);
8623       else
8624         return 0;
8625     }
8626   else
8627     return 0;
8628 }
8629
8630 //= MEDFileIntFieldMultiTS
8631
8632 /*!
8633  * Returns a new empty instance of MEDFileFieldMultiTS.
8634  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8635  *          is to delete this field using decrRef() as it is no more needed.
8636  */
8637 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8638 {
8639   return new MEDFileIntFieldMultiTS;
8640 }
8641
8642 /*!
8643  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8644  * that has been read from a specified MED file.
8645  *  \param [in] fileName - the name of the MED file to read.
8646  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8647  *          is to delete this field using decrRef() as it is no more needed.
8648  *  \throw If reading the file fails.
8649  */
8650 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8651 {
8652   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8653   ret->contentNotNull();//to check that content type matches with \a this type.
8654   return ret.retn();
8655 }
8656
8657 /*!
8658  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8659  * that has been read from a specified MED file.
8660  *  \param [in] fileName - the name of the MED file to read.
8661  *  \param [in] fieldName - the name of the field to read.
8662  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8663  *          is to delete this field using decrRef() as it is no more needed.
8664  *  \throw If reading the file fails.
8665  *  \throw If there is no field named \a fieldName in the file.
8666  */
8667 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8668 {
8669   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8670   ret->contentNotNull();//to check that content type matches with \a this type.
8671   return ret.retn();
8672 }
8673
8674 /*!
8675  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8676  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8677  *
8678  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8679  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8680  * \warning this is a shallow copy constructor
8681  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8682  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8683  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8684  *          is to delete this field using decrRef() as it is no more needed.
8685  */
8686 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8687 {
8688   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8689 }
8690
8691 /*!
8692  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8693  * following the given input policy.
8694  *
8695  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8696  *                            By default (true) the globals are deeply copied.
8697  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8698  */
8699 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8700 {
8701   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8702   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8703   if(content)
8704     {
8705       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8706       if(!contc)
8707         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8708       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8709       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8710     }
8711   else
8712     ret=MEDFileFieldMultiTS::New();
8713   if(deepCpyGlobs)
8714     ret->deepCpyGlobs(*this);
8715   else
8716     ret->shallowCpyGlobs(*this);
8717   return ret.retn();
8718 }
8719
8720 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8721 {
8722   return new MEDFileIntFieldMultiTS(*this);
8723 }
8724
8725 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8726 {
8727   if(!f1ts)
8728     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8729   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8730   if(!f1tsC)
8731     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8732 }
8733
8734 /*!
8735  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8736  * mesh entities of a given dimension of the first mesh in MED file.
8737  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8738  *  \param [in] type - a spatial discretization of interest.
8739  *  \param [in] iteration - the iteration number of a required time step.
8740  *  \param [in] order - the iteration order number of required time step.
8741  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8742  *  \param [out] arrOut - the DataArrayInt containing values of field.
8743  *  \param [in] renumPol - specifies how to permute values of the result field according to
8744  *          the optional numbers of cells and nodes, if any. The valid values are
8745  *          - 0 - do not permute.
8746  *          - 1 - permute cells.
8747  *          - 2 - permute nodes.
8748  *          - 3 - permute cells and nodes.
8749  *
8750  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8751  *          caller is to delete this field using decrRef() as it is no more needed. 
8752  *  \throw If the MED file is not readable.
8753  *  \throw If there is no mesh in the MED file.
8754  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8755  *  \throw If no field values of the required parameters are available.
8756  */
8757 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8758 {
8759   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8760   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8761   if(!myF1TSC)
8762     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8763   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8764   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8765   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8766   return ret.retn();
8767 }
8768
8769 /*!
8770  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8771  * the top level cells of the first mesh in MED file.
8772  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8773  *  \param [in] type - a spatial discretization of interest.
8774  *  \param [in] iteration - the iteration number of a required time step.
8775  *  \param [in] order - the iteration order number of required time step.
8776  *  \param [out] arrOut - the DataArrayInt containing values of field.
8777  *  \param [in] renumPol - specifies how to permute values of the result field according to
8778  *          the optional numbers of cells and nodes, if any. The valid values are
8779  *          - 0 - do not permute.
8780  *          - 1 - permute cells.
8781  *          - 2 - permute nodes.
8782  *          - 3 - permute cells and nodes.
8783  *
8784  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8785  *          caller is to delete this field using decrRef() as it is no more needed. 
8786  *  \throw If the MED file is not readable.
8787  *  \throw If there is no mesh in the MED file.
8788  *  \throw If no field values of the required parameters are available.
8789  */
8790 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8791 {
8792   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8793   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8794   if(!myF1TSC)
8795     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8796   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8797   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8798   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8799   return ret.retn();
8800 }
8801
8802 /*!
8803  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8804  * a given support.
8805  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8806  *  \param [in] type - a spatial discretization of interest.
8807  *  \param [in] iteration - the iteration number of a required time step.
8808  *  \param [in] order - the iteration order number of required time step.
8809  *  \param [out] arrOut - the DataArrayInt containing values of field.
8810  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8811  *  \param [in] mesh - the supporting mesh.
8812  *  \param [in] renumPol - specifies how to permute values of the result field according to
8813  *          the optional numbers of cells and nodes, if any. The valid values are
8814  *          - 0 - do not permute.
8815  *          - 1 - permute cells.
8816  *          - 2 - permute nodes.
8817  *          - 3 - permute cells and nodes.
8818  *
8819  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8820  *          caller is to delete this field using decrRef() as it is no more needed. 
8821  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8822  *  \throw If no field of \a this is lying on \a mesh.
8823  *  \throw If no field values of the required parameters are available.
8824  */
8825 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8826 {
8827   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8828   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8829   if(!myF1TSC)
8830     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8831   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8832   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8833   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8834   return ret.retn();
8835 }
8836
8837 /*!
8838  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8839  * given support. 
8840  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8841  *  \param [in] type - a spatial discretization of the new field.
8842  *  \param [in] iteration - the iteration number of a required time step.
8843  *  \param [in] order - the iteration order number of required time step.
8844  *  \param [in] mesh - the supporting mesh.
8845  *  \param [out] arrOut - the DataArrayInt containing values of field.
8846  *  \param [in] renumPol - specifies how to permute values of the result field according to
8847  *          the optional numbers of cells and nodes, if any. The valid values are
8848  *          - 0 - do not permute.
8849  *          - 1 - permute cells.
8850  *          - 2 - permute nodes.
8851  *          - 3 - permute cells and nodes.
8852  *
8853  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8854  *          caller is to delete this field using decrRef() as it is no more needed. 
8855  *  \throw If no field of \a this is lying on \a mesh.
8856  *  \throw If no field values of the required parameters are available.
8857  */
8858 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8859 {
8860   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8861   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8862   if(!myF1TSC)
8863     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8864   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8865   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8866   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8867   return ret.retn();
8868 }
8869
8870 /*!
8871  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8872  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8873  * This method is useful for MED2 file format when field on different mesh was autorized.
8874  */
8875 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8876 {
8877   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8878   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8879   if(!myF1TSC)
8880     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8881   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8882   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8883   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8884   return ret.retn();
8885 }
8886
8887 /*!
8888  * Returns values and a profile of the field of a given type, of a given time step,
8889  * lying on a given support.
8890  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8891  *  \param [in] type - a spatial discretization of the field.
8892  *  \param [in] iteration - the iteration number of a required time step.
8893  *  \param [in] order - the iteration order number of required time step.
8894  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8895  *  \param [in] mesh - the supporting mesh.
8896  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8897  *          field of interest lies on. If the field lies on all entities of the given
8898  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
8899  *          using decrRef() as it is no more needed.  
8900  *  \param [in] glob - the global data storing profiles and localization.
8901  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8902  *          field. The caller is to delete this array using decrRef() as it is no more needed.
8903  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8904  *  \throw If no field of \a this is lying on \a mesh.
8905  *  \throw If no field values of the required parameters are available.
8906  */
8907 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8908 {
8909   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8910   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8911   if(!myF1TSC)
8912     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8913   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8914   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8915 }
8916
8917 /*!
8918  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8919  *  \param [in] pos - a time step id.
8920  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8921  *          delete this field using decrRef() as it is no more needed.
8922  *  \throw If \a pos is not a valid time step id.
8923  */
8924 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8925 {
8926   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8927   if(!item)
8928     {
8929       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8930       throw INTERP_KERNEL::Exception(oss.str().c_str());
8931     }
8932   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8933   if(itemC)
8934     {
8935       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8936       ret->shallowCpyGlobs(*this);
8937       return ret.retn();
8938     }
8939   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8940   throw INTERP_KERNEL::Exception(oss.str().c_str());
8941 }
8942
8943 /*!
8944  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8945  * the given field is checked if its elements are sorted suitable for writing to MED file
8946  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
8947  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8948  *  \param [in] field - the field to add to \a this.
8949  *  \throw If the name of \a field is empty.
8950  *  \throw If the data array of \a field is not set.
8951  *  \throw If existing time steps have different name or number of components than \a field.
8952  *  \throw If the underlying mesh of \a field has no name.
8953  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8954  */
8955 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8956 {
8957   contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8958 }
8959
8960 /*!
8961  * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8962  * a given dimension of a given mesh are used as the support of the given field.
8963  * Elements of the given mesh must be sorted suitable for writing to MED file. 
8964  * Order of underlying mesh entities of the given field specified by \a profile parameter
8965  * is not prescribed; this method permutes field values to have them sorted by element
8966  * type as required for writing to MED file.  
8967  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8968  *  \param [in] field - the field to add to \a this.
8969  *  \param [in] mesh - the supporting mesh of \a field.
8970  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8971  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
8972  *  \throw If either \a field or \a mesh or \a profile has an empty name.
8973  *  \throw If existing time steps have different name or number of components than \a field.
8974  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8975  *  \throw If the data array of \a field is not set.
8976  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8977  */
8978 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8979 {
8980   contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8981 }
8982
8983 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8984 {
8985   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8986   if(!pt)
8987     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8988   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8989   if(!ret)
8990     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 !");
8991   return ret;
8992 }
8993
8994  MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8995 {
8996   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8997   if(!pt)
8998     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8999   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9000   if(!ret)
9001     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 !");
9002   return ret;
9003 }
9004
9005 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9006 {
9007   _content=new MEDFileIntFieldMultiTSWithoutSDA;
9008 }
9009
9010 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9011 {
9012 }
9013
9014 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9015 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9016 {
9017 }
9018 catch(INTERP_KERNEL::Exception& e)
9019   { throw e; }
9020
9021 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9022 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9023 {
9024 }
9025 catch(INTERP_KERNEL::Exception& e)
9026   { throw e; }
9027
9028 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9029 {
9030   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9031 }
9032
9033 //= MEDFileFields
9034
9035 MEDFileFields *MEDFileFields::New()
9036 {
9037   return new MEDFileFields;
9038 }
9039
9040 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9041 {
9042   return new MEDFileFields(fileName,loadAll);
9043 }
9044
9045 std::size_t MEDFileFields::getHeapMemorySize() const
9046 {
9047   std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9048   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9049     if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9050       ret+=(*it)->getHeapMemorySize();
9051   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9052 }
9053
9054 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9055 {
9056   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9057   std::size_t i=0;
9058   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9059     {
9060       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9061         ret->_fields[i]=(*it)->deepCpy();
9062     }
9063   ret->deepCpyGlobs(*this);
9064   return ret.retn();
9065 }
9066
9067 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9068 {
9069   return new MEDFileFields(*this);
9070 }
9071
9072 /*!
9073  * 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
9074  * 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.
9075  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9076  *
9077  * \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.
9078  * \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.
9079  * 
9080  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9081  */
9082 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9083 {
9084   std::set< std::pair<int,int> > s;
9085   bool firstShot=true;
9086   areThereSomeForgottenTS=false;
9087   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9088     {
9089       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9090         continue;
9091       std::vector< std::pair<int,int> > v=(*it)->getIterations();
9092       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9093       if(firstShot)
9094         { s=s1; firstShot=false; }
9095       else
9096         {
9097           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9098           if(s!=s2)
9099             areThereSomeForgottenTS=true;
9100           s=s2;
9101         }
9102     }
9103   std::vector< std::pair<int,int> > ret;
9104   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9105   return ret;
9106 }
9107
9108 int MEDFileFields::getNumberOfFields() const
9109 {
9110   return _fields.size();
9111 }
9112
9113 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9114 {
9115   std::vector<std::string> ret(_fields.size());
9116   int i=0;
9117   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9118     {
9119       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9120       if(f)
9121         {
9122           ret[i]=f->getName();
9123         }
9124       else
9125         {
9126           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9127           throw INTERP_KERNEL::Exception(oss.str().c_str());
9128         }
9129     }
9130   return ret;
9131 }
9132
9133 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9134 {
9135   std::vector<std::string> ret;
9136   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9137     {
9138       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9139       if(cur)
9140         ret.push_back(cur->getMeshName());
9141     }
9142   return ret;
9143 }
9144
9145 std::string MEDFileFields::simpleRepr() const
9146 {
9147   std::ostringstream oss;
9148   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9149   simpleRepr(0,oss);
9150   return oss.str();
9151 }
9152
9153 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9154 {
9155   int nbOfFields=getNumberOfFields();
9156   std::string startLine(bkOffset,' ');
9157   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9158   int i=0;
9159   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9160     {
9161       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9162       if(cur)
9163         {
9164           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9165         }
9166       else
9167         {
9168           oss << startLine << "  - not defined !" << std::endl;
9169         }
9170     }
9171   i=0;
9172   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9173     {
9174       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9175       std::string chapter(17,'0'+i);
9176       oss << startLine << chapter << std::endl;
9177       if(cur)
9178         {
9179           cur->simpleRepr(bkOffset+2,oss,i);
9180         }
9181       else
9182         {
9183           oss << startLine << "  - not defined !" << std::endl;
9184         }
9185       oss << startLine << chapter << std::endl;
9186     }
9187   simpleReprGlobs(oss);
9188 }
9189
9190 MEDFileFields::MEDFileFields()
9191 {
9192 }
9193
9194 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9195 try:MEDFileFieldGlobsReal(fileName)
9196   {
9197     MEDFileUtilities::CheckFileForRead(fileName);
9198     MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9199     int nbFields=MEDnField(fid);
9200     _fields.resize(nbFields);
9201     med_field_type typcha;
9202     for(int i=0;i<nbFields;i++)
9203       {
9204         std::vector<std::string> infos;
9205         std::string fieldName,dtunit;
9206         int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9207         switch(typcha)
9208           {
9209           case MED_FLOAT64:
9210             {
9211               _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9212               break;
9213             }
9214           case MED_INT32:
9215             {
9216               _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9217               break;
9218             }
9219           default:
9220             {
9221               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] !";
9222               throw INTERP_KERNEL::Exception(oss.str().c_str());
9223             }
9224           }
9225       }
9226     loadAllGlobals(fid);
9227   }
9228 catch(INTERP_KERNEL::Exception& e)
9229   {
9230     throw e;
9231   }
9232
9233 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9234 {
9235   int i=0;
9236   writeGlobals(fid,*this);
9237   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9238     {
9239       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9240       if(!elt)
9241         {
9242           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9243           throw INTERP_KERNEL::Exception(oss.str().c_str());
9244         }
9245       elt->writeLL(fid,*this);
9246     }
9247 }
9248
9249 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9250 {
9251   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9252   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9253   writeLL(fid);
9254 }
9255
9256 /*!
9257  * This method alloc the arrays and load potentially huge arrays contained in this field.
9258  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9259  * This method can be also called to refresh or reinit values from a file.
9260  * 
9261  * \throw If the fileName is not set or points to a non readable MED file.
9262  */
9263 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9264 {
9265   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9266   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9267     {
9268       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9269       if(elt)
9270         elt->loadBigArraysRecursively(fid,*elt);
9271     }
9272 }
9273
9274 /*!
9275  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9276  * But once data loaded once, this method does nothing.
9277  * 
9278  * \throw If the fileName is not set or points to a non readable MED file.
9279  * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays
9280  */
9281 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9282 {
9283   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9284   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9285     {
9286       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9287       if(elt)
9288         elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9289     }
9290 }
9291
9292 /*!
9293  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9294  * This method does not release arrays set outside the context of a MED file.
9295  * 
9296  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9297  */
9298 void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception)
9299 {
9300   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9301   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9302     {
9303       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9304       if(elt)
9305         elt->releaseArrays();
9306     }
9307 }
9308
9309 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9310 {
9311   std::vector<std::string> ret;
9312   std::set<std::string> ret2;
9313   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9314     {
9315       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9316       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9317         if(ret2.find(*it2)==ret2.end())
9318           {
9319             ret.push_back(*it2);
9320             ret2.insert(*it2);
9321           }
9322     }
9323   return ret;
9324 }
9325
9326 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9327 {
9328   std::vector<std::string> ret;
9329   std::set<std::string> ret2;
9330   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9331     {
9332       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9333       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9334         if(ret2.find(*it2)==ret2.end())
9335           {
9336             ret.push_back(*it2);
9337             ret2.insert(*it2);
9338           }
9339     }
9340   return ret;
9341 }
9342
9343 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9344 {
9345   std::vector<std::string> ret;
9346   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9347     {
9348       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9349       ret.insert(ret.end(),tmp.begin(),tmp.end());
9350     }
9351   return ret;
9352 }
9353
9354 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9355 {
9356   std::vector<std::string> ret;
9357   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9358     {
9359       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9360       ret.insert(ret.end(),tmp.begin(),tmp.end());
9361     }
9362   return ret;
9363 }
9364
9365 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9366 {
9367   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9368     (*it)->changePflsRefsNamesGen2(mapOfModif);
9369 }
9370
9371 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9372 {
9373   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9374     (*it)->changeLocsRefsNamesGen2(mapOfModif);
9375 }
9376
9377 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9378 {
9379   _fields.resize(newSize);
9380 }
9381
9382 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9383 {
9384   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9385     pushField(*it);
9386 }
9387
9388 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9389 {
9390   if(!field)
9391     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9392   _fields.push_back(field->getContent());
9393   appendGlobs(*field,1e-12);
9394 }
9395
9396 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9397 {
9398   if(!field)
9399     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9400   if(i>=(int)_fields.size())
9401     _fields.resize(i+1);
9402   _fields[i]=field->getContent();
9403   appendGlobs(*field,1e-12);
9404 }
9405
9406 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9407 {
9408   destroyFieldsAtPos(&i,&i+1);
9409 }
9410
9411 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9412 {
9413   std::vector<bool> b(_fields.size(),true);
9414   for(const int *i=startIds;i!=endIds;i++)
9415     {
9416       if(*i<0 || *i>=(int)_fields.size())
9417         {
9418           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9419           throw INTERP_KERNEL::Exception(oss.str().c_str());
9420         }
9421       b[*i]=false;
9422     }
9423   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9424   std::size_t j=0;
9425   for(std::size_t i=0;i<_fields.size();i++)
9426     if(b[i])
9427       fields[j++]=_fields[i];
9428   _fields=fields;
9429 }
9430
9431 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9432 {
9433   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9434   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9435   std::vector<bool> b(_fields.size(),true);
9436   int k=bg;
9437   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9438     {
9439       if(k<0 || k>=(int)_fields.size())
9440         {
9441           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9442           throw INTERP_KERNEL::Exception(oss.str().c_str());
9443         }
9444       b[k]=false;
9445     }
9446   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9447   std::size_t j=0;
9448   for(std::size_t i=0;i<_fields.size();i++)
9449     if(b[i])
9450       fields[j++]=_fields[i];
9451   _fields=fields;
9452 }
9453
9454 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9455 {
9456   bool ret=false;
9457   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9458     {
9459       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9460       if(cur)
9461         ret=cur->changeMeshNames(modifTab) || ret;
9462     }
9463   return ret;
9464 }
9465
9466 /*!
9467  * \param [in] meshName the name of the mesh that will be renumbered.
9468  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9469  *             This code corresponds to the distribution of types in the corresponding mesh.
9470  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9471  * \param [in] renumO2N the old to new renumber array.
9472  * \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 
9473  *         field in \a this.
9474  */
9475 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9476 {
9477   bool ret=false;
9478   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9479     {
9480       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9481       if(fmts)
9482         {
9483           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9484         }
9485     }
9486   return ret;
9487 }
9488
9489 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9490 {
9491   if(i<0 || i>=(int)_fields.size())
9492     {
9493       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9494       throw INTERP_KERNEL::Exception(oss.str().c_str());
9495     }
9496   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9497   if(!fmts)
9498     return 0;
9499   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9500   const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9501   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9502   if(fmtsC)
9503     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9504   else if(fmtsC2)
9505     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9506   else
9507     {
9508       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9509       throw INTERP_KERNEL::Exception(oss.str().c_str());
9510     }
9511   ret->shallowCpyGlobs(*this);
9512   return ret.retn();
9513 }
9514
9515 /*!
9516  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9517  * This method is accessible in python using __getitem__ with a list in input.
9518  * \return a new object that the caller should deal with.
9519  */
9520 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9521 {
9522   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9523   std::size_t sz=std::distance(startIds,endIds);
9524   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9525   int j=0;
9526   for(const int *i=startIds;i!=endIds;i++,j++)
9527     {
9528       if(*i<0 || *i>=(int)_fields.size())
9529         {
9530           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9531           throw INTERP_KERNEL::Exception(oss.str().c_str());
9532         }
9533       fields[j]=_fields[*i];
9534     }
9535   ret->_fields=fields;
9536   return ret.retn();
9537 }
9538
9539 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9540 {
9541   return getFieldAtPos(getPosFromFieldName(fieldName));
9542 }
9543
9544 /*!
9545  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9546  * This method can be seen as a filter applied on \a this, that returns an object containing
9547  * 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
9548  * shallow copied from \a this.
9549  * 
9550  * \param [in] meshName - the name of the mesh on w
9551  * \return a new object that the caller should deal with.
9552  */
9553 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9554 {
9555   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9556   ret->shallowCpyOnlyUsedGlobs(*this);
9557   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9558     {
9559       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9560       if(!cur)
9561         continue;
9562       if(cur->getMeshName()==meshName)
9563         {
9564           cur->incrRef();
9565           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9566           ret->_fields.push_back(cur2);
9567         }
9568     }
9569   return ret.retn();
9570 }
9571
9572 /*!
9573  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9574  * Input time steps are specified using a pair of integer (iteration, order).
9575  * 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,
9576  * but for each multitimestep only the time steps in \a timeSteps are kept.
9577  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9578  * 
9579  * The returned object points to shallow copy of elements in \a this.
9580  * 
9581  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9582  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9583  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9584  */
9585 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9586 {
9587   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9588   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9589     {
9590       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9591       if(!cur)
9592         continue;
9593       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9594       ret->_fields.push_back(elt);
9595     }
9596   ret->shallowCpyOnlyUsedGlobs(*this);
9597   return ret.retn();
9598 }
9599
9600 /*!
9601  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9602  */
9603 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9604 {
9605   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9606   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9607     {
9608       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9609       if(!cur)
9610         continue;
9611       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9612       if(elt->getNumberOfTS()!=0)
9613         ret->_fields.push_back(elt);
9614     }
9615   ret->shallowCpyOnlyUsedGlobs(*this);
9616   return ret.retn();
9617 }
9618
9619 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9620 {
9621   return new MEDFileFieldsIterator(this);
9622 }
9623
9624 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9625 {
9626   std::string tmp(fieldName);
9627   std::vector<std::string> poss;
9628   for(std::size_t i=0;i<_fields.size();i++)
9629     {
9630       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9631       if(f)
9632         {
9633           std::string fname(f->getName());
9634           if(tmp==fname)
9635             return i;
9636           else
9637             poss.push_back(fname);
9638         }
9639     }
9640   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9641   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9642   oss << " !";
9643   throw INTERP_KERNEL::Exception(oss.str().c_str());
9644 }
9645
9646 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9647 {
9648   if(fs)
9649     {
9650       fs->incrRef();
9651       _nb_iter=fs->getNumberOfFields();
9652     }
9653 }
9654
9655 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
9656 {
9657 }
9658
9659 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9660 {
9661   if(_iter_id<_nb_iter)
9662     {
9663       MEDFileFields *fs(_fs);
9664       if(fs)
9665         return fs->getFieldAtPos(_iter_id++);
9666       else
9667         return 0;
9668     }
9669   else
9670     return 0;
9671 }