]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Step 7 : start of filtering structure elements in fields
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
34
35 #include <algorithm>
36 #include <iterator>
37
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
42
43 using namespace MEDCoupling;
44
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
47
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
50
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
52 {
53   return new MEDFileFieldLoc(fid,locName);
54 }
55
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
57 {
58   return new MEDFileFieldLoc(fid,id);
59 }
60
61 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
62 {
63   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
64 }
65
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
67 {
68   med_geometry_type geotype;
69   med_geometry_type sectiongeotype;
70   int nsectionmeshcell;
71   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
74   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76   _nb_node_per_cell=cm.getNumberOfNodes();
77   _ref_coo.resize(_dim*_nb_node_per_cell);
78   _gs_coo.resize(_dim*_nb_gauss_pt);
79   _w.resize(_nb_gauss_pt);
80   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
81 }
82
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
84 {
85   med_geometry_type geotype;
86   med_geometry_type sectiongeotype;
87   int nsectionmeshcell;
88   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
92   _name=locName;
93   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95   _nb_node_per_cell=cm.getNumberOfNodes();
96   _ref_coo.resize(_dim*_nb_node_per_cell);
97   _gs_coo.resize(_dim*_nb_gauss_pt);
98   _w.resize(_nb_gauss_pt);
99   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
100 }
101
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
104                                      _w(w)
105 {
106   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107   _dim=cm.getDimension();
108   _nb_node_per_cell=cm.getNumberOfNodes();
109   _nb_gauss_pt=_w.size();
110 }
111
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
113 {
114   return new MEDFileFieldLoc(*this);
115 }
116
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
118 {
119   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
120 }
121
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
123 {
124   return std::vector<const BigMemoryObject *>();
125 }
126
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
128 {
129   static const char OFF7[]="\n    ";
130   oss << "\"" << _name << "\"" << OFF7;
131   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132   oss << "Dimension=" << _dim << OFF7;
133   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
138 }
139
140 void MEDFileFieldLoc::setName(const std::string& name)
141 {
142   _name=name;
143 }
144
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
146 {
147   if(_name!=other._name)
148     return false;
149   if(_dim!=other._dim)
150     return false;
151   if(_nb_gauss_pt!=other._nb_gauss_pt)
152     return false;
153   if(_nb_node_per_cell!=other._nb_node_per_cell)
154     return false;
155   if(_geo_type!=other._geo_type)
156     return false;
157   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
158     return false;
159   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
160     return false;
161   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162     return false;
163
164   return true;
165 }
166
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
168 {
169   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
170 }
171
172 std::string MEDFileFieldLoc::repr() const
173 {
174   std::ostringstream oss; oss.precision(15);
175   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
177   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
178   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
179   oss << "\n  - Ref coords are : ";
180   int sz=_ref_coo.size();
181   if(sz%_dim==0)
182     {
183       int nbOfTuples=sz/_dim;
184       for(int i=0;i<nbOfTuples;i++)
185         {
186           oss << "(";
187           for(int j=0;j<_dim;j++)
188             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
189           oss << ") ";
190         }
191     }
192   else
193     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194   oss << "\n  - Gauss coords in reference element : ";
195   sz=_gs_coo.size();
196   if(sz%_dim==0)
197     {
198       int nbOfTuples=sz/_dim;
199       for(int i=0;i<nbOfTuples;i++)
200         {
201           oss << "(";
202           for(int j=0;j<_dim;j++)
203             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
204           oss << ") ";
205         }
206     }
207   else
208     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
210   return oss.str();
211 }
212
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
214 {
215   _type=field->getTypeOfField();
216   _start=start;
217   switch(_type)
218   {
219     case ON_CELLS:
220       {
221         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222         _end=_start+nbOfCells;
223         _nval=nbOfCells;
224         break;
225       }
226     case ON_GAUSS_NE:
227       {
228         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229         const int *arrPtr=arr->getConstPointer();
230         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232         _nval=nbOfCells;
233         break;
234       }
235     case ON_GAUSS_PT:
236       {
237         const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238         const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239         const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
240         if(!disc2)
241           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242         const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243         MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244         const int *dai2Ptr(dai2->getConstPointer());
245         int nbi(gsLoc.getWeights().size());
246         MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247         MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248         const int *da3Ptr(da3->getConstPointer());
249         if(da3->getNumberOfTuples()!=nbOfCells)
250           {//profile : for gauss even in NoProfile !!!
251             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
252             _profile=oss.str();
253             da3->setName(_profile.c_str());
254             glob.appendProfile(da3);
255           }
256         MCAuto<DataArrayInt> da4(DataArrayInt::New());
257         _nval=da3->getNbOfElems();
258         da4->alloc(_nval*nbi,1);
259         int *da4Ptr(da4->getPointer());
260         for(int i=0;i<_nval;i++)
261           {
262             int ref=dai2Ptr[offset+da3Ptr[i]];
263             for(int j=0;j<nbi;j++)
264               *da4Ptr++=ref+j;
265           }
266         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267         _localization=oss2.str();
268         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269         _end=_start+_nval*nbi;
270         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
271         break;
272       }
273     default:
274       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275   }
276   start=_end;
277 }
278
279 /*!
280  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281  * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
282  * \param [in] multiTypePfl is the end user profile specified in high level API
283  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
285  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
287  */
288 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
289 {
290   _profile.clear();
291   _type=field->getTypeOfField();
292   std::string pflName(multiTypePfl->getName());
293   std::ostringstream oss; oss << pflName;
294   if(_type!=ON_NODES)
295     {
296       if(!isPflAlone)
297         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
298     }
299   else
300     { oss << "_NODE"; }
301   if(locIds)
302     {
303       if(pflName.empty())
304         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305       if(_type!=ON_GAUSS_PT)
306         {
307           locIds->setName(oss.str());
308           glob.appendProfile(locIds);
309           _profile=oss.str();
310         }
311     }
312   _start=start;
313   switch(_type)
314   {
315     case ON_NODES:
316       {
317         _nval=idsInPfl->getNumberOfTuples();
318         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
319         _end=_start+_nval;
320         break;
321       }
322     case ON_CELLS:
323       {
324         _nval=idsInPfl->getNumberOfTuples();
325         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326         _end=_start+_nval;
327         break;
328       }
329     case ON_GAUSS_NE:
330       {
331         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334         arr3->computeOffsetsFull();
335         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336         int trueNval=tmp->getNumberOfTuples();
337         _nval=idsInPfl->getNumberOfTuples();
338         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339         _end=_start+trueNval;
340         break;
341       }
342     case ON_GAUSS_PT:
343       {
344         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
345         if(!disc2)
346           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
352         //
353         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
355         //
356         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
357         int trueNval=0;
358         for(const int *pt=da4->begin();pt!=da4->end();pt++)
359           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360         tmp->alloc(trueNval,1);
361         int *tmpPtr=tmp->getPointer();
362         for(const int *pt=da4->begin();pt!=da4->end();pt++)
363           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
364             *tmpPtr++=j;
365         //
366         _nval=da4->getNumberOfTuples();
367         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368         _end=_start+trueNval;
369         oss << "_loc_" << _loc_id;
370         if(locIds)
371           {
372             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373             da5->setName(oss.str());
374             glob.appendProfile(da5);
375             _profile=oss.str();
376           }
377         else
378           {
379             if(!da3->isIota(nbOfEltsInWholeMesh))
380               {
381                 da3->setName(oss.str());
382                 glob.appendProfile(da3);
383                 _profile=oss.str();
384               }
385           }
386         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387         _localization=oss2.str();
388         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
389         break;
390       }
391     default:
392       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
393   }
394   start=_end;
395 }
396
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
398 {
399   _start=start;
400   _nval=arrr->getNumberOfTuples();
401   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
402   _end=_start+_nval;
403   start=_end;
404 }
405
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
407 {
408   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
409 }
410
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
412 {
413   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
414 }
415
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
417 {
418   return new MEDFileFieldPerMeshPerTypePerDisc(other);
419 }
420
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
422 {
423   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
424 }
425
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
427 {
428   std::vector<const BigMemoryObject *> ret(1);
429   ret[0]=(const PartDefinition*)_pd;
430   return ret;
431 }
432
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
434 {
435   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
436   ret->_father=father;
437   return ret.retn();
438 }
439
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
442 {
443   if(pd)
444     pd->incrRef();
445 }
446 catch(INTERP_KERNEL::Exception& e)
447 {
448     throw e;
449 }
450
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
452 {
453 }
454
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
456 {
457 }
458
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
461 {
462 }
463
464 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
465 {
466   const PartDefinition *pd(_pd);
467   if(!pd)
468     {
469       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
470       int nbi,tmp1;
471       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472       if(_end-_start!=nbValsInFile*nbi)
473         {
474           std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi <<  " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
475           throw INTERP_KERNEL::Exception(oss.str());
476         }
477       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
478     }
479   else
480     {
481       if(!_profile.empty())
482         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
484       int profilesize,nbi;
485       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
487       if(spd)
488         {
489           int start,stop,step;
490           spd->getSlice(start,stop,step);
491           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492           med_filter filter=MED_FILTER_INIT;
493           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496                                    /*lastblocksize=useless because count=1*/0,&filter);
497           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498           MEDfilterClose(&filter);
499           return ;
500         }
501       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
502       if(dpd)
503         {
504           dpd->checkConsistencyLight();
505           MCAuto<DataArrayInt> myIds(dpd->toDAI());
506           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508           myIds->applyLin(1,-a);
509           int nbOfEltsToLoad(b-a+1);
510           med_filter filter=MED_FILTER_INIT;
511           {//TODO : manage int32 !
512             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517                                      /*lastblocksize=useless because count=1*/0,&filter);
518             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
522           }
523           MEDfilterClose(&filter);
524         }
525       else
526         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
527     }
528 }
529
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
531 {
532   return _father;
533 }
534
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
536 {
537   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539   std::string fieldName(nasc.getName()),meshName(getMeshName());
540   int iteration(getIteration()),order(getOrder()),profilesize,nbi;
541   TypeOfField type(getType());
542   med_geometry_type mgeoti;
543   med_entity_type menti;
544   _father->entriesForMEDfile(type,mgeoti,menti);
545   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
546   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
547   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
548   const PartDefinition *pd(_pd);
549   if(!pd)
550     {
551       _nval=zeNVal;
552     }
553   else
554     {
555       if(!_profile.empty())
556         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
557       _nval=pd->getNumberOfElems();
558     }
559   _start=start;
560   _end=start+_nval*nbi;
561   start=_end;
562   if(type==ON_CELLS && !_localization.empty())
563     {
564       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
565         setType(ON_GAUSS_PT);
566       else
567         {
568           setType(ON_GAUSS_NE);
569           _localization.clear();
570         }
571     }
572 }
573
574 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
575 {
576   std::string fieldName(nasc.getName()),meshName(getMeshName());
577   int iteration(getIteration()),order(getOrder());
578   TypeOfField type(getType());
579   med_geometry_type mgeoti;
580   med_entity_type menti;
581   _father->entriesForMEDfile(type,mgeoti,menti);
582   if(_start>_end)
583     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
584   if(_start==_end)
585     return ;
586   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
587   if(_start<0 || _start>=arr->getNumberOfTuples())
588     {
589       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
590       throw INTERP_KERNEL::Exception(oss.str());
591     }
592   if(_end<0 || _end>arr->getNumberOfTuples())
593     {
594       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
595       throw INTERP_KERNEL::Exception(oss.str());
596     }
597   int nbOfCompo(arr->getNumberOfComponents());
598   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
599   if(arrD)
600     {
601       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
602       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
603       return ;
604     }
605   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
606   if(arrI)
607     {
608       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
609       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
610       return ;
611     }
612   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
613 }
614
615 /*!
616  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
617  */
618 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
619 {
620   int delta=_end-_start;
621   _start=newValueOfStart;
622   _end=_start+delta;
623 }
624
625 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
626 {
627   return _father->getIteration();
628 }
629
630 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
631 {
632   return _father->getOrder();
633 }
634
635 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
636 {
637   return _father->getTime();
638 }
639
640 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
641 {
642   return _father->getMeshName();
643 }
644
645 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
646 {
647   const char startLine[]="    ## ";
648   std::string startLine2(bkOffset,' ');
649   startLine2+=startLine;
650   INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
651   oss << startLine2 << "Localization #" << id << "." << std::endl;
652   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
653   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
654   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
655   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
656 }
657
658 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
659 {
660   return _type;
661 }
662
663 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
664 {
665   return _father->getGeoType();
666 }
667
668 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
669 {
670   types.insert(_type);
671 }
672
673 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
674 {
675   _type=newType;
676 }
677
678 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
679 {
680   return _father->getNumberOfComponents();
681 }
682
683 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
684 {
685   return _end-_start;
686 }
687
688 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
689 {
690   return _father->getOrCreateAndGetArray();
691 }
692
693 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
694 {
695   const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
696   return fath->getOrCreateAndGetArray();
697 }
698
699 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
700 {
701   return _father->getInfo();
702 }
703
704 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
705 {
706   return _profile;
707 }
708
709 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
710 {
711   _profile=newPflName;
712 }
713
714 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
715 {
716   return _localization;
717 }
718
719 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
720 {
721   _localization=newLocName;
722 }
723
724 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
725 {
726   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
727     {
728       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
729         {
730           _profile=(*it2).second;
731           return;
732         }
733     }
734 }
735
736 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
737 {
738   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
739     {
740       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
741         {
742           _localization=(*it2).second;
743           return;
744         }
745     }
746 }
747
748 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
749 {
750   if(type!=_type)
751     return ;
752   dads.push_back(std::pair<int,int>(_start,_end));
753   geoTypes.push_back(getGeoType());
754   if(_profile.empty())
755     pfls.push_back(0);
756   else
757     {
758       pfls.push_back(glob->getProfile(_profile.c_str()));
759     }
760   if(_localization.empty())
761     locs.push_back(-1);
762   else
763     {
764       locs.push_back(glob->getLocalizationId(_localization.c_str()));
765     }
766 }
767
768 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
769 {
770   entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
771   startEntryId++;
772 }
773
774 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
775 {
776   TypeOfField type=getType();
777   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
778   med_geometry_type mgeoti;
779   med_entity_type menti;
780   _father->entriesForMEDfile(getType(),mgeoti,menti);
781   const DataArray *arr(getOrCreateAndGetArray());
782   if(!arr)
783     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
784   if(!arr->isAllocated())
785     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
786   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
787   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
788   const unsigned char *locToWrite=0;
789   if(arrD)
790     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
791   else if(arrI)
792     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
793   else
794     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
795   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
796                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
797                                                    locToWrite));
798 }
799
800 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
801 {
802   type=_type;
803   pfl=_profile;
804   loc=_localization;
805   dad.first=_start; dad.second=_end;
806 }
807
808 /*!
809  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
810  *             This code corresponds to the distribution of types in the corresponding mesh.
811  * \param [out] ptToFill memory zone where the output will be stored.
812  * \return the size of data pushed into output param \a ptToFill
813  */
814 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
815 {
816   _loc_id=offset;
817   std::ostringstream oss;
818   std::size_t nbOfType=codeOfMesh.size()/3;
819   int found=-1;
820   for(std::size_t i=0;i<nbOfType && found==-1;i++)
821     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
822       found=(int)i;
823   if(found==-1)
824     {
825       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
826       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
827       throw INTERP_KERNEL::Exception(oss.str());
828     }
829   int *work=ptToFill;
830   if(_profile.empty())
831     {
832       if(_nval!=codeOfMesh[3*found+1])
833         {
834           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
835           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
836           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
837           throw INTERP_KERNEL::Exception(oss.str());
838         }
839       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
840         *work++=ii;
841     }
842   else
843     {
844       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
845       if(pfl->getNumberOfTuples()!=_nval)
846         {
847           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
848           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
849           oss << _nval;
850           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
851           throw INTERP_KERNEL::Exception(oss.str());
852         }
853       int offset2=codeOfMesh[3*found+2];
854       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
855         {
856           if(*pflId<codeOfMesh[3*found+1])
857             *work++=offset2+*pflId;
858         }
859     }
860   return _nval;
861 }
862
863 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
864 {
865   for(int i=_start;i<_end;i++)
866     *ptToFill++=i;
867   return _end-_start;
868 }
869
870 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
871 {
872   switch(type)
873   {
874     case ON_CELLS:
875       return -2;
876     case ON_GAUSS_NE:
877       return -1;
878     case ON_GAUSS_PT:
879       return locId;
880     default:
881       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
882   }
883 }
884
885 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
886 {
887   int id=0;
888   std::map<std::pair<std::string,TypeOfField>,int> m;
889   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
890   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
891     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
892       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
893   ret.resize(id);
894   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
895     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
896   return ret;
897 }
898
899 /*!
900  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
901  * 
902  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
903  * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
904  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
905  * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
906  * \param [in,out] glob if necessary by the method, new profiles can be added to it
907  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
908  * \param [out] result All new entries will be appended on it.
909  * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
910  */
911 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
912                                                        const DataArrayInt *explicitIdsInMesh,
913                                                        const std::vector<int>& newCode,
914                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
915                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
916 {
917   if(entriesOnSameDisc.empty())
918     return false;
919   TypeOfField type=entriesOnSameDisc[0]->getType();
920   int szEntities=0,szTuples=0;
921   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
922     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
923   int nbi=szTuples/szEntities;
924   if(szTuples%szEntities!=0)
925     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
926   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
927   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
928   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
929   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
930   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
931   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
932   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
933   int id=0;
934   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
935     {
936       int startOfEltIdOfChunk=(*it)->_start;
937       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
938       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
939       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
940       //
941       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
942       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
943       //
944       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
945       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
946     }
947   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
948   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
949   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
950   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
951   //
952   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
953   //
954   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
955   arrPart->renumberInPlace(renumTupleIds->begin());
956   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
957   bool ret=false;
958   const int *idIt=diffVals->begin();
959   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
960   int offset2=0;
961   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
962     {
963       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
964       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
965       int nbEntityElts=subIds->getNumberOfTuples();
966       bool ret2;
967       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
968           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
969                                       offset+offset2,
970                                       li,glob,ret2);
971       ret=ret || ret2;
972       result.push_back(eltToAdd);
973       offset2+=nbEntityElts*nbi;
974     }
975   ret=ret || li.empty();
976   return ret;
977 }
978
979 /*!
980  * \param [in] typeF type of field of new chunk
981  * \param [in] geoType the geometric type of the chunk
982  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
983  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
984  * \param [in] nbi number of integration points
985  * \param [in] offset The offset in the **global array of data**.
986  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
987  *                 to the new chunk to create.
988  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
989  * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
990  *              and corresponding entry erased from \a entriesOnSameDisc.
991  * \return a newly allocated chunk
992  */
993 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
994                                                                                                   bool isPfl, int nbi, int offset,
995                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
996                                                                                                   MEDFileFieldGlobsReal& glob,
997                                                                                                   bool &notInExisting)
998 {
999   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1000   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1001   for(;it!=entriesOnSameDisc.end();it++)
1002     {
1003       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1004         {
1005           if(!isPfl)
1006             {
1007               if((*it)->_profile.empty())
1008                 break;
1009               else
1010                 if(!(*it)->_profile.empty())
1011                   {
1012                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1013                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1014                       break;
1015                   }
1016             }
1017         }
1018     }
1019   if(it==entriesOnSameDisc.end())
1020     {
1021       notInExisting=true;
1022       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1023       ret->_type=typeF;
1024       ret->_loc_id=(int)geoType;
1025       ret->_nval=nbMeshEntities;
1026       ret->_start=offset;
1027       ret->_end=ret->_start+ret->_nval*nbi;
1028       if(isPfl)
1029         {
1030           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1031           glob.appendProfile(idsOfMeshElt);
1032           ret->_profile=idsOfMeshElt->getName();
1033         }
1034       //tony treatment of localization
1035       return ret;
1036     }
1037   else
1038     {
1039       notInExisting=false;
1040       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1041       ret->_loc_id=(int)geoType;
1042       ret->setNewStart(offset);
1043       entriesOnSameDisc.erase(it);
1044       return ret;
1045     }
1046
1047 }
1048
1049 ////////////////////////////////////
1050
1051 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1052  {
1053  }
1054
1055 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1056 {
1057   _father=father;
1058 }
1059
1060 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1061 {
1062   std::size_t i=0;
1063   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1064     {
1065       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1066         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1067     }
1068 }
1069
1070 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1071 {
1072   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1073 }
1074
1075 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1076 {
1077   std::vector<const BigMemoryObject *> ret;
1078   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1079     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1080   return ret;
1081 }
1082
1083 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1084 {
1085   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1088 }
1089
1090 /*!
1091  * This method is the most general one. No optimization is done here.
1092  * \param [in] multiTypePfl is the end user profile specified in high level API
1093  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1095  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1098  */
1099 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1100 {
1101   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1104 }
1105
1106 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1107 {
1108   _field_pm_pt_pd.resize(1);
1109   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1111 }
1112
1113 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1114 {
1115   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116   if(!arr || !arr->isAllocated())
1117     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1118   _field_pm_pt_pd.resize(1);
1119   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120   _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1121 }
1122
1123 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1124 {
1125   TypeOfField type=field->getTypeOfField();
1126   if(type!=ON_GAUSS_PT)
1127     {
1128       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129       int sz=_field_pm_pt_pd.size();
1130       bool found=false;
1131       for(int j=0;j<sz && !found;j++)
1132         {
1133           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1134             {
1135               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136               found=true;
1137             }
1138         }
1139       if(!found)
1140         {
1141           _field_pm_pt_pd.resize(sz+1);
1142           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1143         }
1144       std::vector<int> ret(1,(int)sz);
1145       return ret;
1146     }
1147   else
1148     {
1149       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150       int sz2=ret2.size();
1151       std::vector<int> ret3(sz2);
1152       int k=0;
1153       for(int i=0;i<sz2;i++)
1154         {
1155           int sz=_field_pm_pt_pd.size();
1156           int locIdToFind=ret2[i];
1157           bool found=false;
1158           for(int j=0;j<sz && !found;j++)
1159             {
1160               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1161                 {
1162                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1163                   ret3[k++]=j;
1164                   found=true;
1165                 }
1166             }
1167           if(!found)
1168             {
1169               _field_pm_pt_pd.resize(sz+1);
1170               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1171               ret3[k++]=sz;
1172             }
1173         }
1174       return ret3;
1175     }
1176 }
1177
1178 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1179 {
1180   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1182   if(!disc2)
1183     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1185   if(!da)
1186     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189   if(retTmp->presenceOfValue(-1))
1190     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191   std::vector<int> ret(retTmp->begin(),retTmp->end());
1192   return ret;
1193 }
1194
1195 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1196 {
1197   TypeOfField type=field->getTypeOfField();
1198   if(type!=ON_GAUSS_PT)
1199     {
1200       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201       int sz=_field_pm_pt_pd.size();
1202       bool found=false;
1203       for(int j=0;j<sz && !found;j++)
1204         {
1205           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1206             {
1207               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1208               found=true;
1209             }
1210         }
1211       if(!found)
1212         {
1213           _field_pm_pt_pd.resize(sz+1);
1214           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1215         }
1216       std::vector<int> ret(1,0);
1217       return ret;
1218     }
1219   else
1220     {
1221       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222       int sz2=ret2.size();
1223       std::vector<int> ret3(sz2);
1224       int k=0;
1225       for(int i=0;i<sz2;i++)
1226         {
1227           int sz=_field_pm_pt_pd.size();
1228           int locIdToFind=ret2[i];
1229           bool found=false;
1230           for(int j=0;j<sz && !found;j++)
1231             {
1232               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1233                 {
1234                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1235                   ret3[k++]=j;
1236                   found=true;
1237                 }
1238             }
1239           if(!found)
1240             {
1241               _field_pm_pt_pd.resize(sz+1);
1242               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1243               ret3[k++]=sz;
1244             }
1245         }
1246       return ret3;
1247     }
1248 }
1249
1250 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1251 {
1252   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1254   if(!disc2)
1255     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1257   if(!da)
1258     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261   if(retTmp->presenceOfValue(-1))
1262     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263   std::vector<int> ret(retTmp->begin(),retTmp->end());
1264   return ret;
1265 }
1266
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1268 {
1269   return _father;
1270 }
1271
1272 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1273 {
1274   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1275   int curDim((int)cm.getDimension());
1276   if(dim!=std::numeric_limits<int>::max())
1277     {
1278       if(dim!=curDim)
1279         return false;
1280     }
1281   else
1282     dim=curDim;
1283   return true;
1284 }
1285
1286 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1287 {
1288   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1289     {
1290       (*it)->fillTypesOfFieldAvailable(types);
1291     }
1292 }
1293
1294 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1295 {
1296   int sz=_field_pm_pt_pd.size();
1297   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1298   for(int i=0;i<sz;i++)
1299     {
1300       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1301     }
1302 }
1303
1304 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1305 {
1306   return _father->getIteration();
1307 }
1308
1309 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1310 {
1311   return _father->getOrder();
1312 }
1313
1314 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1315 {
1316   return _father->getTime();
1317 }
1318
1319 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1320 {
1321   return _father->getMeshName();
1322 }
1323
1324 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1325 {
1326   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1327     {
1328       globalSz+=(*it)->getNumberOfTuples();
1329     }
1330   nbOfEntries+=(int)_field_pm_pt_pd.size();
1331 }
1332
1333 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1334 {
1335   return _father->getNumberOfComponents();
1336 }
1337
1338 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1339 {
1340   std::size_t nb(0);
1341   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1342     {
1343       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1344       if(fmtd)
1345         nb++;
1346     }
1347   return nb>1;
1348 }
1349
1350 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1351 {
1352   return _father->getOrCreateAndGetArray();
1353 }
1354
1355 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1356 {
1357   const MEDFileFieldPerMesh *fath=_father;
1358   return fath->getOrCreateAndGetArray();
1359 }
1360
1361 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1362 {
1363   return _father->getInfo();
1364 }
1365
1366 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1367 {
1368   std::vector<std::string> ret;
1369   std::set<std::string> ret2;
1370   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1371     {
1372       std::string tmp=(*it1)->getProfile();
1373       if(!tmp.empty())
1374         if(ret2.find(tmp)==ret2.end())
1375           {
1376             ret.push_back(tmp);
1377             ret2.insert(tmp);
1378           }
1379     }
1380   return ret;
1381 }
1382
1383 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1384 {
1385   std::vector<std::string> ret;
1386   std::set<std::string> ret2;
1387   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1388     {
1389       std::string tmp=(*it1)->getLocalization();
1390       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1391         if(ret2.find(tmp)==ret2.end())
1392           {
1393             ret.push_back(tmp);
1394             ret2.insert(tmp);
1395           }
1396     }
1397   return ret;
1398 }
1399
1400 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1401 {
1402   std::vector<std::string> ret;
1403   std::set<std::string> ret2;
1404   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1405     {
1406       std::string tmp=(*it1)->getProfile();
1407       if(!tmp.empty())
1408         ret.push_back(tmp);
1409     }
1410   return ret;
1411 }
1412
1413 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1414 {
1415   std::vector<std::string> ret;
1416   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1417     {
1418       std::string tmp=(*it1)->getLocalization();
1419       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1420         ret.push_back(tmp);
1421     }
1422   return ret;
1423 }
1424
1425 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1426 {
1427   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428     (*it1)->changePflsRefsNamesGen(mapOfModif);
1429 }
1430
1431 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1432 {
1433   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1434     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1435 }
1436
1437 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1438 {
1439   if(_field_pm_pt_pd.empty())
1440     {
1441       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1442       throw INTERP_KERNEL::Exception(oss.str());
1443     }
1444   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1445     return _field_pm_pt_pd[locId];
1446   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1447   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1448   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1449   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1450 }
1451
1452 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1453 {
1454   if(_field_pm_pt_pd.empty())
1455     {
1456       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1457       throw INTERP_KERNEL::Exception(oss.str());
1458     }
1459   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1460     return _field_pm_pt_pd[locId];
1461   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1462   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1463   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1464   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1465 }
1466
1467 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1468 {
1469   int i=0;
1470   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1471     {
1472       (*it)->fillValues(i,startEntryId,entries);
1473     }
1474 }
1475
1476 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1477 {
1478   _field_pm_pt_pd=leaves;
1479   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1480     (*it)->setFather(this);
1481 }
1482
1483 /*!
1484  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1485  *  \param [out] its - list of pair (start,stop) kept
1486  *  \return bool - false if the type of field \a tof is not contained in \a this.
1487  */
1488 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1489 {
1490   bool ret(false);
1491   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1492   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1493     if((*it)->getType()==tof)
1494       {
1495         newPmPtPd.push_back(*it);
1496         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1497         (*it)->setNewStart(globalNum);
1498         globalNum=(*it)->getEnd();
1499         its.push_back(bgEnd);
1500         ret=true;
1501       }
1502   if(ret)
1503     _field_pm_pt_pd=newPmPtPd;
1504   return ret;
1505 }
1506
1507 /*!
1508  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1509  *  \param [out] its - list of pair (start,stop) kept
1510  *  \return bool - false if the type of field \a tof is not contained in \a this.
1511  */
1512 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1513 {
1514   if(_field_pm_pt_pd.size()<=idOfDisc)
1515     return false;
1516   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1517   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1518   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1519   elt->setNewStart(globalNum);
1520   globalNum=elt->getEnd();
1521   its.push_back(bgEnd);
1522   _field_pm_pt_pd=newPmPtPd;
1523   return true;
1524 }
1525
1526 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1527 {
1528   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1529     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1530 }
1531
1532 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1533 {
1534   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1535     (*it)->loadBigArray(fid,nasc);
1536 }
1537
1538 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1539 {
1540   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1541     {
1542       (*it)->copyOptionsFrom(*this);
1543       (*it)->writeLL(fid,nasc);
1544     }
1545 }
1546
1547 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1548 {
1549   switch(ikType)
1550   {
1551     case ON_CELLS:
1552       medfGeoType=typmai3[(int)ikGeoType];
1553       return MED_CELL;
1554     case ON_NODES:
1555       medfGeoType=MED_NONE;
1556       return MED_NODE;
1557     case ON_GAUSS_NE:
1558       medfGeoType=typmai3[(int)ikGeoType];
1559       return MED_NODE_ELEMENT;
1560     case ON_GAUSS_PT:
1561       medfGeoType=typmai3[(int)ikGeoType];
1562       return MED_CELL;
1563     default:
1564       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1565   }
1566   return MED_UNDEF_ENTITY_TYPE;
1567 }
1568
1569 //////////////////////////////////////////////////
1570
1571 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1572 {
1573   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1574 }
1575
1576 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1577 {
1578   return new MEDFileFieldPerMeshPerType(fath,geoType);
1579 }
1580
1581 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1582 {
1583   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1584   ret->setFather(father);
1585   ret->deepCopyElements();
1586   return ret.retn();
1587 }
1588
1589 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
1590 {
1591   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1592     {
1593       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1594       if(meshDim!=(int)cm.getDimension())
1595         return ;
1596     }
1597   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1598     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1599 }
1600
1601 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1602 {
1603   return _geo_type;
1604 }
1605
1606 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1607 {
1608   ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1609 }
1610
1611 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1612 {
1613   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1614   int curDim((int)cm.getDimension());
1615   dim=std::max(dim,curDim);
1616 }
1617
1618 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1619 {
1620   const char startLine[]="  ## ";
1621   std::string startLine2(bkOffset,' ');
1622   std::string startLine3(startLine2);
1623   startLine3+=startLine;
1624   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1625     {
1626       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1627       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1628     }
1629   else
1630     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1631   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1632   int i=0;
1633   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1634     {
1635       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1636       if(cur)
1637         cur->simpleRepr(bkOffset,oss,i);
1638       else
1639         {
1640           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1641         }
1642     }
1643 }
1644
1645 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1646 {
1647   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1648   return std::string(cm.getRepr());
1649 }
1650
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1652 {
1653 }
1654
1655 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1656 {
1657   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1658   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1659   med_geometry_type mgeoti;
1660   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1661   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1662   _field_pm_pt_pd.resize(nbProfiles);
1663   for(int i=0;i<nbProfiles;i++)
1664     {
1665       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1666     }
1667   if(type==ON_CELLS)
1668     {
1669       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1670       for(int i=0;i<nbProfiles2;i++)
1671         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1672     }
1673 }
1674
1675 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1676 {
1677   MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1678   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1679   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1680     {
1681       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1682         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1683     }
1684   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1685     {
1686       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1687       ret->_field_pm_pt_pd.push_back(agg);
1688     }
1689   return ret;
1690 }
1691
1692 //////////////////////////////////////////////////
1693
1694 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1695 {
1696   if(!entities)
1697     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1698   const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1699   if(!entities2)
1700     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1701   const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1702   return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1703 }
1704
1705 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1706 {
1707   _se.takeRef(se);
1708   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1709   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1710   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1711   _field_pm_pt_pd.resize(nbProfiles);
1712   for(int i=0;i<nbProfiles;i++)
1713     {
1714       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1715     }
1716 }
1717
1718 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1719 {
1720   return _se->getDynGT();
1721 }
1722
1723 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1724 {
1725   throw INTERP_KERNEL::Exception("not implemented yet !");
1726 }
1727
1728 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1729 {
1730   gt=getDynGT();
1731   ent=MED_STRUCT_ELEMENT;
1732 }
1733
1734 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1735 {
1736   throw INTERP_KERNEL::Exception("not implemented yet !");
1737 }
1738
1739 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1740 {
1741   const char startLine[]="  ## ";
1742   std::string startLine2(bkOffset,' ');
1743   std::string startLine3(startLine2);
1744   startLine3+=startLine;
1745   oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1746   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1747   int i=0;
1748   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1749     {
1750       if((*it).isNotNull())
1751         (*it)->simpleRepr(bkOffset,oss,i);
1752       else
1753         {
1754           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1755         }
1756     }
1757 }
1758
1759 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1760 {
1761   throw INTERP_KERNEL::Exception("not implemented yet !");
1762 }
1763
1764 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1765 {
1766   throw INTERP_KERNEL::Exception("not implemented yet !");
1767 }
1768
1769 void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1770 {
1771   throw INTERP_KERNEL::Exception("not implemented yet !");
1772 }
1773
1774 //////////////////////////////////////////////////
1775
1776 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1777 {
1778   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1779 }
1780
1781 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1782 {
1783   return new MEDFileFieldPerMesh(fath,mesh);
1784 }
1785
1786 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1787 {
1788   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1789 }
1790
1791 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1792 {
1793   std::vector<const BigMemoryObject *> ret;
1794   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1795     ret.push_back(*it);
1796   return ret;
1797 }
1798
1799 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1800 {
1801   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1802   ret->_father=father;
1803   std::size_t i=0;
1804   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1805     {
1806       if((*it).isNotNull())
1807         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1808     }
1809   return ret.retn();
1810 }
1811
1812 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1813 {
1814   std::string startLine(bkOffset,' ');
1815   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1816   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1817   int i=0;
1818   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1819     {
1820       if((*it).isNotNull())
1821         (*it)->simpleRepr(bkOffset,oss,i);
1822       else
1823         {
1824           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1825         }
1826     }
1827 }
1828
1829 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1830 {
1831   _mesh_name=mesh->getName();
1832   mesh->getTime(_mesh_iteration,_mesh_order);
1833 }
1834
1835 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1836 {
1837   int nbOfTypes=code.size()/3;
1838   int offset=0;
1839   for(int i=0;i<nbOfTypes;i++)
1840     {
1841       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1842       int nbOfCells=code[3*i+1];
1843       int pos=addNewEntryIfNecessary(type);
1844       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1845       offset+=nbOfCells;
1846     }
1847 }
1848
1849 /*!
1850  * This method is the most general one. No optimization is done here.
1851  * \param [in] multiTypePfl is the end user profile specified in high level API
1852  * \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].
1853  * \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.
1854  * \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.
1855  * \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.
1856  * \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.
1857  */
1858 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)
1859 {
1860   int nbOfTypes(code.size()/3);
1861   for(int i=0;i<nbOfTypes;i++)
1862     {
1863       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1864       int pos=addNewEntryIfNecessary(type);
1865       DataArrayInt *pfl=0;
1866       if(code[3*i+2]!=-1)
1867         pfl=idsPerType[code[3*i+2]];
1868       int nbOfTupes2=code2.size()/3;
1869       int found=0;
1870       for(;found<nbOfTupes2;found++)
1871         if(code[3*i]==code2[3*found])
1872           break;
1873       if(found==nbOfTupes2)
1874         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1875       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1876     }
1877 }
1878
1879 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1880 {
1881   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1882   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1883 }
1884
1885 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1886 {
1887   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1888   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1889 }
1890
1891 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1892 {
1893   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1894     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1895 }
1896
1897 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1898 {
1899   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1900     (*it)->loadBigArraysRecursively(fid,nasc);
1901 }
1902
1903 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1904 {
1905   int nbOfTypes=_field_pm_pt.size();
1906   for(int i=0;i<nbOfTypes;i++)
1907     {
1908       _field_pm_pt[i]->copyOptionsFrom(*this);
1909       _field_pm_pt[i]->writeLL(fid,nasc);
1910     }
1911 }
1912
1913 void MEDFileFieldPerMesh::getDimension(int& dim) const
1914 {
1915   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1916     (*it)->getDimension(dim);
1917 }
1918
1919 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1920 {
1921   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1922     if(!(*it)->isUniqueLevel(dim))
1923       return false;
1924   return true;
1925 }
1926
1927 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1928 {
1929   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1930     (*it)->fillTypesOfFieldAvailable(types);
1931 }
1932
1933 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
1934 {
1935   int sz=_field_pm_pt.size();
1936   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1937   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1938   for(int i=0;i<sz;i++)
1939     {
1940       types[i]=_field_pm_pt[i]->getGeoType();
1941       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1942     }
1943   return ret;
1944 }
1945
1946 double MEDFileFieldPerMesh::getTime() const
1947 {
1948   int tmp1,tmp2;
1949   return _father->getTime(tmp1,tmp2);
1950 }
1951
1952 int MEDFileFieldPerMesh::getIteration() const
1953 {
1954   return _father->getIteration();
1955 }
1956
1957 int MEDFileFieldPerMesh::getOrder() const
1958 {
1959   return _father->getOrder();
1960 }
1961
1962 int MEDFileFieldPerMesh::getNumberOfComponents() const
1963 {
1964   return _father->getNumberOfComponents();
1965 }
1966
1967 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1968 {
1969   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1970     {
1971       if((*it).isNull())
1972         continue;
1973       if((*it)->presenceOfMultiDiscPerGeoType())
1974         return true;
1975     }
1976   return false;
1977 }
1978
1979 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1980 {
1981   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1982     if((*it).isNotNull())
1983       {
1984         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
1985         if(pt)
1986           return true;
1987       }
1988   return false;
1989 }
1990
1991 bool MEDFileFieldPerMesh::onlyStructureElements() const
1992 {
1993   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1994     if((*it).isNotNull())
1995       {
1996         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
1997         if(!pt)
1998           return false;
1999       }
2000   return true;
2001 }
2002
2003 void MEDFileFieldPerMesh::killStructureElements()
2004 {
2005   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2006   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2007     {
2008       if((*it).isNotNull())
2009         {
2010           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2011           if(!pt)
2012             res.push_back(*it);
2013         }
2014     }
2015   _field_pm_pt=res;
2016 }
2017
2018 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2019 {
2020   if(!_father)
2021     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2022   return _father->getOrCreateAndGetArray();
2023 }
2024
2025 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2026 {
2027   if(!_father)
2028     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2029   return _father->getOrCreateAndGetArray();
2030 }
2031
2032 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2033 {
2034   return _father->getInfo();
2035 }
2036
2037 /*!
2038  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2039  * 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.
2040  * It returns 2 output vectors :
2041  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2042  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2043  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2044  */
2045 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)
2046 {
2047   int notNullPflsSz=0;
2048   int nbOfArrs=geoTypes.size();
2049   for(int i=0;i<nbOfArrs;i++)
2050     if(pfls[i])
2051       notNullPflsSz++;
2052   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2053   int nbOfDiffGeoTypes=geoTypes3.size();
2054   code.resize(3*nbOfDiffGeoTypes);
2055   notNullPfls.resize(notNullPflsSz);
2056   notNullPflsSz=0;
2057   int j=0;
2058   for(int i=0;i<nbOfDiffGeoTypes;i++)
2059     {
2060       int startZone=j;
2061       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2062       std::vector<const DataArrayInt *> notNullTmp;
2063       if(pfls[j])
2064         notNullTmp.push_back(pfls[j]);
2065       j++;
2066       for(;j<nbOfArrs;j++)
2067         if(geoTypes[j]==refType)
2068           {
2069             if(pfls[j])
2070               notNullTmp.push_back(pfls[j]);
2071           }
2072         else
2073           break;
2074       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2075       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2076       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2077       code[3*i]=(int)refType;
2078       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2079       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2080       if(notNullTmp.empty())
2081         code[3*i+2]=-1;
2082       else
2083         {
2084           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2085           code[3*i+2]=notNullPflsSz++;
2086         }
2087     }
2088 }
2089
2090 /*!
2091  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2092  */
2093 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)
2094 {
2095   int sz=dads.size();
2096   int ret=0;
2097   for(int i=0;i<sz;i++)
2098     {
2099       if(locs[i]==-1)
2100         {
2101           if(type!=ON_GAUSS_NE)
2102             ret+=dads[i].second-dads[i].first;
2103           else
2104             {
2105               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2106               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2107             }
2108         }
2109       else
2110         {
2111           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2112           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2113         }
2114     }
2115   return ret;
2116 }
2117
2118 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2119 {
2120   std::vector<std::string> ret;
2121   std::set<std::string> ret2;
2122   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123     {
2124       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2125       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2126         if(ret2.find(*it2)==ret2.end())
2127           {
2128             ret.push_back(*it2);
2129             ret2.insert(*it2);
2130           }
2131     }
2132   return ret;
2133 }
2134
2135 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2136 {
2137   std::vector<std::string> ret;
2138   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2139     {
2140       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2141       ret.insert(ret.end(),tmp.begin(),tmp.end());
2142     }
2143   return ret;
2144 }
2145
2146 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2147 {
2148   std::vector<std::string> ret;
2149   std::set<std::string> ret2;
2150   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2151     {
2152       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2153       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2154         if(ret2.find(*it2)==ret2.end())
2155           {
2156             ret.push_back(*it2);
2157             ret2.insert(*it2);
2158           }
2159     }
2160   return ret;
2161 }
2162
2163 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2164 {
2165   std::vector<std::string> ret;
2166   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2167     {
2168       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2169       ret.insert(ret.end(),tmp.begin(),tmp.end());
2170     }
2171   return ret;
2172 }
2173
2174 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2175 {
2176   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2177     {
2178       if((*it).first==_mesh_name)
2179         {
2180           _mesh_name=(*it).second;
2181           return true;
2182         }
2183     }
2184   return false;
2185 }
2186
2187 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2188                                                       MEDFileFieldGlobsReal& glob)
2189 {
2190   if(_mesh_name!=meshName)
2191     return false;
2192   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2193   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2194   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2195   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2196   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2197   getUndergroundDataArrayExt(entries);
2198   DataArray *arr0(getOrCreateAndGetArray());//tony
2199   if(!arr0)
2200     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2201   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2202   if(!arr0)
2203     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2204   int sz=0;
2205   if(!arr)
2206     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2207   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2208     {
2209       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2210         {
2211           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2212           sz+=(*it).second.second-(*it).second.first;
2213         }
2214       else
2215         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2216     }
2217   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2218   ////////////////////
2219   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2220   int *workI2=explicitIdsOldInMesh->getPointer();
2221   int sz1=0,sz2=0,sid=1;
2222   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2223   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2224   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2225     {
2226       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2227       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2228       int *workI=explicitIdsOldInArr->getPointer();
2229       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2230         {
2231           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2232           (*itL2)->setLocId(sz2);
2233           (*itL2)->_tmp_work1=(*itL2)->getStart();
2234           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2235         }
2236       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2237     }
2238   explicitIdsOldInMesh->reAlloc(sz2);
2239   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2240   ////////////////////
2241   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2242   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2243   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2244   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2245     {
2246       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2247       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2248       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2249     }
2250   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2251   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2252   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2253     {
2254       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2255       int newStart=elt->getLocId();
2256       elt->setLocId((*it)->getGeoType());
2257       elt->setNewStart(newStart);
2258       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2259       entriesKeptNew.push_back(elt);
2260       entriesKeptNew2.push_back(elt);
2261     }
2262   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2263   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2264   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2265   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2266   bool ret=false;
2267   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2268     {
2269       sid=0;
2270       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2271         {
2272           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2273           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2274           }*/
2275       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2276                                                             glob,arr2,otherEntriesNew) || ret;
2277     }
2278   if(!ret)
2279     return false;
2280   // Assign new dispatching
2281   assignNewLeaves(otherEntriesNew);
2282   arr->deepCopyFrom(*arr2);
2283   return true;
2284 }
2285
2286 /*!
2287  * \param [in,out] globalNum a global numbering counter for the renumbering.
2288  * \param [out] its - list of pair (start,stop) kept
2289  */
2290 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2291 {
2292   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2293   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2294     {
2295       std::vector< std::pair<int,int> > its2;
2296       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2297         {
2298           ret.push_back(*it);
2299           its.insert(its.end(),its2.begin(),its2.end());
2300         }
2301     }
2302   _field_pm_pt=ret;
2303 }
2304
2305 /*!
2306  * \param [in,out] globalNum a global numbering counter for the renumbering.
2307  * \param [out] its - list of pair (start,stop) kept
2308  */
2309 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2310 {
2311   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2312   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2313     {
2314       std::vector< std::pair<int,int> > its2;
2315       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2316         {
2317           ret.push_back(*it);
2318           its.insert(its.end(),its2.begin(),its2.end());
2319         }
2320     }
2321   _field_pm_pt=ret;
2322 }
2323
2324 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2325 {
2326   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2327   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2328     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2329   //
2330   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2331   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2332   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2333   for(;it1!=types.end();it1++,it2++)
2334     {
2335       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2336       elt->setLeaves((*it1).second);
2337       MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2338       *it2=elt2;
2339     }
2340   _field_pm_pt=fieldPmPt;
2341 }
2342
2343 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2344 {
2345   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2346     (*it)->changePflsRefsNamesGen(mapOfModif);
2347 }
2348
2349 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2350 {
2351   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2352     (*it)->changeLocsRefsNamesGen(mapOfModif);
2353 }
2354
2355 /*!
2356  * \param [in] mesh is the whole mesh
2357  */
2358 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2359 {
2360   if(_field_pm_pt.empty())
2361     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2362   //
2363   std::vector< std::pair<int,int> > dads;
2364   std::vector<const DataArrayInt *> pfls;
2365   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2366   std::vector<int> locs,code;
2367   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2368   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2369     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2370   // Sort by types
2371   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2372   if(code.empty())
2373     {
2374       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2375       throw INTERP_KERNEL::Exception(oss.str());
2376     }
2377   //
2378   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2379   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2380   if(type!=ON_NODES)
2381     {
2382       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2383       if(!arr)
2384         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2385       else
2386         {
2387           MCAuto<DataArrayInt> arr2(arr);
2388           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2389         }
2390     }
2391   else
2392     {
2393       if(code.size()!=3)
2394         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2395       int nb=code[1];
2396       if(code[2]==-1)
2397         {
2398           if(nb!=mesh->getNumberOfNodes())
2399             {
2400               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2401               oss << " nodes in mesh !";
2402               throw INTERP_KERNEL::Exception(oss.str());
2403             }
2404           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2405         }
2406       else
2407         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2408     }
2409 }
2410
2411 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2412 {
2413   if(_field_pm_pt.empty())
2414     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2415   //
2416   std::vector<std::pair<int,int> > dads;
2417   std::vector<const DataArrayInt *> pfls;
2418   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2419   std::vector<int> locs,code;
2420   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2421   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2422     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2423   // Sort by types
2424   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2425   if(code.empty())
2426     {
2427       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2428       throw INTERP_KERNEL::Exception(oss.str());
2429     }
2430   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2431   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2432   if(type!=ON_NODES)
2433     {
2434       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2435       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2436     }
2437   else
2438     {
2439       if(code.size()!=3)
2440         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2441       int nb=code[1];
2442       if(code[2]==-1)
2443         {
2444           if(nb!=mesh->getNumberOfNodes())
2445             {
2446               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2447               oss << " nodes in mesh !";
2448               throw INTERP_KERNEL::Exception(oss.str());
2449             }
2450         }
2451       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2452     }
2453   //
2454   return 0;
2455 }
2456
2457 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2458 {
2459   int globalSz=0;
2460   int nbOfEntries=0;
2461   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2462     {
2463       (*it)->getSizes(globalSz,nbOfEntries);
2464     }
2465   entries.resize(nbOfEntries);
2466   nbOfEntries=0;
2467   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2468     {
2469       (*it)->fillValues(nbOfEntries,entries);
2470     }
2471 }
2472
2473 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2474 {
2475   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2476     {
2477       if((*it)->getGeoType()==typ)
2478         return (*it)->getLeafGivenLocId(locId);
2479     }
2480   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2481   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2482   oss << "Possiblities are : ";
2483   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2484     {
2485       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2486       oss << "\"" << cm2.getRepr() << "\", ";
2487     }
2488   throw INTERP_KERNEL::Exception(oss.str());
2489 }
2490
2491 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2492 {
2493   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2494     {
2495       if((*it)->getGeoType()==typ)
2496         return (*it)->getLeafGivenLocId(locId);
2497     }
2498   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2499   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2500   oss << "Possiblities are : ";
2501   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2502     {
2503       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2504       oss << "\"" << cm2.getRepr() << "\", ";
2505     }
2506   throw INTERP_KERNEL::Exception(oss.str());
2507 }
2508
2509 /*!
2510  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2511  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2512  * \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
2513  * \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
2514  */
2515 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2516 {
2517   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2518   if(pms.empty())
2519     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2520   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2521     {
2522       if(!(*it).second)
2523         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2524       if(!(*it).second->getProfile().empty())
2525         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2526       if(!(*it).second->getLocalization().empty())
2527         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2528     }
2529   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2530   std::size_t i(0);
2531   std::vector< std::pair<int,int> > filteredDTS;
2532   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2533     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2534       if((*it2).first==gt)
2535         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2536   if(pms.size()!=filteredDTS.size())
2537     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2538   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2539   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2540   int zeStart(start),nval(0);
2541   for(;it1!=pms.end();it1++,it2++)
2542     {
2543       if((*it1).first!=(*it2).first)
2544         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2545       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2546       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2547       start+=e1-s1;
2548       nval+=((*it1).second)->getNumberOfVals();
2549     }
2550   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2551   return ret;
2552 }
2553
2554 MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2555 {
2556   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2557   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2558   std::size_t i(0);
2559   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2560     {
2561       const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2562       for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2563         {
2564           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2565           const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2566           if(!elt)
2567             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2568           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2569         }
2570     }
2571   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2572     {
2573       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2574       MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2575       ret->_field_pm_pt.push_back(agg2);
2576     }
2577   return ret;
2578 }
2579
2580 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2581 {
2582   int i=0;
2583   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2584   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2585   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2586     {
2587       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2588       if(type==curType)
2589         return i;
2590       else
2591         {
2592           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2593           if(pos>pos2)
2594             it2=it+1;
2595         }
2596     }
2597   int ret=std::distance(_field_pm_pt.begin(),it2);
2598   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2599   return ret;
2600 }
2601
2602 /*!
2603  * 'dads' and 'locs' input parameters have the same number of elements
2604  * \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
2605  */
2606 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2607                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2608                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2609 {
2610   isPfl=false;
2611   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2612   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2613   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2614   const std::vector<std::string>& infos=getInfo();
2615   da->setInfoOnComponents(infos);
2616   da->setName("");
2617   if(type==ON_GAUSS_PT)
2618     {
2619       int offset=0;
2620       int nbOfArrs=dads.size();
2621       for(int i=0;i<nbOfArrs;i++)
2622         {
2623           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2624           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2625           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2626           MCAuto<DataArrayInt> di=DataArrayInt::New();
2627           di->alloc(nbOfElems,1);
2628           di->iota(offset);
2629           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2630           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2631           offset+=nbOfElems;
2632         }
2633     }
2634   arrOut=da;
2635   return ret.retn();
2636 }
2637
2638 /*!
2639  * 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.
2640  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2641  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2642  * The order of cells in the returned field is those imposed by the profile.
2643  * \param [in] mesh is the global mesh.
2644  */
2645 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2646                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2647                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2648                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2649 {
2650   if(da->isIota(mesh->getNumberOfCells()))
2651     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2652   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2653   m2->setName(mesh->getName().c_str());
2654   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2655   isPfl=true;
2656   return ret.retn();
2657 }
2658
2659 /*!
2660  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2661  */
2662 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2663                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2664                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2665 {
2666   if(da->isIota(mesh->getNumberOfNodes()))
2667     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2668   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2669   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2670   if(meshu)
2671     {
2672       if(meshu->getNodalConnectivity()==0)
2673         {
2674           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2675           int nb=da->getNbOfElems();
2676           const int *ptr=da->getConstPointer();
2677           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2678           meshuc->allocateCells(nb);
2679           for(int i=0;i<nb;i++)
2680             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2681           meshuc->finishInsertingCells();
2682           ret->setMesh(meshuc);
2683           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2684           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2685           disc->checkCoherencyBetween(meshuc,arrOut);
2686           return ret.retn();
2687         }
2688     }
2689   //
2690   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2691   isPfl=true;
2692   DataArrayInt *arr2=0;
2693   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2694   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2695   MCAuto<DataArrayInt> arr3(arr2);
2696   int nnodes=mesh2->getNumberOfNodes();
2697   if(nnodes==(int)da->getNbOfElems())
2698     {
2699       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2700       arrOut->renumberInPlace(da3->getConstPointer());
2701       mesh2->setName(mesh->getName().c_str());
2702       ret->setMesh(mesh2);
2703       return ret.retn();
2704     }
2705   else
2706     {
2707       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 !!!";
2708       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2709       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2710       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2711       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2712       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2713       throw INTERP_KERNEL::Exception(oss.str());
2714     }
2715   return 0;
2716 }
2717
2718 /*!
2719  * This method is the most light method of field retrieving.
2720  */
2721 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2722 {
2723   if(!pflIn)
2724     {
2725       pflOut=DataArrayInt::New();
2726       pflOut->alloc(nbOfElems,1);
2727       pflOut->iota(0);
2728     }
2729   else
2730     {
2731       pflOut=const_cast<DataArrayInt*>(pflIn);
2732       pflOut->incrRef();
2733     }
2734   MCAuto<DataArrayInt> safePfl(pflOut);
2735   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2736   const std::vector<std::string>& infos=getInfo();
2737   int nbOfComp=infos.size();
2738   for(int i=0;i<nbOfComp;i++)
2739     da->setInfoOnComponent(i,infos[i].c_str());
2740   safePfl->incrRef();
2741   return da.retn();
2742 }
2743
2744
2745 /// @cond INTERNAL
2746
2747 class MFFPMIter
2748 {
2749 public:
2750   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2751   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2752   virtual ~MFFPMIter() { }
2753   virtual void begin() = 0;
2754   virtual bool finished() const = 0;
2755   virtual void next() = 0;
2756   virtual int current() const = 0;
2757 };
2758
2759 class MFFPMIterSimple : public MFFPMIter
2760 {
2761 public:
2762   MFFPMIterSimple():_pos(0) { }
2763   void begin() { _pos=0; }
2764   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2765   void next() { _pos++; }
2766   int current() const { return _pos; }
2767 private:
2768   int _pos;
2769 };
2770
2771 class MFFPMIter2 : public MFFPMIter
2772 {
2773 public:
2774   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2775   void begin() { _it=_ids.begin(); }
2776   bool finished() const { return _it==_ids.end(); }
2777   void next() { _it++; }
2778   int current() const { return *_it; }
2779 private:
2780   std::vector<int> _ids;
2781   std::vector<int>::const_iterator _it;
2782 };
2783
2784 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2785 {
2786   if(!entities)
2787     return new MFFPMIterSimple;
2788   else
2789     {
2790       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2791       if(entities2)
2792         {
2793           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2794           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2795           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2796             {
2797               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2798                 tmp.push_back((*it).second);
2799             }
2800           return new MFFPMIter2(tmp);
2801         }
2802       return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2803     }
2804 }
2805
2806 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2807 {
2808   if(!entities)
2809     return true;
2810   else
2811     {
2812       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2813       if(entities2)
2814         {
2815           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2816           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2817             if((*it).first==ON_NODES)
2818               return true;
2819           return false;
2820         }
2821       return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2822     }
2823 }
2824
2825 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2826 {
2827   std::size_t sz(cts.size());
2828   _ids.resize(sz);
2829   for(std::size_t i=0;i<sz;i++)
2830     {
2831       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2832       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2833         _ids[i]=(int)std::distance(typmai2,loc);
2834       else
2835         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2836     }
2837 }
2838
2839 /// @endcond
2840
2841 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2842     _father(fath)
2843 {
2844   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2845   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2846   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2847   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2848   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2849   for(iter0->begin();!iter0->finished();iter0->next())
2850     {
2851       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2852       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2853       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2854       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2855       if(nbProfile>0 || nbProfile2>0)
2856         {
2857           const PartDefinition *pd(0);
2858           if(mmu)
2859             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2860           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2861           if(nbProfile>0)
2862             _mesh_name=name0;
2863           else
2864             _mesh_name=name1;
2865         }
2866     }
2867   if(MFFPMIter::IsPresenceOfNode(entities))
2868     {
2869       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2870       if(nbProfile>0)
2871         {
2872           const PartDefinition *pd(0);
2873           if(mmu)
2874             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2875           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2876           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2877         }
2878     }
2879   if(!entities)
2880     return ;
2881   std::vector<int> dynGT(entities->getDynGTAvail());
2882   for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2883     {
2884       int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2885       if(nbPfl>0)
2886         {
2887           _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2888           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2889         }
2890     }
2891 }
2892
2893 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2894 {
2895   copyTinyInfoFrom(mesh);
2896 }
2897
2898 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2899 {
2900   if(id>=(int)_pfls.size())
2901     _pfls.resize(id+1);
2902   _pfls[id]=DataArrayInt::New();
2903   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2904   _pfls[id]->setName(pflName);
2905   _pfls[id]->alloc(lgth,1);
2906   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2907   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2908 }
2909
2910 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2911 {
2912   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2913   int sz;
2914   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2915   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2916   if(i>=(int)_pfls.size())
2917     _pfls.resize(i+1);
2918   _pfls[i]=DataArrayInt::New();
2919   _pfls[i]->alloc(sz,1);
2920   _pfls[i]->setName(pflCpp.c_str());
2921   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2922   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2923 }
2924
2925 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2926 {
2927   int nbOfPfls=_pfls.size();
2928   for(int i=0;i<nbOfPfls;i++)
2929     {
2930       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2931       cpy->applyLin(1,1,0);
2932       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2933       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2934       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2935     }
2936   //
2937   int nbOfLocs=_locs.size();
2938   for(int i=0;i<nbOfLocs;i++)
2939     _locs[i]->writeLL(fid);
2940 }
2941
2942 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2943 {
2944   std::vector<std::string> pfls=getPfls();
2945   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2946     {
2947       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2948       if(it2==pfls.end())
2949         {
2950           _pfls.push_back(*it);
2951         }
2952       else
2953         {
2954           int id=std::distance(pfls.begin(),it2);
2955           if(!(*it)->isEqual(*_pfls[id]))
2956             {
2957               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2958               throw INTERP_KERNEL::Exception(oss.str());
2959             }
2960         }
2961     }
2962   std::vector<std::string> locs=getLocs();
2963   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2964     {
2965       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2966       if(it2==locs.end())
2967         {
2968           _locs.push_back(*it);
2969         }
2970       else
2971         {
2972           int id=std::distance(locs.begin(),it2);
2973           if(!(*it)->isEqual(*_locs[id],eps))
2974             {
2975               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2976               throw INTERP_KERNEL::Exception(oss.str());
2977             }
2978         }
2979     }
2980 }
2981
2982 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2983 {
2984   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2985     getProfile((*it).c_str());
2986 }
2987
2988 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2989 {
2990   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2991     getLocalization((*it).c_str());
2992 }
2993
2994 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2995 {
2996   std::vector<std::string> profiles=real.getPflsReallyUsed();
2997   int sz=profiles.size();
2998   _pfls.resize(sz);
2999   for(int i=0;i<sz;i++)
3000     loadProfileInFile(fid,i,profiles[i].c_str());
3001   //
3002   std::vector<std::string> locs=real.getLocsReallyUsed();
3003   sz=locs.size();
3004   _locs.resize(sz);
3005   for(int i=0;i<sz;i++)
3006     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3007 }
3008
3009 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3010 {
3011   int nProfil=MEDnProfile(fid);
3012   for(int i=0;i<nProfil;i++)
3013     loadProfileInFile(fid,i);
3014   int sz=MEDnLocalization(fid);
3015   _locs.resize(sz);
3016   for(int i=0;i<sz;i++)
3017     {
3018       _locs[i]=MEDFileFieldLoc::New(fid,i);
3019     }
3020 }
3021
3022 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3023 {
3024   return new MEDFileFieldGlobs(fid);
3025 }
3026
3027 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3028 {
3029   return new MEDFileFieldGlobs;
3030 }
3031
3032 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3033 {
3034   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3035 }
3036
3037 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3038 {
3039   std::vector<const BigMemoryObject *> ret;
3040   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3041     ret.push_back((const DataArrayInt *)*it);
3042   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3043     ret.push_back((const MEDFileFieldLoc *)*it);
3044   return ret;
3045 }
3046
3047 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3048 {
3049   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3050   std::size_t i=0;
3051   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3052     {
3053       if((const DataArrayInt *)*it)
3054         ret->_pfls[i]=(*it)->deepCopy();
3055     }
3056   i=0;
3057   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3058     {
3059       if((const MEDFileFieldLoc*)*it)
3060         ret->_locs[i]=(*it)->deepCopy();
3061     }
3062   return ret.retn();
3063 }
3064
3065 /*!
3066  * \throw if a profile in \a pfls in not in \a this.
3067  * \throw if a localization in \a locs in not in \a this.
3068  * \sa MEDFileFieldGlobs::deepCpyPart
3069  */
3070 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3071 {
3072   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3073   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3074     {
3075       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3076       if(!pfl)
3077         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3078       pfl->incrRef();
3079       MCAuto<DataArrayInt> pfl2(pfl);
3080       ret->_pfls.push_back(pfl2);
3081     }
3082   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3083     {
3084       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3085       if(!loc)
3086         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3087       loc->incrRef();
3088       MCAuto<MEDFileFieldLoc> loc2(loc);
3089       ret->_locs.push_back(loc2);
3090     }
3091   ret->setFileName(getFileName());
3092   return ret.retn();
3093 }
3094
3095 /*!
3096  * \throw if a profile in \a pfls in not in \a this.
3097  * \throw if a localization in \a locs in not in \a this.
3098  * \sa MEDFileFieldGlobs::shallowCpyPart
3099  */
3100 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3101 {
3102   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3103   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3104     {
3105       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3106       if(!pfl)
3107         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3108       ret->_pfls.push_back(pfl->deepCopy());
3109     }
3110   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3111     {
3112       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3113       if(!loc)
3114         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3115       ret->_locs.push_back(loc->deepCopy());
3116     }
3117   ret->setFileName(getFileName());
3118   return ret.retn();
3119 }
3120
3121 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3122 {
3123 }
3124
3125 MEDFileFieldGlobs::MEDFileFieldGlobs()
3126 {
3127 }
3128
3129 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3130 {
3131 }
3132
3133 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3134 {
3135   oss << "Profiles :\n";
3136   std::size_t n=_pfls.size();
3137   for(std::size_t i=0;i<n;i++)
3138     {
3139       oss << "  - #" << i << " ";
3140       const DataArrayInt *pfl=_pfls[i];
3141       if(pfl)
3142         oss << "\"" << pfl->getName() << "\"\n";
3143       else
3144         oss << "EMPTY !\n";
3145     }
3146   n=_locs.size();
3147   oss << "Localizations :\n";
3148   for(std::size_t i=0;i<n;i++)
3149     {
3150       oss << "  - #" << i << " ";
3151       const MEDFileFieldLoc *loc=_locs[i];
3152       if(loc)
3153         loc->simpleRepr(oss);
3154       else
3155         oss<< "EMPTY !\n";
3156     }
3157 }
3158
3159 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3160 {
3161   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3162     {
3163       DataArrayInt *elt(*it);
3164       if(elt)
3165         {
3166           std::string name(elt->getName());
3167           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3168             {
3169               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3170                 {
3171                   elt->setName((*it2).second.c_str());
3172                   return;
3173                 }
3174             }
3175         }
3176     }
3177 }
3178
3179 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3180 {
3181   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3182     {
3183       MEDFileFieldLoc *elt(*it);
3184       if(elt)
3185         {
3186           std::string name(elt->getName());
3187           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3188             {
3189               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3190                 {
3191                   elt->setName((*it2).second.c_str());
3192                   return;
3193                 }
3194             }
3195         }
3196     }
3197 }
3198
3199 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3200 {
3201   if(locId<0 || locId>=(int)_locs.size())
3202     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3203   return _locs[locId]->getNbOfGaussPtPerCell();
3204 }
3205
3206 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3207 {
3208   return getLocalizationFromId(getLocalizationId(locName));
3209 }
3210
3211 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3212 {
3213   if(locId<0 || locId>=(int)_locs.size())
3214     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3215   return *_locs[locId];
3216 }
3217
3218 /// @cond INTERNAL
3219 namespace MEDCouplingImpl
3220 {
3221   class LocFinder
3222   {
3223   public:
3224     LocFinder(const std::string& loc):_loc(loc) { }
3225     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3226   private:
3227     const std::string &_loc;
3228   };
3229
3230   class PflFinder
3231   {
3232   public:
3233     PflFinder(const std::string& pfl):_pfl(pfl) { }
3234     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3235   private:
3236     const std::string& _pfl;
3237   };
3238 }
3239 /// @endcond
3240
3241 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3242 {
3243   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3244   if(it==_locs.end())
3245     {
3246       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3247       for(it=_locs.begin();it!=_locs.end();it++)
3248         oss << "\"" << (*it)->getName() << "\", ";
3249       throw INTERP_KERNEL::Exception(oss.str());
3250     }
3251   return std::distance(_locs.begin(),it);
3252 }
3253
3254 /*!
3255  * The returned value is never null.
3256  */
3257 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3258 {
3259   std::string pflNameCpp(pflName);
3260   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3261   if(it==_pfls.end())
3262     {
3263       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3264       for(it=_pfls.begin();it!=_pfls.end();it++)
3265         oss << "\"" << (*it)->getName() << "\", ";
3266       throw INTERP_KERNEL::Exception(oss.str());
3267     }
3268   return *it;
3269 }
3270
3271 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3272 {
3273   if(pflId<0 || pflId>=(int)_pfls.size())
3274     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3275   return _pfls[pflId];
3276 }
3277
3278 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3279 {
3280   if(locId<0 || locId>=(int)_locs.size())
3281     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3282   return *_locs[locId];
3283 }
3284
3285 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3286 {
3287   return getLocalizationFromId(getLocalizationId(locName));
3288 }
3289
3290 /*!
3291  * The returned value is never null.
3292  */
3293 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3294 {
3295   std::string pflNameCpp(pflName);
3296   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3297   if(it==_pfls.end())
3298     {
3299       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3300       for(it=_pfls.begin();it!=_pfls.end();it++)
3301         oss << "\"" << (*it)->getName() << "\", ";
3302       throw INTERP_KERNEL::Exception(oss.str());
3303     }
3304   return *it;
3305 }
3306
3307 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3308 {
3309   if(pflId<0 || pflId>=(int)_pfls.size())
3310     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3311   return _pfls[pflId];
3312 }
3313
3314 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3315 {
3316   std::vector< MCAuto<DataArrayInt> > newPfls;
3317   int i=0;
3318   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3319     {
3320       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3321         newPfls.push_back(*it);
3322     }
3323   _pfls=newPfls;
3324 }
3325
3326 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3327 {
3328   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3329   int i=0;
3330   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3331     {
3332       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3333         newLocs.push_back(*it);
3334     }
3335   _locs=newLocs;
3336 }
3337
3338 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3339 {
3340   int sz=_pfls.size();
3341   std::vector<std::string> ret(sz);
3342   for(int i=0;i<sz;i++)
3343     ret[i]=_pfls[i]->getName();
3344   return ret;
3345 }
3346
3347 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3348 {
3349   int sz=_locs.size();
3350   std::vector<std::string> ret(sz);
3351   for(int i=0;i<sz;i++)
3352     ret[i]=_locs[i]->getName();
3353   return ret;
3354 }
3355
3356 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3357 {
3358   std::vector<std::string> v=getPfls();
3359   std::string s(pflName);
3360   return std::find(v.begin(),v.end(),s)!=v.end();
3361 }
3362
3363 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3364 {
3365   std::vector<std::string> v=getLocs();
3366   std::string s(locName);
3367   return std::find(v.begin(),v.end(),s)!=v.end();
3368 }
3369
3370 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3371 {
3372   std::map<int,std::vector<int> > m;
3373   int i=0;
3374   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3375     {
3376       const DataArrayInt *tmp=(*it);
3377       if(tmp)
3378         {
3379           m[tmp->getHashCode()].push_back(i);
3380         }
3381     }
3382   std::vector< std::vector<int> > ret;
3383   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3384     {
3385       if((*it2).second.size()>1)
3386         {
3387           std::vector<int> ret0;
3388           bool equalityOrNot=false;
3389           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3390             {
3391               std::vector<int>::const_iterator it4=it3; it4++;
3392               for(;it4!=(*it2).second.end();it4++)
3393                 {
3394                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3395                     {
3396                       if(!equalityOrNot)
3397                         ret0.push_back(*it3);
3398                       ret0.push_back(*it4);
3399                       equalityOrNot=true;
3400                     }
3401                 }
3402             }
3403           if(!ret0.empty())
3404             ret.push_back(ret0);
3405         }
3406     }
3407   return ret;
3408 }
3409
3410 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3411 {
3412   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3413 }
3414
3415 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3416 {
3417   std::string name(pfl->getName());
3418   if(name.empty())
3419     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3420   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3421     if(name==(*it)->getName())
3422       {
3423         if(!pfl->isEqual(*(*it)))
3424           {
3425             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3426             throw INTERP_KERNEL::Exception(oss.str());
3427           }
3428       }
3429   pfl->incrRef();
3430   _pfls.push_back(pfl);
3431 }
3432
3433 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3434 {
3435   std::string name(locName);
3436   if(name.empty())
3437     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3438   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3439   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3440     if((*it)->isName(locName))
3441       {
3442         if(!(*it)->isEqual(*obj,1e-12))
3443           {
3444             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3445             throw INTERP_KERNEL::Exception(oss.str());
3446           }
3447       }
3448   _locs.push_back(obj);
3449 }
3450
3451 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3452 {
3453   std::vector<std::string> names=getPfls();
3454   return CreateNewNameNotIn("NewPfl_",names);
3455 }
3456
3457 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3458 {
3459   std::vector<std::string> names=getLocs();
3460   return CreateNewNameNotIn("NewLoc_",names);
3461 }
3462
3463 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3464 {
3465   for(std::size_t sz=0;sz<100000;sz++)
3466     {
3467       std::ostringstream tryName;
3468       tryName << prefix << sz;
3469       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3470         return tryName.str();
3471     }
3472   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3473 }
3474
3475 /*!
3476  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3477  *  \param [in] fname - the file name.
3478  */
3479 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3480 {
3481 }
3482
3483 /*!
3484  * Creates an empty MEDFileFieldGlobsReal.
3485  */
3486 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3487 {
3488 }
3489
3490 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3491 {
3492   return 0;
3493 }
3494
3495 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3496 {
3497   std::vector<const BigMemoryObject *> ret;
3498   ret.push_back((const MEDFileFieldGlobs *)_globals);
3499   return ret;
3500 }
3501
3502 /*!
3503  * Returns a string describing profiles and Gauss points held in \a this.
3504  *  \return std::string - the description string.
3505  */
3506 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3507 {
3508   const MEDFileFieldGlobs *glob=_globals;
3509   std::ostringstream oss2; oss2 << glob;
3510   std::string stars(oss2.str().length(),'*');
3511   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3512   if(glob)
3513     glob->simpleRepr(oss);
3514   else
3515     oss << "NO GLOBAL INFORMATION !\n";
3516 }
3517
3518 void MEDFileFieldGlobsReal::resetContent()
3519 {
3520   _globals=MEDFileFieldGlobs::New();
3521 }
3522
3523 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3524 {
3525 }
3526
3527 /*!
3528  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3529  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3530  */
3531 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3532 {
3533   _globals=other._globals;
3534 }
3535
3536 /*!
3537  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3538  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3539  */
3540 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3541 {
3542   const MEDFileFieldGlobs *otherg(other._globals);
3543   if(!otherg)
3544     return ;
3545   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3546 }
3547
3548 /*!
3549  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3550  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3551  */
3552 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3553 {
3554   const MEDFileFieldGlobs *otherg(other._globals);
3555   if(!otherg)
3556     return ;
3557   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3558 }
3559
3560 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3561 {
3562   _globals=other._globals;
3563   if((const MEDFileFieldGlobs *)_globals)
3564     _globals=other._globals->deepCopy();
3565 }
3566
3567 /*!
3568  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3569  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3570  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3571  *         \a this and \a other MEDFileFieldGlobsReal.
3572  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3573  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3574  */
3575 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3576 {
3577   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3578   if(thisGlobals==otherGlobals)
3579     return ;
3580   if(!thisGlobals)
3581     {
3582       _globals=other._globals;
3583       return ;
3584     }
3585   _globals->appendGlobs(*other._globals,eps);
3586 }
3587
3588 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3589 {
3590   checkGlobsPflsPartCoherency();
3591   checkGlobsLocsPartCoherency();
3592 }
3593
3594 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3595 {
3596   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3597 }
3598
3599 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3600 {
3601   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3602 }
3603
3604 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3605 {
3606   contentNotNull()->loadProfileInFile(fid,id,pflName);
3607 }
3608
3609 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3610 {
3611   contentNotNull()->loadProfileInFile(fid,id);
3612 }
3613
3614 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3615 {
3616   contentNotNull()->loadGlobals(fid,*this);
3617 }
3618
3619 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3620 {
3621   contentNotNull()->loadAllGlobals(fid);
3622 }
3623
3624 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3625 {
3626   contentNotNull()->writeGlobals(fid,opt);
3627 }
3628
3629 /*!
3630  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3631  * or getPflsReallyUsedMulti().
3632  *  \return std::vector<std::string> - a sequence of names of all profiles.
3633  */
3634 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3635 {
3636   return contentNotNull()->getPfls();
3637 }
3638
3639 /*!
3640  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3641  * or getLocsReallyUsedMulti().
3642  *  \return std::vector<std::string> - a sequence of names of all localizations.
3643  */
3644 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3645 {
3646   return contentNotNull()->getLocs();
3647 }
3648
3649 /*!
3650  * Checks if the profile with a given name exists.
3651  *  \param [in] pflName - the profile name of interest.
3652  *  \return bool - \c true if the profile named \a pflName exists.
3653  */
3654 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3655 {
3656   return contentNotNull()->existsPfl(pflName);
3657 }
3658
3659 /*!
3660  * Checks if the localization with a given name exists.
3661  *  \param [in] locName - the localization name of interest.
3662  *  \return bool - \c true if the localization named \a locName exists.
3663  */
3664 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3665 {
3666   return contentNotNull()->existsLoc(locName);
3667 }
3668
3669 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3670 {
3671   return contentNotNull()->createNewNameOfPfl();
3672 }
3673
3674 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3675 {
3676   return contentNotNull()->createNewNameOfLoc();
3677 }
3678
3679 /*!
3680  * Sets the name of a MED file.
3681  *  \param [inout] fileName - the file name.
3682  */
3683 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3684 {
3685   contentNotNull()->setFileName(fileName);
3686 }
3687
3688 /*!
3689  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3690  * in the same order.
3691  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3692  *          Each item of this sequence is a vector containing ids of equal profiles.
3693  */
3694 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3695 {
3696   return contentNotNull()->whichAreEqualProfiles();
3697 }
3698
3699 /*!
3700  * Finds equal localizations.
3701  *  \param [in] eps - a precision used to compare real values of the localizations.
3702  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3703  *          Each item of this sequence is a vector containing ids of equal localizations.
3704  */
3705 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3706 {
3707   return contentNotNull()->whichAreEqualLocs(eps);
3708 }
3709
3710 /*!
3711  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3712  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3713  *        this sequence is a pair whose 
3714  *        - the first item is a vector of profile names to replace by the second item,
3715  *        - the second item is a profile name to replace every profile name of the first item.
3716  */
3717 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3718 {
3719   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3720 }
3721
3722 /*!
3723  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3724  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3725  *        this sequence is a pair whose 
3726  *        - the first item is a vector of localization names to replace by the second item,
3727  *        - the second item is a localization name to replace every localization name of the first item.
3728  */
3729 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3730 {
3731   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3732 }
3733
3734 /*!
3735  * Replaces references to some profiles (a reference is a profile name) by references
3736  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3737  * them-selves accordingly. <br>
3738  * This method is a generalization of changePflName().
3739  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3740  *        this sequence is a pair whose 
3741  *        - the first item is a vector of profile names to replace by the second item,
3742  *        - the second item is a profile name to replace every profile of the first item.
3743  * \sa changePflsRefsNamesGen()
3744  * \sa changePflName()
3745  */
3746 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3747 {
3748   changePflsRefsNamesGen(mapOfModif);
3749   changePflsNamesInStruct(mapOfModif);
3750 }
3751
3752 /*!
3753  * Replaces references to some localizations (a reference is a localization name) by references
3754  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3755  * them-selves accordingly. <br>
3756  * This method is a generalization of changeLocName().
3757  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3758  *        this sequence is a pair whose 
3759  *        - the first item is a vector of localization names to replace by the second item,
3760  *        - the second item is a localization name to replace every localization of the first item.
3761  * \sa changeLocsRefsNamesGen()
3762  * \sa changeLocName()
3763  */
3764 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3765 {
3766   changeLocsRefsNamesGen(mapOfModif);
3767   changeLocsNamesInStruct(mapOfModif);
3768 }
3769
3770 /*!
3771  * Renames the profile having a given name and updates references to this profile.
3772  *  \param [in] oldName - the name of the profile to rename.
3773  *  \param [in] newName - a new name of the profile.
3774  * \sa changePflsNames().
3775  */
3776 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3777 {
3778   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3779   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3780   mapOfModif[0]=p;
3781   changePflsNames(mapOfModif);
3782 }
3783
3784 /*!
3785  * Renames the localization having a given name and updates references to this localization.
3786  *  \param [in] oldName - the name of the localization to rename.
3787  *  \param [in] newName - a new name of the localization.
3788  * \sa changeLocsNames().
3789  */
3790 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3791 {
3792   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3793   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3794   mapOfModif[0]=p;
3795   changeLocsNames(mapOfModif);
3796 }
3797
3798 /*!
3799  * Removes duplicated profiles. Returns a map used to update references to removed 
3800  * profiles via changePflsRefsNamesGen().
3801  * Equal profiles are found using whichAreEqualProfiles().
3802  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3803  *          a sequence describing the performed replacements of profiles. Each element of
3804  *          this sequence is a pair whose
3805  *          - the first item is a vector of profile names replaced by the second item,
3806  *          - the second item is a profile name replacing every profile of the first item.
3807  */
3808 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3809 {
3810   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3811   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3812   int i=0;
3813   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3814     {
3815       std::vector< std::string > tmp((*it).size());
3816       int j=0;
3817       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3818         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3819       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3820       ret[i]=p;
3821       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3822       killProfileIds(tmp2);
3823     }
3824   changePflsRefsNamesGen(ret);
3825   return ret;
3826 }
3827
3828 /*!
3829  * Removes duplicated localizations. Returns a map used to update references to removed 
3830  * localizations via changeLocsRefsNamesGen().
3831  * Equal localizations are found using whichAreEqualLocs().
3832  *  \param [in] eps - a precision used to compare real values of the localizations.
3833  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3834  *          a sequence describing the performed replacements of localizations. Each element of
3835  *          this sequence is a pair whose
3836  *          - the first item is a vector of localization names replaced by the second item,
3837  *          - the second item is a localization name replacing every localization of the first item.
3838  */
3839 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3840 {
3841   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3842   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3843   int i=0;
3844   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3845     {
3846       std::vector< std::string > tmp((*it).size());
3847       int j=0;
3848       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3849         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3850       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3851       ret[i]=p;
3852       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3853       killLocalizationIds(tmp2);
3854     }
3855   changeLocsRefsNamesGen(ret);
3856   return ret;
3857 }
3858
3859 /*!
3860  * Returns number of Gauss points per cell in a given localization.
3861  *  \param [in] locId - an id of the localization of interest.
3862  *  \return int - the number of the Gauss points per cell.
3863  */
3864 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3865 {
3866   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3867 }
3868
3869 /*!
3870  * Returns an id of a localization by its name.
3871  *  \param [in] loc - the localization name of interest.
3872  *  \return int - the id of the localization.
3873  *  \throw If there is no a localization named \a loc.
3874  */
3875 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3876 {
3877   return contentNotNull()->getLocalizationId(loc);
3878 }
3879
3880 /*!
3881  * Returns the name of the MED file.
3882  *  \return const std::string&  - the MED file name.
3883  */
3884 std::string MEDFileFieldGlobsReal::getFileName() const
3885 {
3886   return contentNotNull()->getFileName();
3887 }
3888
3889 /*!
3890  * Returns a localization object by its name.
3891  *  \param [in] locName - the name of the localization of interest.
3892  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3893  *  \throw If there is no a localization named \a locName.
3894  */
3895 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3896 {
3897   return contentNotNull()->getLocalization(locName);
3898 }
3899
3900 /*!
3901  * Returns a localization object by its id.
3902  *  \param [in] locId - the id of the localization of interest.
3903  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3904  *  \throw If there is no a localization with id \a locId.
3905  */
3906 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3907 {
3908   return contentNotNull()->getLocalizationFromId(locId);
3909 }
3910
3911 /*!
3912  * Returns a profile array by its name.
3913  *  \param [in] pflName - the name of the profile of interest.
3914  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3915  *  \throw If there is no a profile named \a pflName.
3916  */
3917 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3918 {
3919   return contentNotNull()->getProfile(pflName);
3920 }
3921
3922 /*!
3923  * Returns a profile array by its id.
3924  *  \param [in] pflId - the id of the profile of interest.
3925  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3926  *  \throw If there is no a profile with id \a pflId.
3927  */
3928 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3929 {
3930   return contentNotNull()->getProfileFromId(pflId);
3931 }
3932
3933 /*!
3934  * Returns a localization object, apt for modification, by its id.
3935  *  \param [in] locId - the id of the localization of interest.
3936  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3937  *          having the id \a locId.
3938  *  \throw If there is no a localization with id \a locId.
3939  */
3940 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3941 {
3942   return contentNotNull()->getLocalizationFromId(locId);
3943 }
3944
3945 /*!
3946  * Returns a localization object, apt for modification, by its name.
3947  *  \param [in] locName - the name of the localization of interest.
3948  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3949  *          having the name \a locName.
3950  *  \throw If there is no a localization named \a locName.
3951  */
3952 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3953 {
3954   return contentNotNull()->getLocalization(locName);
3955 }
3956
3957 /*!
3958  * Returns a profile array, apt for modification, by its name.
3959  *  \param [in] pflName - the name of the profile of interest.
3960  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3961  *  \throw If there is no a profile named \a pflName.
3962  */
3963 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3964 {
3965   return contentNotNull()->getProfile(pflName);
3966 }
3967
3968 /*!
3969  * Returns a profile array, apt for modification, by its id.
3970  *  \param [in] pflId - the id of the profile of interest.
3971  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3972  *  \throw If there is no a profile with id \a pflId.
3973  */
3974 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3975 {
3976   return contentNotNull()->getProfileFromId(pflId);
3977 }
3978
3979 /*!
3980  * Removes profiles given by their ids. No data is updated to track this removal.
3981  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3982  */
3983 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3984 {
3985   contentNotNull()->killProfileIds(pflIds);
3986 }
3987
3988 /*!
3989  * Removes localizations given by their ids. No data is updated to track this removal.
3990  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3991  */
3992 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3993 {
3994   contentNotNull()->killLocalizationIds(locIds);
3995 }
3996
3997 /*!
3998  * Stores a profile array.
3999  *  \param [in] pfl - the profile array to store.
4000  *  \throw If the name of \a pfl is empty.
4001  *  \throw If a profile with the same name as that of \a pfl already exists but contains
4002  *         different ids.
4003  */
4004 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4005 {
4006   contentNotNull()->appendProfile(pfl);
4007 }
4008
4009 /*!
4010  * Adds a new localization of Gauss points.
4011  *  \param [in] locName - the name of the new localization.
4012  *  \param [in] geoType - a geometrical type of the reference cell.
4013  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4014  *         must be \c nbOfNodesPerCell * \c dimOfType.
4015  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4016  *         must be  _wg_.size() * \c dimOfType.
4017  *  \param [in] w - the weights of Gauss points.
4018  *  \throw If \a locName is empty.
4019  *  \throw If a localization with the name \a locName already exists but is
4020  *         different form the new one.
4021  */
4022 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
4023 {
4024   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4025 }
4026
4027 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4028 {
4029   MEDFileFieldGlobs *g(_globals);
4030   if(!g)
4031     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4032   return g;
4033 }
4034
4035 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4036 {
4037   const MEDFileFieldGlobs *g(_globals);
4038   if(!g)
4039     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4040   return g;
4041 }
4042
4043 //= MEDFileFieldNameScope
4044
4045 MEDFileFieldNameScope::MEDFileFieldNameScope()
4046 {
4047 }
4048
4049 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4050 {
4051 }
4052
4053 /*!
4054  * Returns the name of \a this field.
4055  *  \return std::string - a string containing the field name.
4056  */
4057 std::string MEDFileFieldNameScope::getName() const
4058 {
4059   return _name;
4060 }
4061
4062 /*!
4063  * Sets name of \a this field
4064  *  \param [in] name - the new field name.
4065  */
4066 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4067 {
4068   _name=fieldName;
4069 }
4070
4071 std::string MEDFileFieldNameScope::getDtUnit() const
4072 {
4073   return _dt_unit;
4074 }
4075
4076 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4077 {
4078   _dt_unit=dtUnit;
4079 }
4080
4081 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4082 {
4083   _name=other._name;
4084   _dt_unit=other._dt_unit;
4085 }
4086
4087 //= MEDFileAnyTypeField1TSWithoutSDA
4088
4089 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4090 {
4091   _field_per_mesh.resize(other._field_per_mesh.size());
4092   std::size_t i=0;
4093   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4094     {
4095       if((const MEDFileFieldPerMesh *)*it)
4096         _field_per_mesh[i]=(*it)->deepCopy(this);
4097     }
4098 }
4099
4100 /*!
4101  * Prints a string describing \a this field into a stream. This string is outputted 
4102  * by \c print Python command.
4103  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4104  *  \param [in,out] oss - the out stream.
4105  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4106  *          info id printed, else, not.
4107  */
4108 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4109 {
4110   std::string startOfLine(bkOffset,' ');
4111   oss << startOfLine << "Field ";
4112   if(bkOffset==0)
4113     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4114   oss << "on one time Step ";
4115   if(f1tsId>=0)
4116     oss << "(" << f1tsId << ") ";
4117   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4118   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4119   const DataArray *arr=getUndergroundDataArray();
4120   if(arr)
4121     {
4122       const std::vector<std::string> &comps=arr->getInfoOnComponents();
4123       if(f1tsId<0)
4124         {
4125           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4126           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4127             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
4128         }
4129       if(arr->isAllocated())
4130         {
4131           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4132         }
4133       else
4134         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4135     }
4136   else
4137     {
4138       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4139     }
4140   oss << startOfLine << "----------------------" << std::endl;
4141   if(!_field_per_mesh.empty())
4142     {
4143       int i=0;
4144       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4145         {
4146           const MEDFileFieldPerMesh *cur=(*it2);
4147           if(cur)
4148             cur->simpleRepr(bkOffset,oss,i);
4149           else
4150             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4151         }
4152     }
4153   else
4154     {
4155       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4156     }
4157   oss << startOfLine << "----------------------" << std::endl;
4158 }
4159
4160 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4161 {
4162   const DataArray *arr(getUndergroundDataArray());
4163   if(!arr)
4164     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4165   int nbOfCompo=arr->getNumberOfComponents();
4166   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4167   for(int i=0;i<nbOfCompo;i++)
4168     {
4169       ret[i]=deepCopy();
4170       std::vector<int> v(1,i);
4171       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4172       ret[i]->setArray(arr2);
4173     }
4174   return ret;
4175 }
4176
4177 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
4178 {
4179 }
4180
4181 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4182 {
4183 }
4184
4185 /*!
4186  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4187  * empty. Returns -1 if this in on nodes.
4188  *  \return int - the dimension of \a this.
4189  */
4190 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4191 {
4192   int ret=-2;
4193   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4194     (*it)->getDimension(ret);
4195   return ret;
4196 }
4197
4198 /*!
4199  * Returns the mesh name.
4200  *  \return std::string - a string holding the mesh name.
4201  *  \throw If \c _field_per_mesh.empty()
4202  */
4203 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4204 {
4205   if(_field_per_mesh.empty())
4206     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4207   return _field_per_mesh[0]->getMeshName();
4208 }
4209
4210 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4211 {
4212   std::string oldName(getMeshName());
4213   std::vector< std::pair<std::string,std::string> > v(1);
4214   v[0].first=oldName; v[0].second=newMeshName;
4215   changeMeshNames(v);
4216 }
4217
4218 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4219 {
4220   bool ret=false;
4221   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4222     {
4223       MEDFileFieldPerMesh *cur(*it);
4224       if(cur)
4225         ret=cur->changeMeshNames(modifTab) || ret;
4226     }
4227   return ret;
4228 }
4229
4230 /*!
4231  * Returns the number of iteration of the state of underlying mesh.
4232  *  \return int - the iteration number.
4233  *  \throw If \c _field_per_mesh.empty()
4234  */
4235 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4236 {
4237   if(_field_per_mesh.empty())
4238     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4239   return _field_per_mesh[0]->getMeshIteration();
4240 }
4241
4242 /*!
4243  * Returns the order number of iteration of the state of underlying mesh.
4244  *  \return int - the order number.
4245  *  \throw If \c _field_per_mesh.empty()
4246  */
4247 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4248 {
4249   if(_field_per_mesh.empty())
4250     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4251   return _field_per_mesh[0]->getMeshOrder();
4252 }
4253
4254 /*!
4255  * Checks if \a this field is tagged by a given iteration number and a given
4256  * iteration order number.
4257  *  \param [in] iteration - the iteration number of interest.
4258  *  \param [in] order - the iteration order number of interest.
4259  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4260  *          \a this->getOrder() == \a order.
4261  */
4262 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4263 {
4264   return iteration==_iteration && order==_order;
4265 }
4266
4267 /*!
4268  * Returns number of iteration and order number of iteration when
4269  * \a this field has been calculated.
4270  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4271  *          order number.
4272  */
4273 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4274 {
4275   std::pair<int,int> p;
4276   fillIteration(p);
4277   return p;
4278 }
4279
4280 /*!
4281  * Returns number of iteration and order number of iteration when
4282  * \a this field has been calculated.
4283  *  \param [in,out] p - a pair returning the iteration number and the iteration
4284  *          order number.
4285  */
4286 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4287 {
4288   p.first=_iteration;
4289   p.second=_order;
4290 }
4291
4292 /*!
4293  * Returns all types of spatial discretization of \a this field.
4294  *  \param [in,out] types - a sequence of types of \a this field.
4295  */
4296 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4297 {
4298   std::set<TypeOfField> types2;
4299   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4300     {
4301       (*it)->fillTypesOfFieldAvailable(types2);
4302     }
4303   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4304   std::copy(types2.begin(),types2.end(),bi);
4305 }
4306
4307 /*!
4308  * Returns all types of spatial discretization of \a this field.
4309  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4310  *          of \a this field.
4311  */
4312 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4313 {
4314   std::vector<TypeOfField> ret;
4315   fillTypesOfFieldAvailable(ret);
4316   return ret;
4317 }
4318
4319 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4320 {
4321   std::vector<std::string> ret;
4322   std::set<std::string> ret2;
4323   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4324     {
4325       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4326       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4327         if(ret2.find(*it2)==ret2.end())
4328           {
4329             ret.push_back(*it2);
4330             ret2.insert(*it2);
4331           }
4332     }
4333   return ret;
4334 }
4335
4336 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4337 {
4338   std::vector<std::string> ret;
4339   std::set<std::string> ret2;
4340   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4341     {
4342       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4343       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4344         if(ret2.find(*it2)==ret2.end())
4345           {
4346             ret.push_back(*it2);
4347             ret2.insert(*it2);
4348           }
4349     }
4350   return ret;
4351 }
4352
4353 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4354 {
4355   std::vector<std::string> ret;
4356   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4357     {
4358       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4359       ret.insert(ret.end(),tmp.begin(),tmp.end());
4360     }
4361   return ret;
4362 }
4363
4364 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4365 {
4366   std::vector<std::string> ret;
4367   std::set<std::string> ret2;
4368   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4369     {
4370       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4371       ret.insert(ret.end(),tmp.begin(),tmp.end());
4372     }
4373   return ret;
4374 }
4375
4376 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4377 {
4378   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4379     (*it)->changePflsRefsNamesGen(mapOfModif);
4380 }
4381
4382 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4383 {
4384   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4385     (*it)->changeLocsRefsNamesGen(mapOfModif);
4386 }
4387
4388 /*!
4389  * Returns all attributes of parts of \a this field lying on a given mesh.
4390  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4391  * item of every of returned sequences refers to the _i_-th part of \a this field.
4392  * Thus all sequences returned by this method are of the same length equal to number
4393  * of different types of supporting entities.<br>
4394  * A field part can include sub-parts with several different spatial discretizations,
4395  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4396  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4397  * of a nested sequence corresponds to a type of spatial discretization.<br>
4398  * This method allows for iteration over MEDFile DataStructure without any overhead.
4399  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4400  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4401  *          not checked if \a mname == \c NULL).
4402  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4403  *          a field part is returned. 
4404  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4405  *          This sequence is of the same length as \a types. 
4406  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4407  *          discretization. A profile name can be empty.
4408  *          Length of this and of nested sequences is the same as that of \a typesF.
4409  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4410  *          discretization. A localization name can be empty.
4411  *          Length of this and of nested sequences is the same as that of \a typesF.
4412  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4413  *          of ids of tuples within the data array, per each type of spatial
4414  *          discretization within one mesh entity type. 
4415  *          Length of this and of nested sequences is the same as that of \a typesF.
4416  *  \throw If no field is lying on \a mname.
4417  */
4418 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
4419 {
4420   int meshId=0;
4421   if(!mname.empty())
4422     meshId=getMeshIdFromMeshName(mname);
4423   else
4424     if(_field_per_mesh.empty())
4425       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4426   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4427 }
4428
4429 /*!
4430  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4431  * maximal absolute dimension and values returned via the out parameter \a levs are 
4432  * dimensions relative to the maximal absolute dimension. <br>
4433  * This method is designed for MEDFileField1TS instances that have a discretization
4434  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4435  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4436  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4437  * Only these 3 discretizations will be taken into account here. If \a this is
4438  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4439  * This method is useful to make the link between the dimension of the underlying mesh
4440  * and the levels of \a this, because it is possible that the highest dimension of \a this
4441  * field is not equal to the dimension of the underlying mesh.
4442  * 
4443  * Let's consider the following case:
4444  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4445  * TETRA4, HEXA8, TRI3 and SEG2.
4446  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4447  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4448  *
4449  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4450  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4451  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4452  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4453  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4454  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4455  * For example<br>
4456  * to retrieve the highest level of
4457  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4458  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4459  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4460  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4461  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4462  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4463  *          not checked if \a mname == \c NULL).
4464  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4465  *          absolute one. They are in decreasing order. This sequence is cleared before
4466  *          filling it in.
4467  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4468  *  \throw If no field is lying on \a mname.
4469  */
4470 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4471 {
4472   levs.clear();
4473   int meshId=getMeshIdFromMeshName(mname);
4474   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4475   std::vector< std::vector<TypeOfField> > typesF;
4476   std::vector< std::vector<std::string> > pfls, locs;
4477   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4478   if(types.empty())
4479     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4480   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4481   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4482     return -1;
4483   st.erase(INTERP_KERNEL::NORM_ERROR);
4484   std::set<int> ret1;
4485   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4486     {
4487       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4488       ret1.insert((int)cm.getDimension());
4489     }
4490   int ret=*std::max_element(ret1.begin(),ret1.end());
4491   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4492   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4493   return ret;
4494 }
4495
4496 /*!
4497  * \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.
4498  * \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.
4499  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4500  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4501  */
4502 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4503 {
4504   int mid=getMeshIdFromMeshName(mName);
4505   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4506 }
4507
4508 /*!
4509  * \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.
4510  * \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.
4511  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4512  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4513  */
4514 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4515 {
4516   int mid=getMeshIdFromMeshName(mName);
4517   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4518 }
4519
4520 /*!
4521  * \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.
4522  */
4523 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4524 {
4525   if(_field_per_mesh.empty())
4526     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4527   if(mName.empty())
4528     return 0;
4529   std::string mName2(mName);
4530   int ret=0;
4531   std::vector<std::string> msg;
4532   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4533     if(mName2==(*it)->getMeshName())
4534       return ret;
4535     else
4536       msg.push_back((*it)->getMeshName());
4537   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4538   oss << "Possible meshes are : ";
4539   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4540     oss << "\"" << (*it2) << "\" ";
4541   throw INTERP_KERNEL::Exception(oss.str());
4542 }
4543
4544 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4545 {
4546   if(!mesh)
4547     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4548   std::string tmp(mesh->getName());
4549   if(tmp.empty())
4550     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4551   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4552   int i=0;
4553   for(;it!=_field_per_mesh.end();it++,i++)
4554     {
4555       if((*it)->getMeshName()==tmp)
4556         return i;
4557     }
4558   int sz=_field_per_mesh.size();
4559   _field_per_mesh.resize(sz+1);
4560   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4561   return sz;
4562 }
4563
4564 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4565                                                                    MEDFileFieldGlobsReal& glob)
4566 {
4567   bool ret=false;
4568   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4569     {
4570       MEDFileFieldPerMesh *fpm(*it);
4571       if(fpm)
4572         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4573     }
4574   return ret;
4575 }
4576
4577 /*!
4578  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4579  * splitting that leads to single spatial discretization of this.
4580  *
4581  * \sa splitMultiDiscrPerGeoTypes
4582  */
4583 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4584 {
4585   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4586   std::vector< std::vector<TypeOfField> > typesF;
4587   std::vector< std::vector<std::string> > pfls,locs;
4588   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4589   std::set<TypeOfField> allEnt;
4590   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4591     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4592       allEnt.insert(*it2);
4593   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4594   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4595   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4596     {
4597       std::vector< std::pair<int,int> > its;
4598       ret[i]=shallowCpy();
4599       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4600       ret[i]->updateData(newLgth,its);
4601     }
4602   return ret;
4603 }
4604
4605 /*!
4606  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4607  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4608  *
4609  * \sa splitDiscretizations
4610  */
4611 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4612 {
4613   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4614   std::vector< std::vector<TypeOfField> > typesF;
4615   std::vector< std::vector<std::string> > pfls,locs;
4616   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4617   std::set<TypeOfField> allEnt;
4618   std::size_t nbOfMDPGT(0),ii(0);
4619   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4620     {
4621       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4622       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4623         allEnt.insert(*it2);
4624     }
4625   if(allEnt.size()!=1)
4626     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4627   if(nbOfMDPGT==0)
4628     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4629   if(nbOfMDPGT==1)
4630     {
4631       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4632       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4633       return ret0;
4634     }
4635   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4636   for(std::size_t i=0;i<nbOfMDPGT;i++)
4637     {
4638       std::vector< std::pair<int,int> > its;
4639       ret[i]=shallowCpy();
4640       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4641       ret[i]->updateData(newLgth,its);
4642     }
4643   return ret;
4644 }
4645
4646 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4647 {
4648   int globalCounter(0);
4649   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4650     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4651   return globalCounter;
4652 }
4653
4654 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4655 {
4656   int globalCounter(0);
4657   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4658     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4659   return globalCounter;
4660 }
4661
4662 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4663 {
4664   if(_nb_of_tuples_to_be_allocated>=0)
4665     {
4666       _nb_of_tuples_to_be_allocated=newLgth;
4667       const DataArray *oldArr(getUndergroundDataArray());
4668       if(oldArr)
4669         {
4670           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4671           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4672           setArray(newArr);
4673           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4674         }
4675       return ;
4676     }
4677   if(_nb_of_tuples_to_be_allocated==-1)
4678     return ;
4679   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4680     {
4681       const DataArray *oldArr(getUndergroundDataArray());
4682       if(!oldArr || !oldArr->isAllocated())
4683         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4684       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4685       newArr->alloc(newLgth,getNumberOfComponents());
4686       if(oldArr)
4687         newArr->copyStringInfoFrom(*oldArr);
4688       int pos=0;
4689       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4690         {
4691           if((*it).second<(*it).first)
4692             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4693           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4694           pos+=(*it).second-(*it).first;
4695         }
4696       setArray(newArr);
4697       return ;
4698     }
4699   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4700 }
4701
4702 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4703 {
4704   if(_field_per_mesh.empty())
4705     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4706   if(_field_per_mesh.size()>1)
4707     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4708   _field_per_mesh[0]->copyOptionsFrom(opts);
4709   _field_per_mesh[0]->writeLL(fid,nasc);
4710 }
4711
4712 /*!
4713  * 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.
4714  * If false is returned the memory allocation is not required.
4715  */
4716 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4717 {
4718   if(_nb_of_tuples_to_be_allocated>=0)
4719     {
4720       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4721       _nb_of_tuples_to_be_allocated=-2;
4722       return true;
4723     }
4724   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4725     return false;
4726   if(_nb_of_tuples_to_be_allocated==-1)
4727     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4728   if(_nb_of_tuples_to_be_allocated<-3)
4729     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4730   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4731 }
4732
4733 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4734 {
4735   med_int numdt,numit;
4736   med_float dt;
4737   med_int nmesh;
4738   med_bool localMesh;
4739   med_int meshnumdt,meshnumit;
4740   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4741   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4742   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4743   if(_iteration!=numdt || _order!=numit)
4744     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4745   _field_per_mesh.resize(nmesh);
4746   //
4747   MEDFileMesh *mm(0);
4748   if(ms)
4749     {
4750       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4751       mm=ms->getMeshWithName(meshNameCpp);
4752     }
4753   //
4754   for(int i=0;i<nmesh;i++)
4755     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4756   _nb_of_tuples_to_be_allocated=0;
4757   for(int i=0;i<nmesh;i++)
4758     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4759 }
4760
4761 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4762 {
4763   allocIfNecessaryTheArrayToReceiveDataFromFile();
4764   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4765     (*it)->loadBigArraysRecursively(fid,nasc);
4766 }
4767
4768 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4769 {
4770   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4771     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4772       (*it)->loadBigArraysRecursively(fid,nasc);
4773 }
4774
4775 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4776 {
4777   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4778   loadBigArraysRecursively(fid,nasc);
4779 }
4780
4781 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4782 {
4783   DataArray *thisArr(getUndergroundDataArray());
4784   if(thisArr && thisArr->isAllocated())
4785     {
4786       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4787       thisArr->desallocate();
4788     }
4789 }
4790
4791 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4792 {
4793   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4794 }
4795
4796 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4797 {
4798   std::vector<const BigMemoryObject *> ret;
4799   if(getUndergroundDataArray())
4800     ret.push_back(getUndergroundDataArray());
4801   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4802     ret.push_back((const MEDFileFieldPerMesh *)*it);
4803   return ret;
4804 }
4805
4806 /*!
4807  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4808  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4809  * "Sort By Type"), if not, an exception is thrown. 
4810  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4811  *  \param [in] arr - the array of values.
4812  *  \param [in,out] glob - the global data where profiles and localization present in
4813  *          \a field, if any, are added.
4814  *  \throw If the name of \a field is empty.
4815  *  \throw If the data array of \a field is not set.
4816  *  \throw If \a this->_arr is already allocated but has different number of components
4817  *         than \a field.
4818  *  \throw If the underlying mesh of \a field has no name.
4819  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4820  */
4821 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4822 {
4823   const MEDCouplingMesh *mesh=field->getMesh();
4824   //
4825   TypeOfField type=field->getTypeOfField();
4826   std::vector<DataArrayInt *> dummy;
4827   int start=copyTinyInfoFrom(field,arr);
4828   int pos=addNewEntryIfNecessary(mesh);
4829   if(type!=ON_NODES)
4830     {
4831       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4832       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4833     }
4834   else
4835     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4836 }
4837
4838 /*!
4839  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4840  * of a given mesh are used as the support of the given field (a real support is not used). 
4841  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4842  * Order of underlying mesh entities of the given field specified by \a profile parameter
4843  * is not prescribed; this method permutes field values to have them sorted by element
4844  * type as required for writing to MED file. A new profile is added only if no equal
4845  * profile is missing. 
4846  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4847  *  \param [in] arrOfVals - the values of the field \a field used.
4848  *  \param [in] mesh - the supporting mesh of \a field.
4849  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4850  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4851  *  \param [in,out] glob - the global data where profiles and localization present in
4852  *          \a field, if any, are added.
4853  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4854  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4855  *  \throw If the data array of \a field is not set.
4856  *  \throw If \a this->_arr is already allocated but has different number of components
4857  *         than \a field.
4858  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4859  *  \sa setFieldNoProfileSBT()
4860  */
4861 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4862 {
4863   if(!field)
4864     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4865   if(!arrOfVals || !arrOfVals->isAllocated())
4866     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4867   TypeOfField type=field->getTypeOfField();
4868   std::vector<DataArrayInt *> idsInPflPerType;
4869   std::vector<DataArrayInt *> idsPerType;
4870   std::vector<int> code,code2;
4871   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4872   if(type!=ON_NODES)
4873     {
4874       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4875       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4876       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4877       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4878       // start of check
4879       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4880       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4881       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4882         {
4883           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4884           throw INTERP_KERNEL::Exception(oss.str());
4885         }
4886       // end of check
4887       int start=copyTinyInfoFrom(field,arrOfVals);
4888       code2=m->getDistributionOfTypes();
4889       //
4890       int pos=addNewEntryIfNecessary(m);
4891       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4892     }
4893   else
4894     {
4895       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4896         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4897       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4898       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4899       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4900       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4901         {
4902           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4903           throw INTERP_KERNEL::Exception(oss.str());
4904         }
4905       int start=copyTinyInfoFrom(field,arrOfVals);
4906       int pos=addNewEntryIfNecessary(m);
4907       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4908     }
4909 }
4910
4911 /*!
4912  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4913  */
4914 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4915 {
4916   if(_nb_of_tuples_to_be_allocated>=0)
4917     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 !");
4918   DataArray *arr(getOrCreateAndGetArray());
4919   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4920   _nb_of_tuples_to_be_allocated=-3;
4921 }
4922
4923 /*!
4924  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4925  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4926  * larger by the size of \a field. Returns an id of the first not filled
4927  * tuple of \a this->_arr.
4928  *  \param [in] field - the field to copy the info on components and the name from.
4929  *  \return int - the id of first not initialized tuple of \a this->_arr.
4930  *  \throw If the name of \a field is empty.
4931  *  \throw If the data array of \a field is not set.
4932  *  \throw If \a this->_arr is already allocated but has different number of components
4933  *         than \a field.
4934  */
4935 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4936 {
4937   if(!field)
4938     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4939   std::string name(field->getName());
4940   setName(name.c_str());
4941   setDtUnit(field->getTimeUnit());
4942   if(name.empty())
4943     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4944   if(!arr)
4945     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4946   if(!arr->isAllocated())
4947     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4948   _dt=field->getTime(_iteration,_order);
4949   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4950   if(!getOrCreateAndGetArray()->isAllocated())
4951     {
4952       allocNotFromFile(arr->getNumberOfTuples());
4953       return 0;
4954     }
4955   else
4956     {
4957       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4958       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4959       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4960       _nb_of_tuples_to_be_allocated=-3;
4961       return oldNbOfTuples;
4962     }
4963 }
4964
4965 /*!
4966  * Returns number of components in \a this field
4967  *  \return int - the number of components.
4968  */
4969 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4970 {
4971   return getOrCreateAndGetArray()->getNumberOfComponents();
4972 }
4973
4974 /*!
4975  * Change info on components in \a this.
4976  * \throw If size of \a infos is not equal to the number of components already in \a this.
4977  */
4978 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4979 {
4980   DataArray *arr=getOrCreateAndGetArray();
4981   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4982 }
4983
4984 /*!
4985  * Returns info on components of \a this field.
4986  *  \return const std::vector<std::string>& - a sequence of strings each being an
4987  *          information on _i_-th component.
4988  */
4989 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4990 {
4991   const DataArray *arr=getOrCreateAndGetArray();
4992   return arr->getInfoOnComponents();
4993 }
4994
4995 /*!
4996  * Returns a mutable info on components of \a this field.
4997  *  \return std::vector<std::string>& - a sequence of strings each being an
4998  *          information on _i_-th component.
4999  */
5000 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5001 {
5002   DataArray *arr=getOrCreateAndGetArray();
5003   return arr->getInfoOnComponents();
5004 }
5005
5006 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5007 {
5008   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5009     {
5010       const MEDFileFieldPerMesh *fpm(*it);
5011       if(!fpm)
5012         continue;
5013       if(fpm->presenceOfMultiDiscPerGeoType())
5014         return true;
5015     }
5016   return false;
5017 }
5018
5019 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5020 {
5021   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5022     if((*it).isNotNull())
5023       if((*it)->presenceOfStructureElements())
5024         return true;
5025   return false;
5026 }
5027
5028 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5029 {
5030   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5031     if((*it).isNotNull())
5032       if(!(*it)->onlyStructureElements())
5033         return false;
5034   return true;
5035 }
5036
5037 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5038 {
5039   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5040     if((*it).isNotNull())
5041       (*it)->killStructureElements();
5042 }
5043
5044 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5045 {
5046   static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with  \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
5047   if(_field_per_mesh.empty())
5048     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5049   if(_field_per_mesh.size()>1)
5050     throw INTERP_KERNEL::Exception(MSG0);
5051   if(_field_per_mesh[0].isNull())
5052     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5053   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5054   std::set<TypeOfField> types;
5055   pm->fillTypesOfFieldAvailable(types);
5056   if(types.size()!=1)
5057     throw INTERP_KERNEL::Exception(MSG0);
5058   TypeOfField type(*types.begin());
5059   int meshDimRelToMax(0);
5060   if(type==ON_NODES)
5061     meshDimRelToMax=0;
5062   else
5063     {
5064       int myDim(std::numeric_limits<int>::max());
5065       bool isUnique(pm->isUniqueLevel(myDim));
5066       if(!isUnique)
5067         throw INTERP_KERNEL::Exception(MSG0);
5068       meshDimRelToMax=myDim-mesh->getMeshDimension();
5069       if(meshDimRelToMax>0)
5070         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5071     }
5072   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5073 }
5074
5075 /*!
5076  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5077  *  \param [in] type - a spatial discretization of the new field.
5078  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5079  *  \param [in] mName - a name of the supporting mesh.
5080  *  \param [in] renumPol - specifies how to permute values of the result field according to
5081  *          the optional numbers of cells and nodes, if any. The valid values are
5082  *          - 0 - do not permute.
5083  *          - 1 - permute cells.
5084  *          - 2 - permute nodes.
5085  *          - 3 - permute cells and nodes.
5086  *
5087  *  \param [in] glob - the global data storing profiles and localization.
5088  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5089  *          caller is to delete this field using decrRef() as it is no more needed. 
5090  *  \throw If the MED file is not readable.
5091  *  \throw If there is no mesh named \a mName in the MED file.
5092  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5093  *  \throw If no field of \a this is lying on the mesh \a mName.
5094  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5095  */
5096 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5097 {
5098   MCAuto<MEDFileMesh> mm;
5099   if(mName.empty())
5100     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5101   else
5102     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5103   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5104 }
5105
5106 /*!
5107  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5108  *  \param [in] type - a spatial discretization of the new field.
5109  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5110  *  \param [in] renumPol - specifies how to permute values of the result field according to
5111  *          the optional numbers of cells and nodes, if any. The valid values are
5112  *          - 0 - do not permute.
5113  *          - 1 - permute cells.
5114  *          - 2 - permute nodes.
5115  *          - 3 - permute cells and nodes.
5116  *
5117  *  \param [in] glob - the global data storing profiles and localization.
5118  *  \param [in] mesh - the supporting mesh.
5119  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5120  *          caller is to delete this field using decrRef() as it is no more needed. 
5121  *  \throw If the MED file is not readable.
5122  *  \throw If no field of \a this is lying on \a mesh.
5123  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5124  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5125  */
5126 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5127 {
5128   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5129   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5130   if(meshDimRelToMax==1)
5131     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5132   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5133 }
5134
5135 /*!
5136  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5137  * given mesh. 
5138  *  \param [in] type - a spatial discretization of the new field.
5139  *  \param [in] mName - a name of the supporting mesh.
5140  *  \param [in] renumPol - specifies how to permute values of the result field according to
5141  *          the optional numbers of cells and nodes, if any. The valid values are
5142  *          - 0 - do not permute.
5143  *          - 1 - permute cells.
5144  *          - 2 - permute nodes.
5145  *          - 3 - permute cells and nodes.
5146  *
5147  *  \param [in] glob - the global data storing profiles and localization.
5148  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5149  *          caller is to delete this field using decrRef() as it is no more needed. 
5150  *  \throw If the MED file is not readable.
5151  *  \throw If there is no mesh named \a mName in the MED file.
5152  *  \throw If there are no mesh entities in the mesh.
5153  *  \throw If no field values of the given \a type are available.
5154  */
5155 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5156 {
5157   MCAuto<MEDFileMesh> mm;
5158   if(mName.empty())
5159     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5160   else
5161     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5162   int absDim=getDimension();
5163   int meshDimRelToMax=absDim-mm->getMeshDimension();
5164   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5165 }
5166
5167 /*!
5168  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5169  *  \param [in] type - a spatial discretization of the new field.
5170  *  \param [in] renumPol - specifies how to permute values of the result field according to
5171  *          the optional numbers of cells and nodes, if any. The valid values are
5172  *          - 0 - do not permute.
5173  *          - 1 - permute cells.
5174  *          - 2 - permute nodes.
5175  *          - 3 - permute cells and nodes.
5176  *
5177  *  \param [in] glob - the global data storing profiles and localization.
5178  *  \param [in] mesh - the supporting mesh.
5179  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5180  *         field according to \a renumPol.
5181  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5182  *         field according to \a renumPol.
5183  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5184  *          caller is to delete this field using decrRef() as it is no more needed. 
5185  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5186  *  \throw If no field of \a this is lying on \a mesh.
5187  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5188  */
5189 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5190 {
5191   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5192   int meshId=getMeshIdFromMeshName(mesh->getName());
5193   bool isPfl=false;
5194   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5195   switch(renumPol)
5196   {
5197     case 0:
5198       {
5199         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5200         return ret.retn();
5201       }
5202     case 3:
5203     case 1:
5204       {
5205         if(isPfl)
5206           throw INTERP_KERNEL::Exception(msg1);
5207         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5208         if(cellRenum)
5209           {
5210             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5211               {
5212                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5213                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5214                 throw INTERP_KERNEL::Exception(oss.str());
5215               }
5216             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5217             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5218             std::vector<DataArray *> arrOut2(1,arrOut);
5219             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5220             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5221             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5222           }
5223         if(renumPol==1)
5224           return ret.retn();
5225       }
5226     case 2:
5227       {
5228         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5229         if(isPfl)
5230           throw INTERP_KERNEL::Exception(msg1);
5231         if(nodeRenum)
5232           {
5233             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5234               {
5235                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5236                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5237                 throw INTERP_KERNEL::Exception(oss.str());
5238               }
5239             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5240             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5241               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5242             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5243           }
5244         return ret.retn();
5245       }
5246     default:
5247       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5248   }
5249 }
5250
5251 /*!
5252  * Returns values and a profile of the field of a given type lying on a given support.
5253  *  \param [in] type - a spatial discretization of the field.
5254  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5255  *  \param [in] mesh - the supporting mesh.
5256  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5257  *          field of interest lies on. If the field lies on all entities of the given
5258  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5259  *          using decrRef() as it is no more needed.  
5260  *  \param [in] glob - the global data storing profiles and localization.
5261  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5262  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5263  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5264  *  \throw If no field of \a this is lying on \a mesh.
5265  *  \throw If no field values of the given \a type are available.
5266  */
5267 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5268 {
5269   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5270   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5271   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5272   ret->setName(nasc.getName().c_str());
5273   return ret.retn();
5274 }
5275
5276 //= MEDFileField1TSWithoutSDA
5277
5278 /*!
5279  * Throws if a given value is not a valid (non-extended) relative dimension.
5280  *  \param [in] meshDimRelToMax - the relative dimension value.
5281  *  \throw If \a meshDimRelToMax > 0.
5282  */
5283 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5284 {
5285   if(meshDimRelToMax>0)
5286     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5287 }
5288
5289 /*!
5290  * Checks if elements of a given mesh are in the order suitable for writing 
5291  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5292  * vector describing types of elements and their number.
5293  *  \param [in] mesh - the mesh to check.
5294  *  \return std::vector<int> - a vector holding for each element type (1) item of
5295  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5296  *          These values are in full-interlace mode.
5297  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5298  */
5299 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5300 {
5301   if(!mesh)
5302     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5303   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5304   int nbOfTypes=geoTypes.size();
5305   std::vector<int> code(3*nbOfTypes);
5306   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5307   arr1->alloc(nbOfTypes,1);
5308   int *arrPtr=arr1->getPointer();
5309   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5310   for(int i=0;i<nbOfTypes;i++,it++)
5311     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5312   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5313   const int *arrPtr2=arr2->getConstPointer();
5314   int i=0;
5315   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5316     {
5317       int pos=arrPtr2[i];
5318       int nbCells=mesh->getNumberOfCellsWithType(*it);
5319       code[3*pos]=(int)(*it);
5320       code[3*pos+1]=nbCells;
5321       code[3*pos+2]=-1;//no profiles
5322     }
5323   std::vector<const DataArrayInt *> idsPerType;//no profiles
5324   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5325   if(da)
5326     {
5327       da->decrRef();
5328       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5329     }
5330   return code;
5331 }
5332
5333 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5334 {
5335   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5336 }
5337
5338 /*!
5339  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5340  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5341  * item of every of returned sequences refers to the _i_-th part of \a this field.
5342  * Thus all sequences returned by this method are of the same length equal to number
5343  * of different types of supporting entities.<br>
5344  * A field part can include sub-parts with several different spatial discretizations,
5345  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5346  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5347  * of a nested sequence corresponds to a type of spatial discretization.<br>
5348  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5349  * The overhead is due to selecting values into new instances of DataArrayDouble.
5350  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5351  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5352  *          not checked if \a mname == \c NULL).
5353  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5354  *          a field part is returned. 
5355  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5356  *          A field part can include sub-parts with several different spatial discretizations,
5357  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5358  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5359  *          This sequence is of the same length as \a types. 
5360  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5361  *          discretization. A profile name can be empty.
5362  *          Length of this and of nested sequences is the same as that of \a typesF.
5363  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5364  *          discretization. A localization name can be empty.
5365  *          Length of this and of nested sequences is the same as that of \a typesF.
5366  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5367  *          per each type of spatial discretization within one mesh entity type.
5368  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5369  *          Length of this and of nested sequences is the same as that of \a typesF.
5370  *  \throw If no field is lying on \a mname.
5371  */
5372 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5373 {
5374   int meshId=0;
5375   if(!mname.empty())
5376     meshId=getMeshIdFromMeshName(mname);
5377   else
5378     if(_field_per_mesh.empty())
5379       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5380   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5381   int nbOfRet=ret0.size();
5382   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5383   for(int i=0;i<nbOfRet;i++)
5384     {
5385       const std::vector< std::pair<int,int> >& p=ret0[i];
5386       int nbOfRet1=p.size();
5387       ret[i].resize(nbOfRet1);
5388       for(int j=0;j<nbOfRet1;j++)
5389         {
5390           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5391           ret[i][j]=tmp;
5392         }
5393     }
5394   return ret;
5395 }
5396
5397 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5398 {
5399   return TYPE_STR;
5400 }
5401
5402 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5403 {
5404   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5405   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5406   ret->deepCpyLeavesFrom(*this);
5407   const DataArrayDouble *arr(_arr);
5408   if(arr)
5409     {
5410       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5411       ret->setArray(arr2);
5412     }
5413   return ret.retn();
5414 }
5415
5416 /*!
5417  * Returns a pointer to the underground DataArrayDouble instance and a
5418  * sequence describing parameters of a support of each part of \a this field. The
5419  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5420  * direct access to the field values. This method is intended for the field lying on one
5421  * mesh only.
5422  *  \param [in,out] entries - the sequence describing parameters of a support of each
5423  *         part of \a this field. Each item of this sequence consists of two parts. The
5424  *         first part describes a type of mesh entity and an id of discretization of a
5425  *         current field part. The second part describes a range of values [begin,end)
5426  *         within the returned array relating to the current field part.
5427  *  \return DataArrayDouble * - the pointer to the field values array.
5428  *  \throw If the number of underlying meshes is not equal to 1.
5429  *  \throw If no field values are available.
5430  *  \sa getUndergroundDataArray()
5431  */
5432 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5433 {
5434   if(_field_per_mesh.size()!=1)
5435     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5436   if(_field_per_mesh[0]==0)
5437     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5438   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5439   return getUndergroundDataArrayTemplate();
5440 }
5441
5442 /*!
5443  * Returns a pointer to the underground DataArrayDouble instance and a
5444  * sequence describing parameters of a support of each part of \a this field. The
5445  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5446  * direct access to the field values. This method is intended for the field lying on one
5447  * mesh only.
5448  *  \param [in,out] entries - the sequence describing parameters of a support of each
5449  *         part of \a this field. Each item of this sequence consists of two parts. The
5450  *         first part describes a type of mesh entity and an id of discretization of a
5451  *         current field part. The second part describes a range of values [begin,end)
5452  *         within the returned array relating to the current field part.
5453  *  \return DataArrayDouble * - the pointer to the field values array.
5454  *  \throw If the number of underlying meshes is not equal to 1.
5455  *  \throw If no field values are available.
5456  *  \sa getUndergroundDataArray()
5457  */
5458 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5459 {
5460   return getUndergroundDataArrayDoubleExt(entries);
5461 }
5462
5463 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5464 {
5465   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5466   arr->setInfoAndChangeNbOfCompo(infos);
5467 }
5468
5469 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5470 {
5471 }
5472
5473 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5474 {
5475   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5476   ret->deepCpyLeavesFrom(*this);
5477   return ret.retn();
5478 }
5479
5480 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5481 {
5482   MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5483   if(_arr.isNotNull())
5484     ret->_arr=_arr->deepCopy();
5485   return ret.retn();
5486 }
5487
5488 //= MEDFileIntField1TSWithoutSDA
5489
5490 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5491 {
5492   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5493 }
5494
5495 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5496 {
5497 }
5498
5499 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5500                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5501 {
5502   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5503   arr->setInfoAndChangeNbOfCompo(infos);
5504 }
5505
5506 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5507 {
5508   return TYPE_STR;
5509 }
5510
5511 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5512 {
5513   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5514   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5515   ret->deepCpyLeavesFrom(*this);
5516   const DataArrayInt *arr(_arr);
5517   if(arr)
5518     {
5519       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5520       ret->setArray(arr2);
5521     }
5522   return ret.retn();
5523 }
5524
5525 /*!
5526  * Returns a pointer to the underground DataArrayInt instance and a
5527  * sequence describing parameters of a support of each part of \a this field. The
5528  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5529  * direct access to the field values. This method is intended for the field lying on one
5530  * mesh only.
5531  *  \param [in,out] entries - the sequence describing parameters of a support of each
5532  *         part of \a this field. Each item of this sequence consists of two parts. The
5533  *         first part describes a type of mesh entity and an id of discretization of a
5534  *         current field part. The second part describes a range of values [begin,end)
5535  *         within the returned array relating to the current field part.
5536  *  \return DataArrayInt * - the pointer to the field values array.
5537  *  \throw If the number of underlying meshes is not equal to 1.
5538  *  \throw If no field values are available.
5539  *  \sa getUndergroundDataArray()
5540  */
5541 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5542 {
5543   return getUndergroundDataArrayIntExt(entries);
5544 }
5545
5546 /*!
5547  * Returns a pointer to the underground DataArrayInt instance and a
5548  * sequence describing parameters of a support of each part of \a this field. The
5549  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5550  * direct access to the field values. This method is intended for the field lying on one
5551  * mesh only.
5552  *  \param [in,out] entries - the sequence describing parameters of a support of each
5553  *         part of \a this field. Each item of this sequence consists of two parts. The
5554  *         first part describes a type of mesh entity and an id of discretization of a
5555  *         current field part. The second part describes a range of values [begin,end)
5556  *         within the returned array relating to the current field part.
5557  *  \return DataArrayInt * - the pointer to the field values array.
5558  *  \throw If the number of underlying meshes is not equal to 1.
5559  *  \throw If no field values are available.
5560  *  \sa getUndergroundDataArray()
5561  */
5562 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5563 {
5564   if(_field_per_mesh.size()!=1)
5565     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5566   if(_field_per_mesh[0]==0)
5567     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5568   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5569   return getUndergroundDataArrayTemplate();
5570 }
5571
5572 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5573 {
5574   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5575   ret->deepCpyLeavesFrom(*this);
5576   return ret.retn();
5577 }
5578
5579 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5580 {
5581   MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5582   if(_arr.isNotNull())
5583     ret->_arr=_arr->deepCopy();
5584   return ret.retn();
5585 }
5586
5587 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5588 {
5589 }
5590
5591 //= MEDFileAnyTypeField1TS
5592
5593 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5594 {
5595   med_field_type typcha;
5596   //
5597   std::vector<std::string> infos;
5598   std::string dtunit,fieldName;
5599   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5600   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5601   switch(typcha)
5602   {
5603     case MED_FLOAT64:
5604       {
5605         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5606         break;
5607       }
5608     case MED_INT32:
5609       {
5610         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5611         break;
5612       }
5613     default:
5614       {
5615         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5616         throw INTERP_KERNEL::Exception(oss.str());
5617       }
5618   }
5619   ret->setDtUnit(dtunit.c_str());
5620   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5621   //
5622   med_int numdt,numit;
5623   med_float dt;
5624   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5625   ret->setTime(numdt,numit,dt);
5626   ret->_csit=1;
5627   if(loadAll)
5628     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5629   else
5630     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5631   return ret.retn();
5632 }
5633
5634 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5635 try:MEDFileFieldGlobsReal(fid)
5636 {
5637   _content=BuildContentFrom(fid,loadAll,ms);
5638   loadGlobals(fid);
5639 }
5640 catch(INTERP_KERNEL::Exception& e)
5641 {
5642     throw e;
5643 }
5644
5645 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5646 {
5647   med_field_type typcha;
5648   std::vector<std::string> infos;
5649   std::string dtunit;
5650   int iii=-1;
5651   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5652   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5653   switch(typcha)
5654   {
5655     case MED_FLOAT64:
5656       {
5657         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5658         break;
5659       }
5660     case MED_INT32:
5661       {
5662         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5663         break;
5664       }
5665     default:
5666       {
5667         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5668         throw INTERP_KERNEL::Exception(oss.str());
5669       }
5670   }
5671   ret->setDtUnit(dtunit.c_str());
5672   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5673   //
5674   if(nbSteps<1)
5675     {
5676       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5677       throw INTERP_KERNEL::Exception(oss.str());
5678     }
5679   //
5680   med_int numdt,numit;
5681   med_float dt;
5682   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5683   ret->setTime(numdt,numit,dt);
5684   ret->_csit=1;
5685   if(loadAll)
5686     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5687   else
5688     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5689   return ret.retn();
5690 }
5691
5692 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5693 try:MEDFileFieldGlobsReal(fid)
5694 {
5695   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5696   loadGlobals(fid);
5697 }
5698 catch(INTERP_KERNEL::Exception& e)
5699 {
5700     throw e;
5701 }
5702
5703 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5704 {
5705   if(!c)
5706     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5707   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5708     {
5709       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5710       ret->_content=c; c->incrRef();
5711       return ret.retn();
5712     }
5713   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5714     {
5715       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5716       ret->_content=c; c->incrRef();
5717       return ret.retn();
5718     }
5719   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5720 }
5721
5722 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5723 {
5724   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5725   ret->setFileName(FileNameFromFID(fid));
5726   return ret;
5727 }
5728
5729 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5730 {
5731   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5732   return New(fid,loadAll);
5733 }
5734
5735 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5736 {
5737   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5738   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5739   ret->loadGlobals(fid);
5740   return ret.retn();
5741 }
5742
5743 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5744 {
5745   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5746   return New(fid,fieldName,loadAll);
5747 }
5748
5749 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5750 {
5751   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5752   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5753   ret->loadGlobals(fid);
5754   return ret.retn();
5755 }
5756
5757 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5758 {
5759   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5760   return New(fid,fieldName,iteration,order,loadAll);
5761 }
5762
5763 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5764 {
5765   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5766   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5767   ret->loadGlobals(fid);
5768   return ret.retn();
5769 }
5770
5771 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5772 {
5773   med_field_type typcha;
5774   std::vector<std::string> infos;
5775   std::string dtunit;
5776   int iii(-1);
5777   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5778   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5779   switch(typcha)
5780   {
5781     case MED_FLOAT64:
5782       {
5783         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5784         break;
5785       }
5786     case MED_INT32:
5787       {
5788         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5789         break;
5790       }
5791     default:
5792       {
5793         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5794         throw INTERP_KERNEL::Exception(oss.str());
5795       }
5796   }
5797   ret->setDtUnit(dtunit.c_str());
5798   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5799   //
5800   bool found=false;
5801   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5802   for(int i=0;i<nbOfStep2 && !found;i++)
5803     {
5804       med_int numdt,numit;
5805       med_float dt;
5806       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5807       if(numdt==iteration && numit==order)
5808         {
5809           found=true;
5810           ret->_csit=i+1;
5811         }
5812       else
5813         dtits[i]=std::pair<int,int>(numdt,numit);
5814     }
5815   if(!found)
5816     {
5817       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5818       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5819         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5820       throw INTERP_KERNEL::Exception(oss.str());
5821     }
5822   if(loadAll)
5823     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5824   else
5825     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5826   return ret.retn();
5827 }
5828
5829 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5830 try:MEDFileFieldGlobsReal(fid)
5831 {
5832   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5833   loadGlobals(fid);
5834 }
5835 catch(INTERP_KERNEL::Exception& e)
5836 {
5837     throw e;
5838 }
5839
5840 /*!
5841  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5842  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5843  *
5844  * \warning this is a shallow copy constructor
5845  */
5846 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5847 {
5848   if(!shallowCopyOfContent)
5849     {
5850       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5851       otherPtr->incrRef();
5852       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5853     }
5854   else
5855     {
5856       _content=other.shallowCpy();
5857     }
5858 }
5859
5860 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5861 {
5862   if(checkFieldId)
5863     {
5864       int nbFields=MEDnField(fid);
5865       if(fieldIdCFormat>=nbFields)
5866         {
5867           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5868           throw INTERP_KERNEL::Exception(oss.str());
5869         }
5870     }
5871   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5872   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5873   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5874   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5875   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5876   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5877   med_bool localMesh;
5878   int nbOfStep;
5879   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5880   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5881   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5882   infos.clear(); infos.resize(ncomp);
5883   for(int j=0;j<ncomp;j++)
5884     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5885   return nbOfStep;
5886 }
5887
5888 /*!
5889  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5890  * 
5891  * \param [out]
5892  * \return in case of success the number of time steps available for the field with name \a fieldName.
5893  */
5894 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5895 {
5896   int nbFields=MEDnField(fid);
5897   bool found=false;
5898   std::vector<std::string> fns(nbFields);
5899   int nbOfStep2(-1);
5900   for(int i=0;i<nbFields && !found;i++)
5901     {
5902       std::string tmp;
5903       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5904       fns[i]=tmp;
5905       found=(tmp==fieldName);
5906       if(found)
5907         posCFormat=i;
5908     }
5909   if(!found)
5910     {
5911       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5912       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5913         oss << "\"" << *it << "\" ";
5914       throw INTERP_KERNEL::Exception(oss.str());
5915     }
5916   return nbOfStep2;
5917 }
5918
5919 /*!
5920  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5921  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5922  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5923  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5924  * to keep a valid instance.
5925  * 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.
5926  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5927  * 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.
5928  *
5929  * \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.
5930  * \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.
5931  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5932  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5933  * \param [in] newLocName is the new localization name.
5934  * \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.
5935  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5936  */
5937 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5938 {
5939   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5940   std::string oldPflName=disc->getProfile();
5941   std::vector<std::string> vv=getPflsReallyUsedMulti();
5942   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5943   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5944     {
5945       disc->setProfile(newPflName);
5946       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5947       pfl->setName(newPflName);
5948     }
5949   else
5950     {
5951       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5952       throw INTERP_KERNEL::Exception(oss.str());
5953     }
5954 }
5955
5956 /*!
5957  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5958  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5959  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5960  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5961  * to keep a valid instance.
5962  * 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.
5963  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5964  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5965  * 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.
5966  *
5967  * \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.
5968  * \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.
5969  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5970  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5971  * \param [in] newLocName is the new localization name.
5972  * \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.
5973  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5974  */
5975 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5976 {
5977   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5978   std::string oldLocName=disc->getLocalization();
5979   std::vector<std::string> vv=getLocsReallyUsedMulti();
5980   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5981   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5982     {
5983       disc->setLocalization(newLocName);
5984       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5985       loc.setName(newLocName);
5986     }
5987   else
5988     {
5989       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5990       throw INTERP_KERNEL::Exception(oss.str());
5991     }
5992 }
5993
5994 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5995 {
5996   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5997   if(!ret)
5998     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5999   return ret;
6000 }
6001
6002 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6003 {
6004   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6005   if(!ret)
6006     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6007   return ret;
6008 }
6009
6010 /*!
6011  * This method alloc the arrays and load potentially huge arrays contained in this field.
6012  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6013  * This method can be also called to refresh or reinit values from a file.
6014  * 
6015  * \throw If the fileName is not set or points to a non readable MED file.
6016  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6017  */
6018 void MEDFileAnyTypeField1TS::loadArrays()
6019 {
6020   if(getFileName().empty())
6021     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6022   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6023   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6024 }
6025
6026 /*!
6027  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6028  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6029  * this method does not throw if \a this does not come from file read.
6030  * 
6031  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6032  */
6033 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6034 {
6035   if(!getFileName().empty())
6036     {
6037       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6038       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6039     }
6040 }
6041
6042 /*!
6043  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6044  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6045  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6046  * 
6047  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6048  */
6049 void MEDFileAnyTypeField1TS::unloadArrays()
6050 {
6051   contentNotNullBase()->unloadArrays();
6052 }
6053
6054 /*!
6055  * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
6056  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6057  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6058  * 
6059  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6060  */
6061 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6062 {
6063   if(!getFileName().empty())
6064     contentNotNullBase()->unloadArrays();
6065 }
6066
6067 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6068 {
6069   int nbComp(getNumberOfComponents());
6070   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6071   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6072   for(int i=0;i<nbComp;i++)
6073     {
6074       std::string info=getInfo()[i];
6075       std::string c,u;
6076       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6077       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6078       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6079     }
6080   if(getName().empty())
6081     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6082   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6083   writeGlobals(fid,*this);
6084   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6085 }
6086
6087 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6088 {
6089   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6090 }
6091
6092 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6093 {
6094   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6095   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6096   return ret;
6097 }
6098
6099 /*!
6100  * Returns a string describing \a this field. This string is outputted 
6101  * by \c print Python command.
6102  */
6103 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6104 {
6105   std::ostringstream oss;
6106   contentNotNullBase()->simpleRepr(0,oss,-1);
6107   simpleReprGlobs(oss);
6108   return oss.str();
6109 }
6110
6111 /*!
6112  * This method returns all profiles whose name is non empty used.
6113  * \b WARNING If profile is used several times it will be reported \b only \b once.
6114  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6115  */
6116 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6117 {
6118   return contentNotNullBase()->getPflsReallyUsed2();
6119 }
6120
6121 /*!
6122  * This method returns all localizations whose name is non empty used.
6123  * \b WARNING If localization is used several times it will be reported \b only \b once.
6124  */
6125 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6126 {
6127   return contentNotNullBase()->getLocsReallyUsed2();
6128 }
6129
6130 /*!
6131  * This method returns all profiles whose name is non empty used.
6132  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6133  */
6134 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6135 {
6136   return contentNotNullBase()->getPflsReallyUsedMulti2();
6137 }
6138
6139 /*!
6140  * This method returns all localizations whose name is non empty used.
6141  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6142  */
6143 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6144 {
6145   return contentNotNullBase()->getLocsReallyUsedMulti2();
6146 }
6147
6148 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6149 {
6150   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6151 }
6152
6153 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6154 {
6155   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6156 }
6157
6158 int MEDFileAnyTypeField1TS::getDimension() const
6159 {
6160   return contentNotNullBase()->getDimension();
6161 }
6162
6163 int MEDFileAnyTypeField1TS::getIteration() const
6164 {
6165   return contentNotNullBase()->getIteration();
6166 }
6167
6168 int MEDFileAnyTypeField1TS::getOrder() const
6169 {
6170   return contentNotNullBase()->getOrder();
6171 }
6172
6173 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6174 {
6175   return contentNotNullBase()->getTime(iteration,order);
6176 }
6177
6178 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6179 {
6180   contentNotNullBase()->setTime(iteration,order,val);
6181 }
6182
6183 std::string MEDFileAnyTypeField1TS::getName() const
6184 {
6185   return contentNotNullBase()->getName();
6186 }
6187
6188 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6189 {
6190   contentNotNullBase()->setName(name);
6191 }
6192
6193 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6194 {
6195   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6196 }
6197
6198 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6199 {
6200   return contentNotNullBase()->getDtUnit();
6201 }
6202
6203 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6204 {
6205   contentNotNullBase()->setDtUnit(dtUnit);
6206 }
6207
6208 std::string MEDFileAnyTypeField1TS::getMeshName() const
6209 {
6210   return contentNotNullBase()->getMeshName();
6211 }
6212
6213 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6214 {
6215   contentNotNullBase()->setMeshName(newMeshName);
6216 }
6217
6218 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6219 {
6220   return contentNotNullBase()->changeMeshNames(modifTab);
6221 }
6222
6223 int MEDFileAnyTypeField1TS::getMeshIteration() const
6224 {
6225   return contentNotNullBase()->getMeshIteration();
6226 }
6227
6228 int MEDFileAnyTypeField1TS::getMeshOrder() const
6229 {
6230   return contentNotNullBase()->getMeshOrder();
6231 }
6232
6233 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6234 {
6235   return contentNotNullBase()->getNumberOfComponents();
6236 }
6237
6238 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6239 {
6240   return contentNotNullBase()->isDealingTS(iteration,order);
6241 }
6242
6243 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6244 {
6245   return contentNotNullBase()->getDtIt();
6246 }
6247
6248 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6249 {
6250   contentNotNullBase()->fillIteration(p);
6251 }
6252
6253 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6254 {
6255   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6256 }
6257
6258 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6259 {
6260   contentNotNullBase()->setInfo(infos);
6261 }
6262
6263 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6264 {
6265   return contentNotNullBase()->getInfo();
6266 }
6267 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6268 {
6269   return contentNotNullBase()->getInfo();
6270 }
6271
6272 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6273 {
6274   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6275 }
6276
6277 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6278 {
6279   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6280 }
6281
6282 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6283 {
6284   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6285 }
6286
6287 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6288 {
6289   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6290 }
6291
6292 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6293 {
6294   return contentNotNullBase()->getTypesOfFieldAvailable();
6295 }
6296
6297 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6298                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6299 {
6300   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6301 }
6302
6303 /*!
6304  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6305  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6306  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6307  */
6308 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6309 {
6310   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6311   if(!content)
6312     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6313   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6314   std::size_t sz(contentsSplit.size());
6315   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6316   for(std::size_t i=0;i<sz;i++)
6317     {
6318       ret[i]=shallowCpy();
6319       ret[i]->_content=contentsSplit[i];
6320     }
6321   return ret;
6322 }
6323
6324 /*!
6325  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6326  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6327  */
6328 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6329 {
6330   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6331   if(!content)
6332     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6333   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6334   std::size_t sz(contentsSplit.size());
6335   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6336   for(std::size_t i=0;i<sz;i++)
6337     {
6338       ret[i]=shallowCpy();
6339       ret[i]->_content=contentsSplit[i];
6340     }
6341   return ret;
6342 }
6343
6344 /*!
6345  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6346  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6347  */
6348 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6349 {
6350   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6351   if(!content)
6352     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6353   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6354   std::size_t sz(contentsSplit.size());
6355   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6356   for(std::size_t i=0;i<sz;i++)
6357     {
6358       ret[i]=shallowCpy();
6359       ret[i]->_content=contentsSplit[i];
6360     }
6361   return ret;
6362 }
6363
6364 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6365 {
6366   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6367   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6368     ret->_content=_content->deepCopy();
6369   ret->deepCpyGlobs(*this);
6370   return ret.retn();
6371 }
6372
6373 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6374 {
6375   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6376 }
6377
6378 //= MEDFileField1TS
6379
6380 /*!
6381  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6382  * the first field that has been read from a specified MED file.
6383  *  \param [in] fileName - the name of the MED file to read.
6384  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6385  *          is to delete this field using decrRef() as it is no more needed.
6386  *  \throw If reading the file fails.
6387  */
6388 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6389 {
6390   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6391   return New(fid,loadAll);
6392 }
6393
6394 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6395 {
6396   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6397   ret->contentNotNull();
6398   return ret.retn();
6399 }
6400
6401 /*!
6402  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6403  * a given field that has been read from a specified MED file.
6404  *  \param [in] fileName - the name of the MED file to read.
6405  *  \param [in] fieldName - the name of the field to read.
6406  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6407  *          is to delete this field using decrRef() as it is no more needed.
6408  *  \throw If reading the file fails.
6409  *  \throw If there is no field named \a fieldName in the file.
6410  */
6411 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6412 {
6413   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6414   return New(fid,fieldName,loadAll);
6415 }
6416
6417 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6418 {
6419   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6420   ret->contentNotNull();
6421   return ret.retn();
6422 }
6423
6424 /*!
6425  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6426  * a given field that has been read from a specified MED file.
6427  *  \param [in] fileName - the name of the MED file to read.
6428  *  \param [in] fieldName - the name of the field to read.
6429  *  \param [in] iteration - the iteration number of a required time step.
6430  *  \param [in] order - the iteration order number of required time step.
6431  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6432  *          is to delete this field using decrRef() as it is no more needed.
6433  *  \throw If reading the file fails.
6434  *  \throw If there is no field named \a fieldName in the file.
6435  *  \throw If the required time step is missing from the file.
6436  */
6437 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6438 {
6439   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6440   return New(fid,fieldName,iteration,order,loadAll);
6441 }
6442
6443 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6444 {
6445   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6446   ret->contentNotNull();
6447   return ret.retn();
6448 }
6449
6450 /*!
6451  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6452  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6453  *
6454  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6455  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6456  * \warning this is a shallow copy constructor
6457  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6458  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6459  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6460  *          is to delete this field using decrRef() as it is no more needed.
6461  */
6462 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6463 {
6464   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6465   ret->contentNotNull();
6466   return ret.retn();
6467 }
6468
6469 /*!
6470  * Returns a new empty instance of MEDFileField1TS.
6471  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6472  *          is to delete this field using decrRef() as it is no more needed.
6473  */
6474 MEDFileField1TS *MEDFileField1TS::New()
6475 {
6476   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6477   ret->contentNotNull();
6478   return ret.retn();
6479 }
6480
6481 /*!
6482  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6483  * following the given input policy.
6484  *
6485  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6486  *                            By default (true) the globals are deeply copied.
6487  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6488  */
6489 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6490 {
6491   MCAuto<MEDFileIntField1TS> ret;
6492   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6493   if(content)
6494     {
6495       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6496       if(!contc)
6497         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6498       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6499       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6500     }
6501   else
6502     ret=MEDFileIntField1TS::New();
6503   if(isDeepCpyGlobs)
6504     ret->deepCpyGlobs(*this);
6505   else
6506     ret->shallowCpyGlobs(*this);
6507   return ret.retn();
6508 }
6509
6510 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6511 {
6512   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6513   if(!pt)
6514     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6515   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6516   if(!ret)
6517     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 !");
6518   return ret;
6519 }
6520
6521 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6522 {
6523   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6524   if(!pt)
6525     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6526   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6527   if(!ret)
6528     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 !");
6529   return ret;
6530 }
6531
6532 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6533 {
6534   if(!f)
6535     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6536   if(arr.isNull())
6537     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6538   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6539   if(!arrOutC)
6540     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6541   f->setArray(arrOutC);
6542 }
6543
6544 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6545 {
6546   if(arr.isNull())
6547     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6548   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6549   if(!arrOutC)
6550     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6551   arrOutC->incrRef();
6552   return arrOutC;
6553 }
6554
6555 /*!
6556  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6557  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6558  *
6559  * \return A new object that the caller is responsible to deallocate.
6560  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6561  */
6562 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6563 {
6564   if(!mm)
6565     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6566   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6567   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6568   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6569     {
6570       if((*it0)!=ON_NODES)
6571         {
6572           std::vector<int> levs;
6573           getNonEmptyLevels(mm->getName(),levs);
6574           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6575             {
6576               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6577               if(it2!=extractDef.end())
6578                 {
6579                   MCAuto<DataArrayInt> t((*it2).second);
6580                   if(t.isNull())
6581                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6582                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6583                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6584                   ret->setFieldNoProfileSBT(fOut);
6585                 }
6586             }
6587         }
6588       else
6589         {
6590           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6591           if(it2==extractDef.end())
6592             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6593           MCAuto<DataArrayInt> t((*it2).second);
6594           if(t.isNull())
6595             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6596           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6597           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6598           DataArrayDouble *arr(f->getArray());
6599           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6600           fOut->setArray(newArr);
6601           ret->setFieldNoProfileSBT(fOut);
6602         }
6603     }
6604   return ret.retn();
6605 }
6606
6607 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6608 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6609 {
6610 }
6611 catch(INTERP_KERNEL::Exception& e)
6612 { throw e; }
6613
6614 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6615 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6616 {
6617 }
6618 catch(INTERP_KERNEL::Exception& e)
6619 { throw e; }
6620
6621 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6622 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6623 {
6624 }
6625 catch(INTERP_KERNEL::Exception& e)
6626 { throw e; }
6627
6628 /*!
6629  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6630  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6631  *
6632  * \warning this is a shallow copy constructor
6633  */
6634 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6635 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6636 {
6637 }
6638 catch(INTERP_KERNEL::Exception& e)
6639 { throw e; }
6640
6641 MEDFileField1TS::MEDFileField1TS()
6642 {
6643   _content=new MEDFileField1TSWithoutSDA;
6644 }
6645
6646 /*!
6647  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6648  * method should be called (getFieldOnMeshAtLevel for example).
6649  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6650  *
6651  * \param [in] mesh - the mesh the field is lying on
6652  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6653  *          caller is to delete this field using decrRef() as it is no more needed. 
6654  */
6655 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6656 {
6657   MCAuto<DataArray> arrOut;
6658   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6659   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6660   return ret.retn();
6661 }
6662
6663 /*!
6664  * Returns a new MEDCouplingFieldDouble of a given type lying on
6665  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6666  * has not been constructed via file reading, an exception is thrown.
6667  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6668  *  \param [in] type - a spatial discretization of interest.
6669  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6670  *  \param [in] renumPol - specifies how to permute values of the result field according to
6671  *          the optional numbers of cells and nodes, if any. The valid values are
6672  *          - 0 - do not permute.
6673  *          - 1 - permute cells.
6674  *          - 2 - permute nodes.
6675  *          - 3 - permute cells and nodes.
6676  *
6677  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6678  *          caller is to delete this field using decrRef() as it is no more needed. 
6679  *  \throw If \a this field has not been constructed via file reading.
6680  *  \throw If the MED file is not readable.
6681  *  \throw If there is no mesh in the MED file.
6682  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6683  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6684  *  \sa getFieldOnMeshAtLevel()
6685  */
6686 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6687 {
6688   if(getFileName().empty())
6689     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6690   MCAuto<DataArray> arrOut;
6691   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6692   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6693   return ret.retn();
6694 }
6695
6696 /*!
6697  * Returns a new MEDCouplingFieldDouble of a given type lying on
6698  * the top level cells of the first mesh in MED file. If \a this field 
6699  * has not been constructed via file reading, an exception is thrown.
6700  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6701  *  \param [in] type - a spatial discretization of interest.
6702  *  \param [in] renumPol - specifies how to permute values of the result field according to
6703  *          the optional numbers of cells and nodes, if any. The valid values are
6704  *          - 0 - do not permute.
6705  *          - 1 - permute cells.
6706  *          - 2 - permute nodes.
6707  *          - 3 - permute cells and nodes.
6708  *
6709  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6710  *          caller is to delete this field using decrRef() as it is no more needed. 
6711  *  \throw If \a this field has not been constructed via file reading.
6712  *  \throw If the MED file is not readable.
6713  *  \throw If there is no mesh in the MED file.
6714  *  \throw If no field values of the given \a type.
6715  *  \throw If no field values lying on the top level support.
6716  *  \sa getFieldAtLevel()
6717  */
6718 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6719 {
6720   if(getFileName().empty())
6721     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6722   MCAuto<DataArray> arrOut;
6723   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6724   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6725   return ret.retn();
6726 }
6727
6728 /*!
6729  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6730  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6731  *  \param [in] type - a spatial discretization of the new field.
6732  *  \param [in] mesh - the supporting mesh.
6733  *  \param [in] renumPol - specifies how to permute values of the result field according to
6734  *          the optional numbers of cells and nodes, if any. The valid values are
6735  *          - 0 - do not permute.
6736  *          - 1 - permute cells.
6737  *          - 2 - permute nodes.
6738  *          - 3 - permute cells and nodes.
6739  *
6740  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6741  *          caller is to delete this field using decrRef() as it is no more needed. 
6742  *  \throw If no field of \a this is lying on \a mesh.
6743  *  \throw If the mesh is empty.
6744  *  \throw If no field values of the given \a type are available.
6745  *  \sa getFieldAtLevel()
6746  *  \sa getFieldOnMeshAtLevel() 
6747  */
6748 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6749 {
6750   MCAuto<DataArray> arrOut;
6751   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6752   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6753   return ret.retn();
6754 }
6755
6756 /*!
6757  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6758  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6759  *  \param [in] type - a spatial discretization of interest.
6760  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6761  *  \param [in] mesh - the supporting mesh.
6762  *  \param [in] renumPol - specifies how to permute values of the result field according to
6763  *          the optional numbers of cells and nodes, if any. The valid values are
6764  *          - 0 - do not permute.
6765  *          - 1 - permute cells.
6766  *          - 2 - permute nodes.
6767  *          - 3 - permute cells and nodes.
6768  *
6769  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6770  *          caller is to delete this field using decrRef() as it is no more needed. 
6771  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6772  *  \throw If no field of \a this is lying on \a mesh.
6773  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6774  *  \sa getFieldAtLevel()
6775  *  \sa getFieldOnMeshAtLevel() 
6776  */
6777 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6778 {
6779   MCAuto<DataArray> arrOut;
6780   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6781   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6782   return ret.retn();
6783 }
6784
6785 /*!
6786  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6787  * This method is called "Old" because in MED3 norm a field has only one meshName
6788  * attached, so this method is for readers of MED2 files. If \a this field 
6789  * has not been constructed via file reading, an exception is thrown.
6790  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6791  *  \param [in] type - a spatial discretization of interest.
6792  *  \param [in] mName - a name of the supporting mesh.
6793  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6794  *  \param [in] renumPol - specifies how to permute values of the result field according to
6795  *          the optional numbers of cells and nodes, if any. The valid values are
6796  *          - 0 - do not permute.
6797  *          - 1 - permute cells.
6798  *          - 2 - permute nodes.
6799  *          - 3 - permute cells and nodes.
6800  *
6801  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6802  *          caller is to delete this field using decrRef() as it is no more needed. 
6803  *  \throw If the MED file is not readable.
6804  *  \throw If there is no mesh named \a mName in the MED file.
6805  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6806  *  \throw If \a this field has not been constructed via file reading.
6807  *  \throw If no field of \a this is lying on the mesh named \a mName.
6808  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6809  *  \sa getFieldAtLevel()
6810  */
6811 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6812 {
6813   if(getFileName().empty())
6814     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6815   MCAuto<DataArray> arrOut;
6816   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6817   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6818   return ret.retn();
6819 }
6820
6821 /*!
6822  * Returns values and a profile of the field of a given type lying on a given support.
6823  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6824  *  \param [in] type - a spatial discretization of the field.
6825  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6826  *  \param [in] mesh - the supporting mesh.
6827  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6828  *          field of interest lies on. If the field lies on all entities of the given
6829  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6830  *          using decrRef() as it is no more needed.  
6831  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6832  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6833  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6834  *  \throw If no field of \a this is lying on \a mesh.
6835  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6836  */
6837 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6838 {
6839   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6840   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6841 }
6842
6843 /*!
6844  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6845  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6846  * "Sort By Type"), if not, an exception is thrown. 
6847  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6848  *  \param [in] field - the field to add to \a this.
6849  *  \throw If the name of \a field is empty.
6850  *  \throw If the data array of \a field is not set.
6851  *  \throw If the data array is already allocated but has different number of components
6852  *         than \a field.
6853  *  \throw If the underlying mesh of \a field has no name.
6854  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6855  */
6856 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6857 {
6858   setFileName("");
6859   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6860 }
6861
6862 /*!
6863  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6864  * can be an aggregation of several MEDCouplingFieldDouble instances.
6865  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6866  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6867  * and \a profile.
6868  *
6869  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6870  * A new profile is added only if no equal profile is missing.
6871  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6872  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6873  *  \param [in] mesh - the supporting mesh of \a field.
6874  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6875  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6876  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6877  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6878  *  \throw If the data array of \a field is not set.
6879  *  \throw If the data array of \a this is already allocated but has different number of
6880  *         components than \a field.
6881  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6882  *  \sa setFieldNoProfileSBT()
6883  */
6884 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6885 {
6886   setFileName("");
6887   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6888 }
6889
6890 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
6891 {
6892   return new MEDFileField1TS(*this);
6893 }
6894
6895 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6896 {
6897   return contentNotNull()->getUndergroundDataArrayTemplate();
6898 }
6899
6900 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6901 {
6902   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6903 }
6904
6905 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6906                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6907 {
6908   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6909 }
6910
6911 //= MEDFileIntField1TS
6912
6913 MEDFileIntField1TS *MEDFileIntField1TS::New()
6914 {
6915   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6916   ret->contentNotNull();
6917   return ret.retn();
6918 }
6919
6920 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6921 {
6922   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6923   return MEDFileIntField1TS::New(fid,loadAll);
6924 }
6925
6926 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6927 {
6928   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6929   ret->contentNotNull();
6930   return ret.retn();
6931 }
6932
6933 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6934 {
6935   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6936   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6937 }
6938
6939 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6940 {
6941   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6942   ret->contentNotNull();
6943   return ret.retn();
6944 }
6945
6946 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6947 {
6948   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6949   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6950 }
6951
6952 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6953 {
6954   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6955   ret->contentNotNull();
6956   return ret.retn();
6957 }
6958
6959 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6960 {
6961   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6962   ret->contentNotNull();
6963   return ret.retn();
6964 }
6965
6966 MEDFileIntField1TS::MEDFileIntField1TS()
6967 {
6968   _content=new MEDFileIntField1TSWithoutSDA;
6969 }
6970
6971 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6972 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6973 {
6974 }
6975 catch(INTERP_KERNEL::Exception& e)
6976 { throw e; }
6977
6978 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6979 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6980 {
6981 }
6982 catch(INTERP_KERNEL::Exception& e)
6983 { throw e; }
6984
6985 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6986 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6987 {
6988 }
6989 catch(INTERP_KERNEL::Exception& e)
6990 { throw e; }
6991
6992 /*!
6993  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6994  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6995  *
6996  * \warning this is a shallow copy constructor
6997  */
6998 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6999 {
7000 }
7001
7002 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7003 {
7004   return new MEDFileIntField1TS(*this);
7005 }
7006
7007 /*!
7008  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7009  * following the given input policy.
7010  *
7011  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7012  *                            By default (true) the globals are deeply copied.
7013  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7014  */
7015 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7016 {
7017   MCAuto<MEDFileField1TS> ret;
7018   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7019   if(content)
7020     {
7021       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7022       if(!contc)
7023         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7024       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7025       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7026     }
7027   else
7028     ret=MEDFileField1TS::New();
7029   if(isDeepCpyGlobs)
7030     ret->deepCpyGlobs(*this);
7031   else
7032     ret->shallowCpyGlobs(*this);
7033   return ret.retn();
7034 }
7035
7036 /*!
7037  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7038  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7039  * "Sort By Type"), if not, an exception is thrown. 
7040  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7041  *  \param [in] field - the field to add to \a this.
7042  *  \throw If the name of \a field is empty.
7043  *  \throw If the data array of \a field is not set.
7044  *  \throw If the data array is already allocated but has different number of components
7045  *         than \a field.
7046  *  \throw If the underlying mesh of \a field has no name.
7047  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7048  */
7049 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7050 {
7051   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7052   setFileName("");
7053   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7054 }
7055
7056 /*!
7057  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7058  * can be an aggregation of several MEDCouplingFieldDouble instances.
7059  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7060  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7061  * and \a profile.
7062  *
7063  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7064  * A new profile is added only if no equal profile is missing.
7065  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7066  *  \param [in] field - the field to add to \a this.
7067  *  \param [in] mesh - the supporting mesh of \a field.
7068  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7069  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7070  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7071  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7072  *  \throw If the data array of \a field is not set.
7073  *  \throw If the data array of \a this is already allocated but has different number of
7074  *         components than \a field.
7075  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7076  *  \sa setFieldNoProfileSBT()
7077  */
7078 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7079 {
7080   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7081   setFileName("");
7082   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7083 }
7084
7085 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7086 {
7087   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7088   if(!pt)
7089     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7090   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7091   if(!ret)
7092     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 !");
7093   return ret;
7094 }
7095
7096 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7097 {
7098   if(getFileName().empty())
7099     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7100   MCAuto<DataArray> arrOut;
7101   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7102   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7103   return ret2.retn();
7104 }
7105
7106 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7107 {
7108   if(arr.isNull())
7109     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7110   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7111   if(!arrC)
7112     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7113   arrC->incrRef();
7114   return arrC;
7115 }
7116
7117 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7118 {
7119   int t1,t2;
7120   double t0(f->getTime(t1,t2));
7121   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7122   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7123   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7124   ret->setTime(t0,t1,t2); ret->setArray(arr2);
7125   return ret.retn();
7126 }
7127
7128 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7129 {
7130   if(!f)
7131     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7132   int t1,t2;
7133   double t0(f->getTime(t1,t2));
7134   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7135   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7136   ret->setTime(t0,t1,t2);
7137   return ret;
7138 }
7139
7140 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7141 {
7142   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7143 }
7144
7145 /*!
7146  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
7147  * method should be called (getFieldOnMeshAtLevel for example).
7148  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7149  *
7150  * \param [in] mesh - the mesh the field is lying on
7151  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7152  *          caller is to delete this field using decrRef() as it is no more needed. 
7153  */
7154 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7155 {
7156   MCAuto<DataArray> arrOut;
7157   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7158   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7159   return ret2.retn();
7160 }
7161
7162 /*!
7163  * Returns a new MEDCouplingFieldInt of a given type lying on
7164  * the top level cells of the first mesh in MED file. If \a this field 
7165  * has not been constructed via file reading, an exception is thrown.
7166  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7167  *  \param [in] type - a spatial discretization of interest.
7168  *  \param [in] renumPol - specifies how to permute values of the result field according to
7169  *          the optional numbers of cells and nodes, if any. The valid values are
7170  *          - 0 - do not permute.
7171  *          - 1 - permute cells.
7172  *          - 2 - permute nodes.
7173  *          - 3 - permute cells and nodes.
7174  *
7175  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7176  *          caller is to delete this field using decrRef() as it is no more needed. 
7177  *  \throw If \a this field has not been constructed via file reading.
7178  *  \throw If the MED file is not readable.
7179  *  \throw If there is no mesh in the MED file.
7180  *  \throw If no field values of the given \a type.
7181  *  \throw If no field values lying on the top level support.
7182  *  \sa getFieldAtLevel()
7183  */
7184 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7185 {
7186   if(getFileName().empty())
7187     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7188   MCAuto<DataArray> arrOut;
7189   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7190   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7191   return ret2.retn();
7192 }
7193
7194 /*!
7195  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7196  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7197  *  \param [in] type - a spatial discretization of the new field.
7198  *  \param [in] mesh - the supporting mesh.
7199  *  \param [in] renumPol - specifies how to permute values of the result field according to
7200  *          the optional numbers of cells and nodes, if any. The valid values are
7201  *          - 0 - do not permute.
7202  *          - 1 - permute cells.
7203  *          - 2 - permute nodes.
7204  *          - 3 - permute cells and nodes.
7205  *
7206  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7207  *          caller is to delete this field using decrRef() as it is no more needed. 
7208  *  \throw If no field of \a this is lying on \a mesh.
7209  *  \throw If the mesh is empty.
7210  *  \throw If no field values of the given \a type are available.
7211  *  \sa getFieldAtLevel()
7212  *  \sa getFieldOnMeshAtLevel() 
7213  */
7214 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7215 {
7216   MCAuto<DataArray> arrOut;
7217   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7218   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7219   return ret2.retn();
7220 }
7221
7222 /*!
7223  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7224  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7225  *  \param [in] type - a spatial discretization of interest.
7226  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7227  *  \param [in] mesh - the supporting mesh.
7228  *  \param [in] renumPol - specifies how to permute values of the result field according to
7229  *          the optional numbers of cells and nodes, if any. The valid values are
7230  *          - 0 - do not permute.
7231  *          - 1 - permute cells.
7232  *          - 2 - permute nodes.
7233  *          - 3 - permute cells and nodes.
7234  *
7235  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7236  *          caller is to delete this field using decrRef() as it is no more needed. 
7237  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7238  *  \throw If no field of \a this is lying on \a mesh.
7239  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7240  *  \sa getFieldAtLevel()
7241  *  \sa getFieldOnMeshAtLevel() 
7242  */
7243 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7244 {
7245   MCAuto<DataArray> arrOut;
7246   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7247   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7248   return ret2.retn();
7249 }
7250
7251 /*!
7252  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7253  * This method is called "Old" because in MED3 norm a field has only one meshName
7254  * attached, so this method is for readers of MED2 files. If \a this field 
7255  * has not been constructed via file reading, an exception is thrown.
7256  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7257  *  \param [in] type - a spatial discretization of interest.
7258  *  \param [in] mName - a name of the supporting mesh.
7259  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7260  *  \param [in] renumPol - specifies how to permute values of the result field according to
7261  *          the optional numbers of cells and nodes, if any. The valid values are
7262  *          - 0 - do not permute.
7263  *          - 1 - permute cells.
7264  *          - 2 - permute nodes.
7265  *          - 3 - permute cells and nodes.
7266  *
7267  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7268  *          caller is to delete this field using decrRef() as it is no more needed. 
7269  *  \throw If the MED file is not readable.
7270  *  \throw If there is no mesh named \a mName in the MED file.
7271  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7272  *  \throw If \a this field has not been constructed via file reading.
7273  *  \throw If no field of \a this is lying on the mesh named \a mName.
7274  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7275  *  \sa getFieldAtLevel()
7276  */
7277 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7278 {
7279   if(getFileName().empty())
7280     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7281   MCAuto<DataArray> arrOut;
7282   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7283   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7284   return ret2.retn();
7285 }
7286
7287 /*!
7288  * Returns values and a profile of the field of a given type lying on a given support.
7289  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7290  *  \param [in] type - a spatial discretization of the field.
7291  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7292  *  \param [in] mesh - the supporting mesh.
7293  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7294  *          field of interest lies on. If the field lies on all entities of the given
7295  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7296  *          using decrRef() as it is no more needed.  
7297  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7298  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7299  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7300  *  \throw If no field of \a this is lying on \a mesh.
7301  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7302  */
7303 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7304 {
7305   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7306   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7307 }
7308
7309 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7310 {
7311   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7312   if(!pt)
7313     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7314   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7315   if(!ret)
7316     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 !");
7317   return ret;
7318 }
7319
7320 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7321 {
7322   return contentNotNull()->getUndergroundDataArrayTemplate();
7323 }
7324
7325 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7326
7327 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7328 {
7329 }
7330
7331 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7332 {
7333 }
7334
7335 /*!
7336  * \param [in] fieldId field id in C mode
7337  */
7338 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7339 {
7340   med_field_type typcha;
7341   std::string dtunitOut;
7342   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7343   setDtUnit(dtunitOut.c_str());
7344   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7345 }
7346
7347 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7348 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7349 {
7350   setDtUnit(dtunit.c_str());
7351   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7352 }
7353 catch(INTERP_KERNEL::Exception& e)
7354 {
7355     throw e;
7356 }
7357
7358 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7359 {
7360   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7361   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7362     ret+=(*it).capacity();
7363   return ret;
7364 }
7365
7366 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7367 {
7368   std::vector<const BigMemoryObject *> ret;
7369   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7370     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7371   return ret;
7372 }
7373
7374 /*!
7375  * 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
7376  * NULL.
7377  */
7378 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7379 {
7380   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7381   ret->setInfo(_infos);
7382   int sz=(int)_time_steps.size();
7383   for(const int *id=startIds;id!=endIds;id++)
7384     {
7385       if(*id>=0 && *id<sz)
7386         {
7387           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7388           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7389           if(tse)
7390             {
7391               tse->incrRef();
7392               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7393             }
7394           ret->pushBackTimeStep(tse2);
7395         }
7396       else
7397         {
7398           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7399           oss << " ! Should be in [0," << sz << ") !";
7400           throw INTERP_KERNEL::Exception(oss.str());
7401         }
7402     }
7403   if(ret->getNumberOfTS()>0)
7404     ret->synchronizeNameScope();
7405   ret->copyNameScope(*this);
7406   return ret.retn();
7407 }
7408
7409 /*!
7410  * 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
7411  * NULL.
7412  */
7413 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7414 {
7415   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7416   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7417   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7418   ret->setInfo(_infos);
7419   int sz=(int)_time_steps.size();
7420   int j=bg;
7421   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7422     {
7423       if(j>=0 && j<sz)
7424         {
7425           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7426           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7427           if(tse)
7428             {
7429               tse->incrRef();
7430               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7431             }
7432           ret->pushBackTimeStep(tse2);
7433         }
7434       else
7435         {
7436           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7437           oss << " ! Should be in [0," << sz << ") !";
7438           throw INTERP_KERNEL::Exception(oss.str());
7439         }
7440     }
7441   if(ret->getNumberOfTS()>0)
7442     ret->synchronizeNameScope();
7443   ret->copyNameScope(*this);
7444   return ret.retn();
7445 }
7446
7447 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7448 {
7449   int id=0;
7450   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7451   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7452     {
7453       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7454       if(!cur)
7455         continue;
7456       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7457       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7458         ids->pushBackSilent(id);
7459     }
7460   return buildFromTimeStepIds(ids->begin(),ids->end());
7461 }
7462
7463 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7464 {
7465   int id=0;
7466   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7467   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7468     {
7469       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7470       if(!cur)
7471         continue;
7472       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7473       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7474         ids->pushBackSilent(id);
7475     }
7476   return buildFromTimeStepIds(ids->begin(),ids->end());
7477 }
7478
7479 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7480 {
7481   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7482     if((*it).isNotNull())
7483       if((*it)->presenceOfStructureElements())
7484         return true;
7485   return false;
7486 }
7487
7488 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7489 {
7490   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7491     if((*it).isNotNull())
7492       if(!(*it)->onlyStructureElements())
7493         return false;
7494   return true;
7495 }
7496
7497 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7498 {
7499   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > res;
7500   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7501     if((*it).isNotNull())
7502       {
7503         if((*it)->presenceOfStructureElements())
7504           {
7505             if(!(*it)->onlyStructureElements())
7506               {
7507                 (*it)->killStructureElements();
7508                 res.push_back(*it);
7509               }
7510           }
7511         else
7512           {
7513             res.push_back(*it);
7514           }
7515       }
7516   _time_steps=res;
7517 }
7518
7519 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7520 {
7521   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7522     {
7523       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7524       if(!cur)
7525         continue;
7526       if(cur->presenceOfMultiDiscPerGeoType())
7527         return true;
7528     }
7529   return false;
7530 }
7531
7532 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7533 {
7534   return _infos;
7535 }
7536
7537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7538 {
7539   _infos=info;
7540 }
7541
7542 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7543 {
7544   int ret=0;
7545   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7546     {
7547       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7548       if(pt->isDealingTS(iteration,order))
7549         return ret;
7550     }
7551   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7552   std::vector< std::pair<int,int> > vp=getIterations();
7553   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7554     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7555   throw INTERP_KERNEL::Exception(oss.str());
7556 }
7557
7558 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7559 {
7560   return *_time_steps[getTimeStepPos(iteration,order)];
7561 }
7562
7563 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7564 {
7565   return *_time_steps[getTimeStepPos(iteration,order)];
7566 }
7567
7568 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7569 {
7570   if(_time_steps.empty())
7571     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7572   return _time_steps[0]->getMeshName();
7573 }
7574
7575 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7576 {
7577   std::string oldName(getMeshName());
7578   std::vector< std::pair<std::string,std::string> > v(1);
7579   v[0].first=oldName; v[0].second=newMeshName;
7580   changeMeshNames(v);
7581 }
7582
7583 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7584 {
7585   bool ret=false;
7586   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7587     {
7588       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7589       if(cur)
7590         ret=cur->changeMeshNames(modifTab) || ret;
7591     }
7592   return ret;
7593 }
7594
7595 /*!
7596  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7597  */
7598 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7599 {
7600   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7601 }
7602
7603 /*!
7604  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7605  */
7606 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7607 {
7608   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7609 }
7610
7611 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7612                                                                        MEDFileFieldGlobsReal& glob)
7613 {
7614   bool ret=false;
7615   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7616     {
7617       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7618       if(f1ts)
7619         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7620     }
7621   return ret;
7622 }
7623
7624 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7625 {
7626   std::string startLine(bkOffset,' ');
7627   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7628   if(fmtsId>=0)
7629     oss << " (" << fmtsId << ")";
7630   oss << " has the following name: \"" << _name << "\"." << std::endl;
7631   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7632   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7633     {
7634       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7635     }
7636   int i=0;
7637   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7638     {
7639       std::string chapter(17,'0'+i);
7640       oss << startLine << chapter << std::endl;
7641       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7642       if(cur)
7643         cur->simpleRepr(bkOffset+2,oss,i);
7644       else
7645         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7646       oss << startLine << chapter << std::endl;
7647     }
7648 }
7649
7650 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7651 {
7652   std::size_t sz=_time_steps.size();
7653   std::vector< std::pair<int,int> > ret(sz);
7654   ret1.resize(sz);
7655   for(std::size_t i=0;i<sz;i++)
7656     {
7657       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7658       if(f1ts)
7659         {
7660           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7661         }
7662       else
7663         {
7664           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7665           throw INTERP_KERNEL::Exception(oss.str());
7666         }
7667     }
7668   return ret;
7669 }
7670
7671 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7672 {
7673   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7674   if(!tse2)
7675     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7676   checkCoherencyOfType(tse2);
7677   if(_time_steps.empty())
7678     {
7679       setName(tse2->getName().c_str());
7680       setInfo(tse2->getInfo());
7681     }
7682   checkThatComponentsMatch(tse2->getInfo());
7683   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7684     setDtUnit(tse->getDtUnit());
7685   _time_steps.push_back(tse);
7686 }
7687
7688 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7689 {
7690   std::size_t nbOfCompo=_infos.size();
7691   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7692     {
7693       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7694       if(cur)
7695         {
7696           if((cur->getInfo()).size()!=nbOfCompo)
7697             {
7698               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7699               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7700               throw INTERP_KERNEL::Exception(oss.str());
7701             }
7702           cur->copyNameScope(*this);
7703         }
7704     }
7705 }
7706
7707 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7708 {
7709   _time_steps.resize(nbPdt);
7710   for(int i=0;i<nbPdt;i++)
7711     {
7712       std::vector< std::pair<int,int> > ts;
7713       med_int numdt=0,numo=0;
7714       med_float dt=0.0;
7715       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7716       switch(fieldTyp)
7717       {
7718         case MED_FLOAT64:
7719           {
7720             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7721             break;
7722           }
7723         case MED_INT32:
7724           {
7725             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7726             break;
7727           }
7728         default:
7729           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7730       }
7731       if(loadAll)
7732         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7733       else
7734         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7735       synchronizeNameScope();
7736     }
7737 }
7738
7739 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7740 {
7741   if(_time_steps.empty())
7742     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7743   checkThatNbOfCompoOfTSMatchThis();
7744   std::vector<std::string> infos(getInfo());
7745   int nbComp=infos.size();
7746   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7747   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7748   for(int i=0;i<nbComp;i++)
7749     {
7750       std::string info=infos[i];
7751       std::string c,u;
7752       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7753       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7754       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7755     }
7756   if(_name.empty())
7757     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7758   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7759   int nbOfTS=_time_steps.size();
7760   for(int i=0;i<nbOfTS;i++)
7761     _time_steps[i]->writeLL(fid,opts,*this);
7762 }
7763
7764 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7765 {
7766   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7767     {
7768       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7769       if(elt)
7770         elt->loadBigArraysRecursively(fid,nasc);
7771     }
7772 }
7773
7774 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7775 {
7776   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7777     {
7778       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7779       if(elt)
7780         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7781     }
7782 }
7783
7784 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7785 {
7786   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7787     {
7788       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7789       if(elt)
7790         elt->unloadArrays();
7791     }
7792 }
7793
7794 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7795 {
7796   return _time_steps.size();
7797 }
7798
7799 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7800 {
7801   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7802   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7803     {
7804       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7805       if(tmp)
7806         newTS.push_back(*it);
7807     }
7808   _time_steps=newTS;
7809 }
7810
7811 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7812 {
7813   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7814   int maxId=(int)_time_steps.size();
7815   int ii=0;
7816   std::set<int> idsToDel;
7817   for(const int *id=startIds;id!=endIds;id++,ii++)
7818     {
7819       if(*id>=0 && *id<maxId)
7820         {
7821           idsToDel.insert(*id);
7822         }
7823       else
7824         {
7825           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7826           throw INTERP_KERNEL::Exception(oss.str());
7827         }
7828     }
7829   for(int iii=0;iii<maxId;iii++)
7830     if(idsToDel.find(iii)==idsToDel.end())
7831       newTS.push_back(_time_steps[iii]);
7832   _time_steps=newTS;
7833 }
7834
7835 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7836 {
7837   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7838   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7839   if(nbOfEntriesToKill==0)
7840     return ;
7841   std::size_t sz=_time_steps.size();
7842   std::vector<bool> b(sz,true);
7843   int j=bg;
7844   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7845     b[j]=false;
7846   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7847   for(std::size_t i=0;i<sz;i++)
7848     if(b[i])
7849       newTS.push_back(_time_steps[i]);
7850   _time_steps=newTS;
7851 }
7852
7853 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7854 {
7855   int ret=0;
7856   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7857   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7858     {
7859       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7860       if(tmp)
7861         {
7862           int it2,ord;
7863           tmp->getTime(it2,ord);
7864           if(it2==iteration && order==ord)
7865             return ret;
7866           else
7867             oss << "(" << it2 << ","  << ord << "), ";
7868         }
7869     }
7870   throw INTERP_KERNEL::Exception(oss.str());
7871 }
7872
7873 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7874 {
7875   int ret=0;
7876   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7877   oss.precision(15);
7878   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7879     {
7880       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7881       if(tmp)
7882         {
7883           int it2,ord;
7884           double ti=tmp->getTime(it2,ord);
7885           if(fabs(time-ti)<eps)
7886             return ret;
7887           else
7888             oss << ti << ", ";
7889         }
7890     }
7891   throw INTERP_KERNEL::Exception(oss.str());
7892 }
7893
7894 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7895 {
7896   int lgth=_time_steps.size();
7897   std::vector< std::pair<int,int> > ret(lgth);
7898   for(int i=0;i<lgth;i++)
7899     _time_steps[i]->fillIteration(ret[i]);
7900   return ret;
7901 }
7902
7903 /*!
7904  * 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'
7905  * This method returns two things.
7906  * - The absolute dimension of 'this' in first parameter. 
7907  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7908  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7909  *
7910  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7911  * Only these 3 discretizations will be taken into account here.
7912  *
7913  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7914  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7915  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7916  *
7917  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7918  * 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'.
7919  * 
7920  * Let's consider the typical following case :
7921  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7922  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7923  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7924  *   TETRA4 and SEG2
7925  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7926  *
7927  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7928  * 
7929  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7930  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7931  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7932  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7933  */
7934 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7935 {
7936   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7937 }
7938
7939 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7940 {
7941   if(pos<0 || pos>=(int)_time_steps.size())
7942     {
7943       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7944       throw INTERP_KERNEL::Exception(oss.str());
7945     }
7946   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7947   if(item==0)
7948     {
7949       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7950       oss << "\nTry to use following method eraseEmptyTS !";
7951       throw INTERP_KERNEL::Exception(oss.str());
7952     }
7953   return item;
7954 }
7955
7956 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7957 {
7958   if(pos<0 || pos>=(int)_time_steps.size())
7959     {
7960       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7961       throw INTERP_KERNEL::Exception(oss.str());
7962     }
7963   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7964   if(item==0)
7965     {
7966       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7967       oss << "\nTry to use following method eraseEmptyTS !";
7968       throw INTERP_KERNEL::Exception(oss.str());
7969     }
7970   return item;
7971 }
7972
7973 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7974 {
7975   std::vector<std::string> ret;
7976   std::set<std::string> ret2;
7977   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7978     {
7979       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7980       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7981         if(ret2.find(*it2)==ret2.end())
7982           {
7983             ret.push_back(*it2);
7984             ret2.insert(*it2);
7985           }
7986     }
7987   return ret;
7988 }
7989
7990 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7991 {
7992   std::vector<std::string> ret;
7993   std::set<std::string> ret2;
7994   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7995     {
7996       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7997       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7998         if(ret2.find(*it2)==ret2.end())
7999           {
8000             ret.push_back(*it2);
8001             ret2.insert(*it2);
8002           }
8003     }
8004   return ret;
8005 }
8006
8007 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8008 {
8009   std::vector<std::string> ret;
8010   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8011     {
8012       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8013       ret.insert(ret.end(),tmp.begin(),tmp.end());
8014     }
8015   return ret;
8016 }
8017
8018 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8019 {
8020   std::vector<std::string> ret;
8021   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8022     {
8023       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8024       ret.insert(ret.end(),tmp.begin(),tmp.end());
8025     }
8026   return ret;
8027 }
8028
8029 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8030 {
8031   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8032     (*it)->changePflsRefsNamesGen2(mapOfModif);
8033 }
8034
8035 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8036 {
8037   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8038     (*it)->changeLocsRefsNamesGen2(mapOfModif);
8039 }
8040
8041 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8042 {
8043   int lgth=_time_steps.size();
8044   std::vector< std::vector<TypeOfField> > ret(lgth);
8045   for(int i=0;i<lgth;i++)
8046     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8047   return ret;
8048 }
8049
8050 /*!
8051  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8052  */
8053 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8054 {
8055   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8056 }
8057
8058 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8059 {
8060   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8061   std::size_t i=0;
8062   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8063     {
8064       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8065         ret->_time_steps[i]=(*it)->deepCopy();
8066     }
8067   return ret.retn();
8068 }
8069
8070 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8071 {
8072   std::size_t sz(_infos.size()),sz2(_time_steps.size());
8073   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8074   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8075   for(std::size_t i=0;i<sz;i++)
8076     {
8077       ret[i]=shallowCpy();
8078       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8079     }
8080   for(std::size_t i=0;i<sz2;i++)
8081     {
8082       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8083       if(ret1.size()!=sz)
8084         {
8085           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8086           throw INTERP_KERNEL::Exception(oss.str());
8087         }
8088       ts[i]=ret1;
8089     }
8090   for(std::size_t i=0;i<sz;i++)
8091     for(std::size_t j=0;j<sz2;j++)
8092       ret[i]->_time_steps[j]=ts[j][i];
8093   return ret;
8094 }
8095
8096 /*!
8097  * This method splits into discretization each time steps in \a this.
8098  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8099  */
8100 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8101 {
8102   std::size_t sz(_time_steps.size());
8103   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8104   for(std::size_t i=0;i<sz;i++)
8105     {
8106       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8107       if(!timeStep)
8108         {
8109           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
8110           throw INTERP_KERNEL::Exception(oss.str());
8111         }
8112       items[i]=timeStep->splitDiscretizations();  
8113     }
8114   //
8115   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8116   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8117   std::vector< TypeOfField > types;
8118   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8119     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8120       {
8121         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8122         if(ts.size()!=1)
8123           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8124         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8125         if(it2==types.end())
8126           types.push_back(ts[0]);
8127       }
8128   ret.resize(types.size()); ret2.resize(types.size());
8129   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8130     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8131       {
8132         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8133         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8134         ret2[pos].push_back(*it1);
8135       }
8136   for(std::size_t i=0;i<types.size();i++)
8137     {
8138       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8139       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8140         elt->pushBackTimeStep(*it1);//also updates infos in elt
8141       ret[i]=elt;
8142       elt->MEDFileFieldNameScope::operator=(*this);
8143     }
8144   return ret;
8145 }
8146
8147 /*!
8148  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8149  */
8150 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8151 {
8152   std::size_t sz(_time_steps.size());
8153   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8154   std::size_t szOut(std::numeric_limits<std::size_t>::max());
8155   for(std::size_t i=0;i<sz;i++)
8156     {
8157       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8158       if(!timeStep)
8159         {
8160           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8161           throw INTERP_KERNEL::Exception(oss.str());
8162         }
8163       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8164       if(szOut==std::numeric_limits<std::size_t>::max())
8165         szOut=items[i].size();
8166       else
8167         if(items[i].size()!=szOut)
8168           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8169     }
8170   if(szOut==std::numeric_limits<std::size_t>::max())
8171     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8172   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8173   for(std::size_t i=0;i<szOut;i++)
8174     {
8175       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8176       for(std::size_t j=0;j<sz;j++)
8177         elt->pushBackTimeStep(items[j][i]);
8178       ret[i]=elt;
8179       elt->MEDFileFieldNameScope::operator=(*this);
8180     }
8181   return ret;
8182 }
8183
8184 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8185 {
8186   _name=field->getName();
8187   if(_name.empty())
8188     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8189   if(!arr)
8190     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8191   _infos=arr->getInfoOnComponents();
8192 }
8193
8194 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8195 {
8196   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8197   if(_name!=field->getName())
8198     {
8199       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8200       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8201       throw INTERP_KERNEL::Exception(oss.str());
8202     }
8203   if(!arr)
8204     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8205   checkThatComponentsMatch(arr->getInfoOnComponents());
8206 }
8207
8208 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8209 {
8210   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8211   if(getInfo().size()!=compos.size())
8212     {
8213       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8214       oss << " number of components of element to append (" << compos.size() << ") !";
8215       throw INTERP_KERNEL::Exception(oss.str());
8216     }
8217   if(_infos!=compos)
8218     {
8219       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8220       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8221       oss << " But compo in input fields are : ";
8222       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8223       oss << " !";
8224       throw INTERP_KERNEL::Exception(oss.str());
8225     }
8226 }
8227
8228 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8229 {
8230   std::size_t sz=_infos.size();
8231   int j=0;
8232   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8233     {
8234       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8235       if(elt)
8236         if(elt->getInfo().size()!=sz)
8237           {
8238             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8239             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8240             throw INTERP_KERNEL::Exception(oss.str());
8241           }
8242     }
8243 }
8244
8245 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8246 {
8247   if(!field)
8248     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8249   if(!_time_steps.empty())
8250     checkCoherencyOfTinyInfo(field,arr);
8251   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8252   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8253   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8254   copyTinyInfoFrom(field,arr);
8255   _time_steps.push_back(obj);
8256 }
8257
8258 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8259 {
8260   if(!field)
8261     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8262   if(!_time_steps.empty())
8263     checkCoherencyOfTinyInfo(field,arr);
8264   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8265   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8266   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8267   copyTinyInfoFrom(field,arr);
8268   _time_steps.push_back(obj);
8269 }
8270
8271 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8272 {
8273   int sz=(int)_time_steps.size();
8274   if(i<0 || i>=sz)
8275     {
8276       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8277       throw INTERP_KERNEL::Exception(oss.str());
8278     }
8279   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8280   if(tsPtr)
8281     {
8282       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8283         {
8284           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8285           throw INTERP_KERNEL::Exception(oss.str());
8286         }
8287     }
8288   _time_steps[i]=ts;
8289 }
8290
8291 //= MEDFileFieldMultiTSWithoutSDA
8292
8293 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8294 {
8295   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8296 }
8297
8298 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8299 {
8300 }
8301
8302 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8303 {
8304 }
8305
8306 /*!
8307  * \param [in] fieldId field id in C mode
8308  */
8309 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8310 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8311 {
8312 }
8313 catch(INTERP_KERNEL::Exception& e)
8314 { throw e; }
8315
8316 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8317 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8318 {
8319 }
8320 catch(INTERP_KERNEL::Exception& e)
8321 { throw e; }
8322
8323 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8324 {
8325   return new MEDFileField1TSWithoutSDA;
8326 }
8327
8328 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8329 {
8330   if(!f1ts)
8331     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8332   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8333   if(!f1tsC)
8334     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8335 }
8336
8337 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8338 {
8339   return MEDFileField1TSWithoutSDA::TYPE_STR;
8340 }
8341
8342 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8343 {
8344   return new MEDFileFieldMultiTSWithoutSDA(*this);
8345 }
8346
8347 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8348 {
8349   return new MEDFileFieldMultiTSWithoutSDA;
8350 }
8351
8352 /*!
8353  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8354  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8355  */
8356 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8357 {
8358   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8359   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8360   if(!myF1TSC)
8361     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8362   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8363 }
8364
8365 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8366 {
8367   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8368   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8369   int i=0;
8370   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8371     {
8372       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8373       if(eltToConv)
8374         {
8375           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8376           if(!eltToConvC)
8377             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8378           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8379           ret->setIteration(i,elt);
8380         }
8381     }
8382   return ret.retn();
8383 }
8384
8385 //= MEDFileAnyTypeFieldMultiTS
8386
8387 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8388 {
8389 }
8390
8391 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8392 try:MEDFileFieldGlobsReal(fid)
8393 {
8394   _content=BuildContentFrom(fid,loadAll,ms);
8395   loadGlobals(fid);
8396 }
8397 catch(INTERP_KERNEL::Exception& e)
8398 {
8399     throw e;
8400 }
8401
8402 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8403 {
8404   med_field_type typcha;
8405   std::vector<std::string> infos;
8406   std::string dtunit;
8407   int i(-1);
8408   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8409   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8410   switch(typcha)
8411   {
8412     case MED_FLOAT64:
8413       {
8414         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8415         break;
8416       }
8417     case MED_INT32:
8418       {
8419         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8420         break;
8421       }
8422     default:
8423       {
8424         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8425         throw INTERP_KERNEL::Exception(oss.str());
8426       }
8427   }
8428   ret->setDtUnit(dtunit.c_str());
8429   return ret.retn();
8430 }
8431
8432 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8433 {
8434   med_field_type typcha;
8435   //
8436   std::vector<std::string> infos;
8437   std::string dtunit,fieldName;
8438   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8439   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8440   switch(typcha)
8441   {
8442     case MED_FLOAT64:
8443       {
8444         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8445         break;
8446       }
8447     case MED_INT32:
8448       {
8449         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8450         break;
8451       }
8452     default:
8453       {
8454         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8455         throw INTERP_KERNEL::Exception(oss.str());
8456       }
8457   }
8458   ret->setDtUnit(dtunit.c_str());
8459   return ret.retn();
8460 }
8461
8462 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8463 {
8464   if(!c)
8465     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8466   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8467     {
8468       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8469       ret->_content=c;  c->incrRef();
8470       return ret.retn();
8471     }
8472   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8473     {
8474       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8475       ret->_content=c;  c->incrRef();
8476       return ret.retn();
8477     }
8478   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8479 }
8480
8481 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8482 {
8483   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8484   std::string fileName(FileNameFromFID(fid));
8485   ret->setFileName(fileName);
8486   return ret;
8487 }
8488
8489 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8490 try:MEDFileFieldGlobsReal(fid)
8491 {
8492   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8493   loadGlobals(fid);
8494 }
8495 catch(INTERP_KERNEL::Exception& e)
8496 {
8497     throw e;
8498 }
8499
8500 //= MEDFileIntFieldMultiTSWithoutSDA
8501
8502 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8503 {
8504   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8505 }
8506
8507 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8508 {
8509 }
8510
8511 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8512 {
8513 }
8514
8515 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8516 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8517 {
8518 }
8519 catch(INTERP_KERNEL::Exception& e)
8520 { throw e; }
8521
8522 /*!
8523  * \param [in] fieldId field id in C mode
8524  */
8525 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8526 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8527 {
8528 }
8529 catch(INTERP_KERNEL::Exception& e)
8530 { throw e; }
8531
8532 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8533 {
8534   return new MEDFileIntField1TSWithoutSDA;
8535 }
8536
8537 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8538 {
8539   if(!f1ts)
8540     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8541   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8542   if(!f1tsC)
8543     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8544 }
8545
8546 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8547 {
8548   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8549 }
8550
8551 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8552 {
8553   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8554 }
8555
8556 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8557 {
8558   return new MEDFileIntFieldMultiTSWithoutSDA;
8559 }
8560
8561 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8562 {
8563   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8564   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8565   int i=0;
8566   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8567     {
8568       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8569       if(eltToConv)
8570         {
8571           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8572           if(!eltToConvC)
8573             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8574           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8575           ret->setIteration(i,elt);
8576         }
8577     }
8578   return ret.retn();
8579 }
8580
8581 //= MEDFileAnyTypeFieldMultiTS
8582
8583 /*!
8584  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8585  * that has been read from a specified MED file.
8586  *  \param [in] fileName - the name of the MED file to read.
8587  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8588  *          is to delete this field using decrRef() as it is no more needed.
8589  *  \throw If reading the file fails.
8590  */
8591 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8592 {
8593   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8594   return New(fid,loadAll);
8595 }
8596
8597 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8598 {
8599   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8600   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8601   ret->loadGlobals(fid);
8602   return ret.retn();
8603 }
8604
8605 /*!
8606  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8607  * that has been read from a specified MED file.
8608  *  \param [in] fileName - the name of the MED file to read.
8609  *  \param [in] fieldName - the name of the field to read.
8610  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8611  *          is to delete this field using decrRef() as it is no more needed.
8612  *  \throw If reading the file fails.
8613  *  \throw If there is no field named \a fieldName in the file.
8614  */
8615 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8616 {
8617   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8618   return New(fid,fieldName,loadAll);
8619 }
8620
8621 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8622 {
8623   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8624   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8625   ret->loadGlobals(fid);
8626   return ret.retn();
8627 }
8628
8629 /*!
8630  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8631  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8632  *
8633  * \warning this is a shallow copy constructor
8634  */
8635 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8636 {
8637   if(!shallowCopyOfContent)
8638     {
8639       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8640       otherPtr->incrRef();
8641       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8642     }
8643   else
8644     {
8645       _content=other.shallowCpy();
8646     }
8647 }
8648
8649 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8650 {
8651   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8652   if(!ret)
8653     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8654   return ret;
8655 }
8656
8657 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8658 {
8659   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8660   if(!ret)
8661     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8662   return ret;
8663 }
8664
8665 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8666 {
8667   return contentNotNullBase()->getPflsReallyUsed2();
8668 }
8669
8670 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8671 {
8672   return contentNotNullBase()->getLocsReallyUsed2();
8673 }
8674
8675 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8676 {
8677   return contentNotNullBase()->getPflsReallyUsedMulti2();
8678 }
8679
8680 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8681 {
8682   return contentNotNullBase()->getLocsReallyUsedMulti2();
8683 }
8684
8685 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8686 {
8687   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8688 }
8689
8690 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8691 {
8692   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8693 }
8694
8695 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8696 {
8697   return contentNotNullBase()->getNumberOfTS();
8698 }
8699
8700 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8701 {
8702   contentNotNullBase()->eraseEmptyTS();
8703 }
8704
8705 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8706 {
8707   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8708 }
8709
8710 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8711 {
8712   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8713 }
8714
8715 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8716 {
8717   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8718   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8719   ret->_content=c;
8720   return ret.retn();
8721 }
8722
8723 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8724 {
8725   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8726   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8727   ret->_content=c;
8728   return ret.retn();
8729 }
8730
8731 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8732 {
8733   return contentNotNullBase()->getIterations();
8734 }
8735
8736 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8737 {
8738   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8739     pushBackTimeStep(*it);
8740 }
8741
8742 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8743 {
8744   if(!fmts)
8745     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8746   int nbOfTS(fmts->getNumberOfTS());
8747   for(int i=0;i<nbOfTS;i++)
8748     {
8749       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8750       pushBackTimeStep(elt);
8751     }
8752 }
8753
8754 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8755 {
8756   if(!f1ts)
8757     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8758   checkCoherencyOfType(f1ts);
8759   f1ts->incrRef();
8760   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8761   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8762   c->incrRef();
8763   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8764   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8765     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8766   _content->pushBackTimeStep(cSafe);
8767   appendGlobs(*f1ts,1e-12);
8768 }
8769
8770 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8771 {
8772   contentNotNullBase()->synchronizeNameScope();
8773 }
8774
8775 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8776 {
8777   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8778 }
8779
8780 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8781 {
8782   return contentNotNullBase()->getPosGivenTime(time,eps);
8783 }
8784
8785 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8786 {
8787   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8788 }
8789
8790 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8791 {
8792   return contentNotNullBase()->getTypesOfFieldAvailable();
8793 }
8794
8795 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8796 {
8797   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8798 }
8799
8800 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8801 {
8802   return contentNotNullBase()->getName();
8803 }
8804
8805 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8806 {
8807   contentNotNullBase()->setName(name);
8808 }
8809
8810 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8811 {
8812   return contentNotNullBase()->getDtUnit();
8813 }
8814
8815 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8816 {
8817   contentNotNullBase()->setDtUnit(dtUnit);
8818 }
8819
8820 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8821 {
8822   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8823 }
8824
8825 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8826 {
8827   return contentNotNullBase()->getTimeSteps(ret1);
8828 }
8829
8830 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8831 {
8832   return contentNotNullBase()->getMeshName();
8833 }
8834
8835 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8836 {
8837   contentNotNullBase()->setMeshName(newMeshName);
8838 }
8839
8840 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8841 {
8842   return contentNotNullBase()->changeMeshNames(modifTab);
8843 }
8844
8845 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8846 {
8847   return contentNotNullBase()->getInfo();
8848 }
8849
8850 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8851 {
8852   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8853 }
8854
8855 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8856 {
8857   return contentNotNullBase()->setInfo(info);
8858 }
8859
8860 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8861 {
8862   const std::vector<std::string> ret=getInfo();
8863   return (int)ret.size();
8864 }
8865
8866 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8867 {
8868   writeGlobals(fid,*this);
8869   contentNotNullBase()->writeLL(fid,*this);
8870 }
8871
8872 /*!
8873  * This method alloc the arrays and load potentially huge arrays contained in this field.
8874  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8875  * This method can be also called to refresh or reinit values from a file.
8876  * 
8877  * \throw If the fileName is not set or points to a non readable MED file.
8878  */
8879 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8880 {
8881   if(getFileName().empty())
8882     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8883   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8884   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8885 }
8886
8887 /*!
8888  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8889  * But once data loaded once, this method does nothing.
8890  * 
8891  * \throw If the fileName is not set or points to a non readable MED file.
8892  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8893  */
8894 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8895 {
8896   if(!getFileName().empty())
8897     {
8898       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8899       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8900     }
8901 }
8902
8903 /*!
8904  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8905  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8906  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8907  * 
8908  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8909  */
8910 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8911 {
8912   contentNotNullBase()->unloadArrays();
8913 }
8914
8915 /*!
8916  * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
8917  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8918  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8919  * 
8920  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8921  */
8922 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8923 {
8924   if(!getFileName().empty())
8925     contentNotNullBase()->unloadArrays();
8926 }
8927
8928 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8929 {
8930   std::ostringstream oss;
8931   contentNotNullBase()->simpleRepr(0,oss,-1);
8932   simpleReprGlobs(oss);
8933   return oss.str();
8934 }
8935
8936 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8937 {
8938   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8939 }
8940
8941 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8942 {
8943   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8944   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8945   return ret;
8946 }
8947
8948 /*!
8949  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8950  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8951  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8952  */
8953 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8954 {
8955   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8956   if(!content)
8957     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8958   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8959   std::size_t sz(contentsSplit.size());
8960   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8961   for(std::size_t i=0;i<sz;i++)
8962     {
8963       ret[i]=shallowCpy();
8964       ret[i]->_content=contentsSplit[i];
8965     }
8966   return ret;
8967 }
8968
8969 /*!
8970  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8971  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8972  */
8973 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8974 {
8975   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8976   if(!content)
8977     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8978   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8979   std::size_t sz(contentsSplit.size());
8980   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8981   for(std::size_t i=0;i<sz;i++)
8982     {
8983       ret[i]=shallowCpy();
8984       ret[i]->_content=contentsSplit[i];
8985     }
8986   return ret;
8987 }
8988
8989 /*!
8990  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8991  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8992  */
8993 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8994 {
8995   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8996   if(!content)
8997     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8998   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8999   std::size_t sz(contentsSplit.size());
9000   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9001   for(std::size_t i=0;i<sz;i++)
9002     {
9003       ret[i]=shallowCpy();
9004       ret[i]->_content=contentsSplit[i];
9005     }
9006   return ret;
9007 }
9008
9009 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9010 {
9011   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9012   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9013     ret->_content=_content->deepCopy();
9014   ret->deepCpyGlobs(*this);
9015   return ret.retn();
9016 }
9017
9018 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9019 {
9020   return _content;
9021 }
9022
9023 /*!
9024  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9025  *  \param [in] iteration - the iteration number of a required time step.
9026  *  \param [in] order - the iteration order number of required time step.
9027  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9028  *          delete this field using decrRef() as it is no more needed.
9029  *  \throw If there is no required time step in \a this field.
9030  */
9031 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9032 {
9033   int pos=getPosOfTimeStep(iteration,order);
9034   return getTimeStepAtPos(pos);
9035 }
9036
9037 /*!
9038  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9039  *  \param [in] time - the time of the time step of interest.
9040  *  \param [in] eps - a precision used to compare time values.
9041  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9042  *          delete this field using decrRef() as it is no more needed.
9043  *  \throw If there is no required time step in \a this field.
9044  */
9045 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9046 {
9047   int pos=getPosGivenTime(time,eps);
9048   return getTimeStepAtPos(pos);
9049 }
9050
9051 /*!
9052  * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
9053  * The float64 value of time attached to the pair of integers are not considered here.
9054  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9055  *
9056  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9057  * \throw If there is a null pointer in \a vectFMTS.
9058  */
9059 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9060 {
9061   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9062   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9063   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9064   while(!lstFMTS.empty())
9065     {
9066       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9067       MEDFileAnyTypeFieldMultiTS *curIt(*it);
9068       if(!curIt)
9069         throw INTERP_KERNEL::Exception(msg);
9070       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9071       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9072       elt.push_back(curIt); it=lstFMTS.erase(it);
9073       while(it!=lstFMTS.end())
9074         {
9075           curIt=*it;
9076           if(!curIt)
9077             throw INTERP_KERNEL::Exception(msg);
9078           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9079           if(refIts==curIts)
9080             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9081           else
9082             it++;
9083         }
9084       ret.push_back(elt);
9085     }
9086   return ret;
9087 }
9088
9089 /*!
9090  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9091  * All returned instances in a subvector can be safely loaded, rendered along time
9092  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9093  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9094  * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
9095  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9096  * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
9097  *
9098  * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
9099  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9100  * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
9101  * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
9102  *
9103  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9104  * \throw If an element in \a vectFMTS change of spatial discretization along time.
9105  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9106  * \thorw If some elements in \a vectFMTS do not have the same times steps.
9107  * \throw If mesh is null.
9108  * \throw If an element in \a vectFMTS is null.
9109  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9110  */
9111 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9112 {
9113   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9114   if(!mesh)
9115     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9116   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9117   if(vectFMTS.empty())
9118     return ret;
9119   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9120   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9121   if(!frstElt)
9122     throw INTERP_KERNEL::Exception(msg);
9123   std::size_t i=0;
9124   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9125   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9126   for(;it!=vectFMTS.end();it++,i++)
9127     {
9128       if(!(*it))
9129         throw INTERP_KERNEL::Exception(msg);
9130       TypeOfField tof0,tof1;
9131       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9132         {
9133           if(tof1!=ON_NODES)
9134             vectFMTSNotNodes.push_back(*it);
9135           else
9136             vectFMTSNodes.push_back(*it);
9137         }
9138       else
9139         vectFMTSNotNodes.push_back(*it);
9140     }
9141   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9142   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9143   ret=retCell;
9144   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9145     {
9146       i=0;
9147       bool isFetched(false);
9148       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9149         {
9150           if((*it0).empty())
9151             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9152           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9153             { ret[i].push_back(*it2); isFetched=true; }
9154         }
9155       if(!isFetched)
9156         {
9157           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9158           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9159           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9160         }
9161     }
9162   fsc=cmps;
9163   return ret;
9164 }
9165
9166 /*!
9167  * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
9168  * \param [out] cmps - same size than the returned vector.
9169  */
9170 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9171 {
9172   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9173   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9174   while(!lstFMTS.empty())
9175     {
9176       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9177       MEDFileAnyTypeFieldMultiTS *ref(*it);
9178       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9179       elt.push_back(ref); it=lstFMTS.erase(it);
9180       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9181       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9182       while(it!=lstFMTS.end())
9183         {
9184           MEDFileAnyTypeFieldMultiTS *curIt(*it);
9185           if(cmp->isEqual(curIt))
9186             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9187           else
9188             it++;
9189         }
9190       ret.push_back(elt); cmps.push_back(cmp);
9191     }
9192   return ret;
9193 }
9194
9195 /*!
9196  * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
9197  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9198  *
9199  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9200  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9201  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9202  * \thorw If \a f0 and \a f1 do not have the same times steps.
9203  * \throw If mesh is null.
9204  * \throw If \a f0 or \a f1 is null.
9205  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9206  */
9207 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9208 {
9209   if(!mesh)
9210     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9211   if(!f0 || !f1)
9212     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9213   if(f0->getMeshName()!=mesh->getName())
9214     {
9215       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9216       throw INTERP_KERNEL::Exception(oss.str());
9217     }
9218   if(f1->getMeshName()!=mesh->getName())
9219     {
9220       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9221       throw INTERP_KERNEL::Exception(oss.str());
9222     }
9223   int nts=f0->getNumberOfTS();
9224   if(nts!=f1->getNumberOfTS())
9225     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9226   if(nts==0)
9227     return nts;
9228   for(int i=0;i<nts;i++)
9229     {
9230       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9231       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9232       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9233       if(tofs0.size()!=1 || tofs1.size()!=1)
9234         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9235       if(i!=0)
9236         {
9237           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9238             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9239         }
9240       else
9241         { tof0=tofs0[0]; tof1=tofs1[0]; }
9242       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9243         {
9244           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
9245           throw INTERP_KERNEL::Exception(oss.str());
9246         }
9247       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9248         {
9249           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
9250           throw INTERP_KERNEL::Exception(oss.str());
9251         }
9252       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9253         {
9254           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
9255           throw INTERP_KERNEL::Exception(oss.str());
9256         }
9257     }
9258   return nts;
9259 }
9260
9261 /*!
9262  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9263  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9264  *
9265  * \return A new object that the caller is responsible to deallocate.
9266  */
9267 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9268 {
9269   if(!mm)
9270     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9271   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9272   int nbTS(getNumberOfTS());
9273   for(int i=0;i<nbTS;i++)
9274     {
9275       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9276       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9277       fmtsOut->pushBackTimeStep(f1tsOut);
9278     }
9279   return fmtsOut.retn();
9280 }
9281
9282 template<class T>
9283 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9284 {
9285   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9286   if(f1tss.empty())
9287     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9288   std::size_t sz(f1tss.size()),i(0);
9289   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9290   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9291     {
9292       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9293       if(!elt)
9294         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9295       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9296     }
9297   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9298   if(!retc)
9299     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9300   retc->aggregate(f1tsw,dts);
9301   ret->setDtUnit(f1tss[0]->getDtUnit());
9302   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9303 }
9304
9305 template<class T>
9306 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9307 {
9308   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9309   if(fmtss.empty())
9310     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9311   std::size_t sz(fmtss.size());
9312   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9313     {
9314       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9315       if(!elt)
9316         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9317     }
9318   int nbTS(fmtss[0]->getNumberOfTS());
9319   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9320     if((*it)->getNumberOfTS()!=nbTS)
9321       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9322   for(int iterTS=0;iterTS<nbTS;iterTS++)
9323     {
9324       std::size_t i(0);
9325       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9326       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9327       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9328         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9329       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9330       ret->pushBackTimeStep(f1ts);
9331       ret->setDtUnit(f1ts->getDtUnit());
9332     }
9333   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9334 }
9335
9336 /*!
9337  * \a dts and \a ftmss are expected to have same size.
9338  */
9339 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9340 {
9341   if(fmtss.empty())
9342     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9343   std::size_t sz(fmtss.size());
9344   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9345   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9346   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9347     {
9348       if(!(*it))
9349         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9350       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9351       if(elt1)
9352         {
9353           fmtss1.push_back(elt1);
9354           continue;
9355         }
9356       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9357       if(elt2)
9358         {
9359           fmtss2.push_back(elt2);
9360           continue;
9361         }
9362       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9363     }
9364   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9365     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9366   if(fmtss1.size()==sz)
9367     return AggregateHelperFMTS<double>(fmtss1,dts);
9368   if(fmtss2.size()!=sz)
9369     return AggregateHelperFMTS<int>(fmtss2,dts);
9370   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9371 }
9372
9373 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9374 {
9375   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9376 }
9377
9378 //= MEDFileFieldMultiTS
9379
9380 /*!
9381  * Returns a new empty instance of MEDFileFieldMultiTS.
9382  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9383  *          is to delete this field using decrRef() as it is no more needed.
9384  */
9385 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9386 {
9387   return new MEDFileFieldMultiTS;
9388 }
9389
9390 /*!
9391  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9392  * that has been read from a specified MED file.
9393  *  \param [in] fileName - the name of the MED file to read.
9394  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9395  *          is to delete this field using decrRef() as it is no more needed.
9396  *  \throw If reading the file fails.
9397  */
9398 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9399 {
9400   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9401   return New(fid,loadAll);
9402 }
9403
9404 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9405 {
9406   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9407   ret->contentNotNull();//to check that content type matches with \a this type.
9408   return ret.retn();
9409 }
9410
9411 /*!
9412  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9413  * that has been read from a specified MED file.
9414  *  \param [in] fileName - the name of the MED file to read.
9415  *  \param [in] fieldName - the name of the field to read.
9416  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9417  *          is to delete this field using decrRef() as it is no more needed.
9418  *  \throw If reading the file fails.
9419  *  \throw If there is no field named \a fieldName in the file.
9420  */
9421 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9422 {
9423   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9424   return New(fid,fieldName,loadAll);
9425 }
9426
9427 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9428 {
9429   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9430   ret->contentNotNull();//to check that content type matches with \a this type.
9431   return ret.retn();
9432 }
9433
9434 /*!
9435  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9436  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9437  *
9438  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9439  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9440  * \warning this is a shallow copy constructor
9441  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9442  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9443  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9444  *          is to delete this field using decrRef() as it is no more needed.
9445  */
9446 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9447 {
9448   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9449 }
9450
9451 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9452 {
9453   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9454   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9455   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9456   ret->contentNotNull();//to check that content type matches with \a this type.
9457   return ret.retn();
9458 }
9459
9460 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9461 {
9462   return new MEDFileFieldMultiTS(*this);
9463 }
9464
9465 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9466 {
9467   if(!f1ts)
9468     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9469   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9470   if(!f1tsC)
9471     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9472 }
9473
9474 /*!
9475  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9476  * following the given input policy.
9477  *
9478  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9479  *                            By default (true) the globals are deeply copied.
9480  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9481  */
9482 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9483 {
9484   MCAuto<MEDFileIntFieldMultiTS> ret;
9485   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9486   if(content)
9487     {
9488       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9489       if(!contc)
9490         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9491       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9492       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9493     }
9494   else
9495     ret=MEDFileIntFieldMultiTS::New();
9496   if(isDeepCpyGlobs)
9497     ret->deepCpyGlobs(*this);
9498   else
9499     ret->shallowCpyGlobs(*this);
9500   return ret.retn();
9501 }
9502
9503 /*!
9504  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9505  *  \param [in] pos - a time step id.
9506  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9507  *          delete this field using decrRef() as it is no more needed.
9508  *  \throw If \a pos is not a valid time step id.
9509  */
9510 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9511 {
9512   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9513   if(!item)
9514     {
9515       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9516       throw INTERP_KERNEL::Exception(oss.str());
9517     }
9518   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9519   if(itemC)
9520     {
9521       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9522       ret->shallowCpyGlobs(*this);
9523       return ret.retn();
9524     }
9525   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9526   throw INTERP_KERNEL::Exception(oss.str());
9527 }
9528
9529 /*!
9530  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9531  * mesh entities of a given dimension of the first mesh in MED file.
9532  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9533  *  \param [in] type - a spatial discretization of interest.
9534  *  \param [in] iteration - the iteration number of a required time step.
9535  *  \param [in] order - the iteration order number of required time step.
9536  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9537  *  \param [in] renumPol - specifies how to permute values of the result field according to
9538  *          the optional numbers of cells and nodes, if any. The valid values are
9539  *          - 0 - do not permute.
9540  *          - 1 - permute cells.
9541  *          - 2 - permute nodes.
9542  *          - 3 - permute cells and nodes.
9543  *
9544  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9545  *          caller is to delete this field using decrRef() as it is no more needed. 
9546  *  \throw If the MED file is not readable.
9547  *  \throw If there is no mesh in the MED file.
9548  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9549  *  \throw If no field values of the required parameters are available.
9550  */
9551 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9552 {
9553   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9554   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9555   if(!myF1TSC)
9556     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9557   MCAuto<DataArray> arrOut;
9558   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9559   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9560   return ret.retn();
9561 }
9562
9563 /*!
9564  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9565  * the top level cells of the first mesh in MED file.
9566  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9567  *  \param [in] type - a spatial discretization of interest.
9568  *  \param [in] iteration - the iteration number of a required time step.
9569  *  \param [in] order - the iteration order number of required time step.
9570  *  \param [in] renumPol - specifies how to permute values of the result field according to
9571  *          the optional numbers of cells and nodes, if any. The valid values are
9572  *          - 0 - do not permute.
9573  *          - 1 - permute cells.
9574  *          - 2 - permute nodes.
9575  *          - 3 - permute cells and nodes.
9576  *
9577  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9578  *          caller is to delete this field using decrRef() as it is no more needed. 
9579  *  \throw If the MED file is not readable.
9580  *  \throw If there is no mesh in the MED file.
9581  *  \throw If no field values of the required parameters are available.
9582  */
9583 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9584 {
9585   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9586   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9587   if(!myF1TSC)
9588     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9589   MCAuto<DataArray> arrOut;
9590   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9591   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9592   return ret.retn();
9593 }
9594
9595 /*!
9596  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9597  * method should be called (getFieldOnMeshAtLevel for example).
9598  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9599  *
9600  * \param [in] iteration - the iteration number of a required time step.
9601  * \param [in] order - the iteration order number of required time step.
9602  * \param [in] mesh - the mesh the field is lying on
9603  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9604  *          caller is to delete this field using decrRef() as it is no more needed. 
9605  */
9606 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9607 {
9608   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9609   MCAuto<DataArray> arrOut;
9610   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9611   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9612   return ret.retn();
9613 }
9614
9615 /*!
9616  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9617  * a given support.
9618  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9619  *  \param [in] type - a spatial discretization of interest.
9620  *  \param [in] iteration - the iteration number of a required time step.
9621  *  \param [in] order - the iteration order number of required time step.
9622  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9623  *  \param [in] mesh - the supporting mesh.
9624  *  \param [in] renumPol - specifies how to permute values of the result field according to
9625  *          the optional numbers of cells and nodes, if any. The valid values are
9626  *          - 0 - do not permute.
9627  *          - 1 - permute cells.
9628  *          - 2 - permute nodes.
9629  *          - 3 - permute cells and nodes.
9630  *
9631  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9632  *          caller is to delete this field using decrRef() as it is no more needed. 
9633  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9634  *  \throw If no field of \a this is lying on \a mesh.
9635  *  \throw If no field values of the required parameters are available.
9636  */
9637 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9638 {
9639   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9640   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9641   if(!myF1TSC)
9642     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9643   MCAuto<DataArray> arrOut;
9644   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9645   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9646   return ret.retn();
9647 }
9648
9649 /*!
9650  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9651  * given support. 
9652  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9653  *  \param [in] type - a spatial discretization of the new field.
9654  *  \param [in] iteration - the iteration number of a required time step.
9655  *  \param [in] order - the iteration order number of required time step.
9656  *  \param [in] mesh - the supporting mesh.
9657  *  \param [in] renumPol - specifies how to permute values of the result field according to
9658  *          the optional numbers of cells and nodes, if any. The valid values are
9659  *          - 0 - do not permute.
9660  *          - 1 - permute cells.
9661  *          - 2 - permute nodes.
9662  *          - 3 - permute cells and nodes.
9663  *
9664  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9665  *          caller is to delete this field using decrRef() as it is no more needed. 
9666  *  \throw If no field of \a this is lying on \a mesh.
9667  *  \throw If no field values of the required parameters are available.
9668  */
9669 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9670 {
9671   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9672   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9673   if(!myF1TSC)
9674     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9675   MCAuto<DataArray> arrOut;
9676   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9677   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9678   return ret.retn();
9679 }
9680
9681 /*!
9682  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9683  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9684  * This method is useful for MED2 file format when field on different mesh was autorized.
9685  */
9686 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9687 {
9688   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9689   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9690   if(!myF1TSC)
9691     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9692   MCAuto<DataArray> arrOut;
9693   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9694   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9695   return ret.retn();
9696 }
9697
9698 /*!
9699  * Returns values and a profile of the field of a given type, of a given time step,
9700  * lying on a given support.
9701  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9702  *  \param [in] type - a spatial discretization of the field.
9703  *  \param [in] iteration - the iteration number of a required time step.
9704  *  \param [in] order - the iteration order number of required time step.
9705  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9706  *  \param [in] mesh - the supporting mesh.
9707  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9708  *          field of interest lies on. If the field lies on all entities of the given
9709  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9710  *          using decrRef() as it is no more needed.  
9711  *  \param [in] glob - the global data storing profiles and localization.
9712  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9713  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9714  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9715  *  \throw If no field of \a this is lying on \a mesh.
9716  *  \throw If no field values of the required parameters are available.
9717  */
9718 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9719 {
9720   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9721   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9722   if(!myF1TSC)
9723     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9724   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9725   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9726 }
9727
9728 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9729 {
9730   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9731   if(!pt)
9732     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9733   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9734   if(!ret)
9735     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 !");
9736   return ret;
9737 }
9738
9739 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9740 {
9741   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9742   if(!pt)
9743     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9744   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9745   if(!ret)
9746     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 !");
9747   return ret;
9748 }
9749
9750 /*!
9751  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9752  * the given field is checked if its elements are sorted suitable for writing to MED file
9753  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9754  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9755  *  \param [in] field - the field to add to \a this.
9756  *  \throw If the name of \a field is empty.
9757  *  \throw If the data array of \a field is not set.
9758  *  \throw If existing time steps have different name or number of components than \a field.
9759  *  \throw If the underlying mesh of \a field has no name.
9760  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9761  */
9762 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9763 {
9764   const DataArrayDouble *arr=0;
9765   if(field)
9766     arr=field->getArray();
9767   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9768 }
9769
9770 /*!
9771  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9772  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9773  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9774  * and \a profile.
9775  *
9776  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9777  * A new profile is added only if no equal profile is missing.
9778  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9779  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9780  *  \param [in] mesh - the supporting mesh of \a field.
9781  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9782  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9783  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9784  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9785  *  \throw If the data array of \a field is not set.
9786  *  \throw If the data array of \a this is already allocated but has different number of
9787  *         components than \a field.
9788  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9789  *  \sa setFieldNoProfileSBT()
9790  */
9791 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9792 {
9793   const DataArrayDouble *arr=0;
9794   if(field)
9795     arr=field->getArray();
9796   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9797 }
9798
9799 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9800 {
9801   _content=new MEDFileFieldMultiTSWithoutSDA;
9802 }
9803
9804 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9805 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9806 {
9807 }
9808 catch(INTERP_KERNEL::Exception& e)
9809 { throw e; }
9810
9811 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9812 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9813 {
9814 }
9815 catch(INTERP_KERNEL::Exception& e)
9816 { throw e; }
9817
9818 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9819 {
9820 }
9821
9822 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
9823 {
9824   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9825 }
9826
9827 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9828 {
9829   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9830 }
9831
9832 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9833 {
9834   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9835 }
9836
9837 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9838 {
9839   return MEDFileFieldMultiTS::New();
9840 }
9841
9842 //= MEDFileAnyTypeFieldMultiTSIterator
9843
9844 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9845 {
9846   if(fmts)
9847     {
9848       fmts->incrRef();
9849       _nb_iter=fmts->getNumberOfTS();
9850     }
9851 }
9852
9853 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9854 {
9855 }
9856
9857 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9858 {
9859   if(_iter_id<_nb_iter)
9860     {
9861       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9862       if(fmts)
9863         return fmts->getTimeStepAtPos(_iter_id++);
9864       else
9865         return 0;
9866     }
9867   else
9868     return 0;
9869 }
9870
9871 //= MEDFileIntFieldMultiTS
9872
9873 /*!
9874  * Returns a new empty instance of MEDFileFieldMultiTS.
9875  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9876  *          is to delete this field using decrRef() as it is no more needed.
9877  */
9878 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9879 {
9880   return new MEDFileIntFieldMultiTS;
9881 }
9882
9883 /*!
9884  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9885  * that has been read from a specified MED file.
9886  *  \param [in] fileName - the name of the MED file to read.
9887  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9888  *          is to delete this field using decrRef() as it is no more needed.
9889  *  \throw If reading the file fails.
9890  */
9891 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9892 {
9893   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9894   return New(fid,loadAll);
9895 }
9896
9897 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9898 {
9899   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9900   ret->contentNotNull();//to check that content type matches with \a this type.
9901   return ret.retn();
9902 }
9903
9904 /*!
9905  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9906  * that has been read from a specified MED file.
9907  *  \param [in] fileName - the name of the MED file to read.
9908  *  \param [in] fieldName - the name of the field to read.
9909  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9910  *          is to delete this field using decrRef() as it is no more needed.
9911  *  \throw If reading the file fails.
9912  *  \throw If there is no field named \a fieldName in the file.
9913  */
9914 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9915 {
9916   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9917   return New(fid,fieldName,loadAll);
9918 }
9919
9920 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9921 {
9922   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9923   ret->contentNotNull();//to check that content type matches with \a this type.
9924   return ret.retn();
9925 }
9926
9927 /*!
9928  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9929  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9930  *
9931  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9932  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9933  * \warning this is a shallow copy constructor
9934  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9935  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9936  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9937  *          is to delete this field using decrRef() as it is no more needed.
9938  */
9939 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9940 {
9941   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9942 }
9943
9944 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9945 {
9946   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9947   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9948   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9949   ret->contentNotNull();//to check that content type matches with \a this type.
9950   return ret.retn();
9951 }
9952
9953 /*!
9954  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9955  * following the given input policy.
9956  *
9957  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9958  *                            By default (true) the globals are deeply copied.
9959  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9960  */
9961 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9962 {
9963   MCAuto<MEDFileFieldMultiTS> ret;
9964   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9965   if(content)
9966     {
9967       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9968       if(!contc)
9969         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9970       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9971       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9972     }
9973   else
9974     ret=MEDFileFieldMultiTS::New();
9975   if(isDeepCpyGlobs)
9976     ret->deepCpyGlobs(*this);
9977   else
9978     ret->shallowCpyGlobs(*this);
9979   return ret.retn();
9980 }
9981
9982 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9983 {
9984   return new MEDFileIntFieldMultiTS(*this);
9985 }
9986
9987 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9988 {
9989   if(!f1ts)
9990     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9991   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9992   if(!f1tsC)
9993     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9994 }
9995
9996 /*!
9997  * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9998  * method should be called (getFieldOnMeshAtLevel for example).
9999  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10000  *
10001  * \param [in] iteration - the iteration number of a required time step.
10002  * \param [in] order - the iteration order number of required time step.
10003  * \param [in] mesh - the mesh the field is lying on
10004  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10005  *          caller is to delete this field using decrRef() as it is no more needed. 
10006  */
10007 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10008 {
10009   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10010   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10011   if(!myF1TSC)
10012     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10013   MCAuto<DataArray> arrOut;
10014   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10015   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10016   return ret2.retn();
10017 }
10018
10019 /*!
10020  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10021  * mesh entities of a given dimension of the first mesh in MED file.
10022  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10023  *  \param [in] type - a spatial discretization of interest.
10024  *  \param [in] iteration - the iteration number of a required time step.
10025  *  \param [in] order - the iteration order number of required time step.
10026  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10027  *  \param [in] renumPol - specifies how to permute values of the result field according to
10028  *          the optional numbers of cells and nodes, if any. The valid values are
10029  *          - 0 - do not permute.
10030  *          - 1 - permute cells.
10031  *          - 2 - permute nodes.
10032  *          - 3 - permute cells and nodes.
10033  *
10034  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10035  *          caller is to delete this field using decrRef() as it is no more needed. 
10036  *  \throw If the MED file is not readable.
10037  *  \throw If there is no mesh in the MED file.
10038  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10039  *  \throw If no field values of the required parameters are available.
10040  */
10041 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10042 {
10043   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10044   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10045   if(!myF1TSC)
10046     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10047   MCAuto<DataArray> arr;
10048   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10049   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10050   return ret2.retn();
10051 }
10052
10053 /*!
10054  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10055  * the top level cells of the first mesh in MED file.
10056  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10057  *  \param [in] type - a spatial discretization of interest.
10058  *  \param [in] iteration - the iteration number of a required time step.
10059  *  \param [in] order - the iteration order number of required time step.
10060  *  \param [in] renumPol - specifies how to permute values of the result field according to
10061  *          the optional numbers of cells and nodes, if any. The valid values are
10062  *          - 0 - do not permute.
10063  *          - 1 - permute cells.
10064  *          - 2 - permute nodes.
10065  *          - 3 - permute cells and nodes.
10066  *
10067  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10068  *          caller is to delete this field using decrRef() as it is no more needed. 
10069  *  \throw If the MED file is not readable.
10070  *  \throw If there is no mesh in the MED file.
10071  *  \throw If no field values of the required parameters are available.
10072  */
10073 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10074 {
10075   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10076   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10077   if(!myF1TSC)
10078     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10079   MCAuto<DataArray> arr;
10080   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10081   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10082   return ret2.retn();
10083 }
10084
10085 /*!
10086  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10087  * a given support.
10088  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10089  *  \param [in] type - a spatial discretization of interest.
10090  *  \param [in] iteration - the iteration number of a required time step.
10091  *  \param [in] order - the iteration order number of required time step.
10092  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10093  *  \param [in] mesh - the supporting mesh.
10094  *  \param [in] renumPol - specifies how to permute values of the result field according to
10095  *          the optional numbers of cells and nodes, if any. The valid values are
10096  *          - 0 - do not permute.
10097  *          - 1 - permute cells.
10098  *          - 2 - permute nodes.
10099  *          - 3 - permute cells and nodes.
10100  *
10101  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10102  *          caller is to delete this field using decrRef() as it is no more needed. 
10103  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10104  *  \throw If no field of \a this is lying on \a mesh.
10105  *  \throw If no field values of the required parameters are available.
10106  */
10107 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10108 {
10109   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10110   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10111   if(!myF1TSC)
10112     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10113   MCAuto<DataArray> arr;
10114   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10115   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10116   return ret2.retn();
10117 }
10118
10119 /*!
10120  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10121  * given support. 
10122  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10123  *  \param [in] type - a spatial discretization of the new field.
10124  *  \param [in] iteration - the iteration number of a required time step.
10125  *  \param [in] order - the iteration order number of required time step.
10126  *  \param [in] mesh - the supporting mesh.
10127  *  \param [out] arrOut - the DataArrayInt containing values of field.
10128  *  \param [in] renumPol - specifies how to permute values of the result field according to
10129  *          the optional numbers of cells and nodes, if any. The valid values are
10130  *          - 0 - do not permute.
10131  *          - 1 - permute cells.
10132  *          - 2 - permute nodes.
10133  *          - 3 - permute cells and nodes.
10134  *
10135  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10136  *          caller is to delete this field using decrRef() as it is no more needed. 
10137  *  \throw If no field of \a this is lying on \a mesh.
10138  *  \throw If no field values of the required parameters are available.
10139  */
10140 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10141 {
10142   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10143   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10144   if(!myF1TSC)
10145     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10146   MCAuto<DataArray> arr;
10147   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10148   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10149   return ret2.retn();
10150 }
10151
10152 /*!
10153  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10154  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10155  * This method is useful for MED2 file format when field on different mesh was autorized.
10156  */
10157 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10158 {
10159   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10160   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10161   if(!myF1TSC)
10162     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10163   MCAuto<DataArray> arr;
10164   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10165   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10166   return ret2.retn();
10167 }
10168
10169 /*!
10170  * Returns values and a profile of the field of a given type, of a given time step,
10171  * lying on a given support.
10172  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10173  *  \param [in] type - a spatial discretization of the field.
10174  *  \param [in] iteration - the iteration number of a required time step.
10175  *  \param [in] order - the iteration order number of required time step.
10176  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10177  *  \param [in] mesh - the supporting mesh.
10178  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10179  *          field of interest lies on. If the field lies on all entities of the given
10180  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10181  *          using decrRef() as it is no more needed.  
10182  *  \param [in] glob - the global data storing profiles and localization.
10183  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10184  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10185  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10186  *  \throw If no field of \a this is lying on \a mesh.
10187  *  \throw If no field values of the required parameters are available.
10188  */
10189 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10190 {
10191   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10192   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10193   if(!myF1TSC)
10194     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10195   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10196   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10197 }
10198
10199 /*!
10200  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10201  *  \param [in] pos - a time step id.
10202  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10203  *          delete this field using decrRef() as it is no more needed.
10204  *  \throw If \a pos is not a valid time step id.
10205  */
10206 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10207 {
10208   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10209   if(!item)
10210     {
10211       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10212       throw INTERP_KERNEL::Exception(oss.str());
10213     }
10214   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10215   if(itemC)
10216     {
10217       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10218       ret->shallowCpyGlobs(*this);
10219       return ret.retn();
10220     }
10221   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10222   throw INTERP_KERNEL::Exception(oss.str());
10223 }
10224
10225 /*!
10226  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10227  * the given field is checked if its elements are sorted suitable for writing to MED file
10228  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10229  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10230  *  \param [in] field - the field to add to \a this.
10231  *  \throw If the name of \a field is empty.
10232  *  \throw If the data array of \a field is not set.
10233  *  \throw If existing time steps have different name or number of components than \a field.
10234  *  \throw If the underlying mesh of \a field has no name.
10235  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10236  */
10237 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10238 {
10239   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10240   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10241 }
10242
10243 /*!
10244  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10245  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10246  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10247  * and \a profile.
10248  *
10249  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10250  * A new profile is added only if no equal profile is missing.
10251  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10252  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10253  *  \param [in] arrOfVals - the values of the field \a field used.
10254  *  \param [in] mesh - the supporting mesh of \a field.
10255  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10256  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10257  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10258  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10259  *  \throw If the data array of \a field is not set.
10260  *  \throw If the data array of \a this is already allocated but has different number of
10261  *         components than \a field.
10262  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10263  *  \sa setFieldNoProfileSBT()
10264  */
10265 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10266 {
10267   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10268   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10269 }
10270
10271 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10272 {
10273   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10274   if(!pt)
10275     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10276   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10277   if(!ret)
10278     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 !");
10279   return ret;
10280 }
10281
10282 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10283 {
10284   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10285   if(!pt)
10286     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10287   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10288   if(!ret)
10289     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 !");
10290   return ret;
10291 }
10292
10293 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10294 {
10295   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10296 }
10297
10298 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10299 {
10300 }
10301
10302 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10303 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10304 {
10305 }
10306 catch(INTERP_KERNEL::Exception& e)
10307 { throw e; }
10308
10309 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10310 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10311 {
10312 }
10313 catch(INTERP_KERNEL::Exception& e)
10314 { throw e; }
10315
10316 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10317 {
10318   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10319 }
10320
10321 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10322 {
10323   return MEDFileIntFieldMultiTS::New();
10324 }
10325
10326 //= MEDFileFields
10327
10328 MEDFileFields *MEDFileFields::New()
10329 {
10330   return new MEDFileFields;
10331 }
10332
10333 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10334 {
10335   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10336   return New(fid,loadAll);
10337 }
10338
10339 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10340 {
10341   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10342   return NewWithDynGT(fid,se,loadAll);
10343 }
10344
10345 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10346 {
10347   if(!se)
10348     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10349   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10350   return new MEDFileFields(fid,loadAll,0,entities);
10351 }
10352
10353 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10354 {
10355   return new MEDFileFields(fid,loadAll,0,0);
10356 }
10357
10358 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10359 {
10360   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10361   return new MEDFileFields(fid,loadAll,ms,0);
10362 }
10363
10364 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10365 {
10366   MEDFileUtilities::CheckFileForRead(fileName);
10367   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10368   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10369   return new MEDFileFields(fid,loadAll,0,ent);
10370 }
10371
10372 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10373 {
10374   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10375   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10376   return ret;
10377 }
10378
10379 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10380 {
10381   std::vector<const BigMemoryObject *> ret;
10382   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10383     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10384   return ret;
10385 }
10386
10387 MEDFileFields *MEDFileFields::deepCopy() const
10388 {
10389   MCAuto<MEDFileFields> ret(shallowCpy());
10390   std::size_t i(0);
10391   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10392     {
10393       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10394         ret->_fields[i]=(*it)->deepCopy();
10395     }
10396   ret->deepCpyGlobs(*this);
10397   return ret.retn();
10398 }
10399
10400 MEDFileFields *MEDFileFields::shallowCpy() const
10401 {
10402   return new MEDFileFields(*this);
10403 }
10404
10405 /*!
10406  * 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
10407  * 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.
10408  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10409  *
10410  * \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.
10411  * \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.
10412  * 
10413  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10414  */
10415 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10416 {
10417   std::set< std::pair<int,int> > s;
10418   bool firstShot=true;
10419   areThereSomeForgottenTS=false;
10420   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10421     {
10422       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10423         continue;
10424       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10425       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10426       if(firstShot)
10427         { s=s1; firstShot=false; }
10428       else
10429         {
10430           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10431           if(s!=s2)
10432             areThereSomeForgottenTS=true;
10433           s=s2;
10434         }
10435     }
10436   std::vector< std::pair<int,int> > ret;
10437   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10438   return ret;
10439 }
10440
10441 int MEDFileFields::getNumberOfFields() const
10442 {
10443   return _fields.size();
10444 }
10445
10446 std::vector<std::string> MEDFileFields::getFieldsNames() const
10447 {
10448   std::vector<std::string> ret(_fields.size());
10449   int i(0);
10450   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10451     {
10452       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10453       if(f)
10454         {
10455           ret[i]=f->getName();
10456         }
10457       else
10458         {
10459           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10460           throw INTERP_KERNEL::Exception(oss.str());
10461         }
10462     }
10463   return ret;
10464 }
10465
10466 std::vector<std::string> MEDFileFields::getMeshesNames() const
10467 {
10468   std::vector<std::string> ret;
10469   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10470     {
10471       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10472       if(cur)
10473         ret.push_back(cur->getMeshName());
10474     }
10475   return ret;
10476 }
10477
10478 std::string MEDFileFields::simpleRepr() const
10479 {
10480   std::ostringstream oss;
10481   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10482   simpleRepr(0,oss);
10483   return oss.str();
10484 }
10485
10486 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10487 {
10488   int nbOfFields(getNumberOfFields());
10489   std::string startLine(bkOffset,' ');
10490   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10491   int i=0;
10492   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10493     {
10494       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10495       if(cur)
10496         {
10497           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10498         }
10499       else
10500         {
10501           oss << startLine << "  - not defined !" << std::endl;
10502         }
10503     }
10504   i=0;
10505   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10506     {
10507       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10508       std::string chapter(17,'0'+i);
10509       oss << startLine << chapter << std::endl;
10510       if(cur)
10511         {
10512           cur->simpleRepr(bkOffset+2,oss,i);
10513         }
10514       else
10515         {
10516           oss << startLine << "  - not defined !" << std::endl;
10517         }
10518       oss << startLine << chapter << std::endl;
10519     }
10520   simpleReprGlobs(oss);
10521 }
10522
10523 MEDFileFields::MEDFileFields()
10524 {
10525 }
10526
10527 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10528 try:MEDFileFieldGlobsReal(fid)
10529 {
10530   int nbFields(MEDnField(fid));
10531   _fields.resize(nbFields);
10532   med_field_type typcha;
10533   for(int i=0;i<nbFields;i++)
10534     {
10535       std::vector<std::string> infos;
10536       std::string fieldName,dtunit;
10537       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10538       switch(typcha)
10539       {
10540         case MED_FLOAT64:
10541           {
10542             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10543             break;
10544           }
10545         case MED_INT32:
10546           {
10547             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10548             break;
10549           }
10550         default:
10551           {
10552             std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10553             throw INTERP_KERNEL::Exception(oss.str());
10554           }
10555       }
10556     }
10557   loadAllGlobals(fid);
10558 }
10559 catch(INTERP_KERNEL::Exception& e)
10560 {
10561     throw e;
10562 }
10563
10564 void MEDFileFields::writeLL(med_idt fid) const
10565 {
10566   int i=0;
10567   writeGlobals(fid,*this);
10568   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10569     {
10570       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10571       if(!elt)
10572         {
10573           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10574           throw INTERP_KERNEL::Exception(oss.str());
10575         }
10576       elt->writeLL(fid,*this);
10577     }
10578 }
10579
10580 /*!
10581  * This method alloc the arrays and load potentially huge arrays contained in this field.
10582  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10583  * This method can be also called to refresh or reinit values from a file.
10584  * 
10585  * \throw If the fileName is not set or points to a non readable MED file.
10586  */
10587 void MEDFileFields::loadArrays()
10588 {
10589   if(getFileName().empty())
10590     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10591   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10592   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10593     {
10594       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10595       if(elt)
10596         elt->loadBigArraysRecursively(fid,*elt);
10597     }
10598 }
10599
10600 /*!
10601  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10602  * But once data loaded once, this method does nothing.
10603  * 
10604  * \throw If the fileName is not set or points to a non readable MED file.
10605  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10606  */
10607 void MEDFileFields::loadArraysIfNecessary()
10608 {
10609   if(!getFileName().empty())
10610     {
10611       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10612       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10613         {
10614           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10615           if(elt)
10616             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10617         }
10618     }
10619 }
10620
10621 /*!
10622  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10623  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10624  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10625  * 
10626  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10627  */
10628 void MEDFileFields::unloadArrays()
10629 {
10630   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10631     {
10632       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10633       if(elt)
10634         elt->unloadArrays();
10635     }
10636 }
10637
10638 /*!
10639  * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
10640  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10641  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10642  * 
10643  * \sa MEDFileFields::loadArraysIfNecessary
10644  */
10645 void MEDFileFields::unloadArraysWithoutDataLoss()
10646 {
10647   if(!getFileName().empty())
10648     unloadArrays();
10649 }
10650
10651 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10652 {
10653   std::vector<std::string> ret;
10654   std::set<std::string> ret2;
10655   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10656     {
10657       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10658       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10659         if(ret2.find(*it2)==ret2.end())
10660           {
10661             ret.push_back(*it2);
10662             ret2.insert(*it2);
10663           }
10664     }
10665   return ret;
10666 }
10667
10668 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10669 {
10670   std::vector<std::string> ret;
10671   std::set<std::string> ret2;
10672   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10673     {
10674       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10675       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10676         if(ret2.find(*it2)==ret2.end())
10677           {
10678             ret.push_back(*it2);
10679             ret2.insert(*it2);
10680           }
10681     }
10682   return ret;
10683 }
10684
10685 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10686 {
10687   std::vector<std::string> ret;
10688   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10689     {
10690       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10691       ret.insert(ret.end(),tmp.begin(),tmp.end());
10692     }
10693   return ret;
10694 }
10695
10696 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10697 {
10698   std::vector<std::string> ret;
10699   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10700     {
10701       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10702       ret.insert(ret.end(),tmp.begin(),tmp.end());
10703     }
10704   return ret;
10705 }
10706
10707 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10708 {
10709   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10710     (*it)->changePflsRefsNamesGen2(mapOfModif);
10711 }
10712
10713 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10714 {
10715   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10716     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10717 }
10718
10719 void MEDFileFields::resize(int newSize)
10720 {
10721   _fields.resize(newSize);
10722 }
10723
10724 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10725 {
10726   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10727     pushField(*it);
10728 }
10729
10730 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10731 {
10732   if(!field)
10733     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10734   _fields.push_back(field->getContent());
10735   appendGlobs(*field,1e-12);
10736 }
10737
10738 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10739 {
10740   if(!field)
10741     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10742   if(i>=(int)_fields.size())
10743     _fields.resize(i+1);
10744   _fields[i]=field->getContent();
10745   appendGlobs(*field,1e-12);
10746 }
10747
10748 void MEDFileFields::destroyFieldAtPos(int i)
10749 {
10750   destroyFieldsAtPos(&i,&i+1);
10751 }
10752
10753 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10754 {
10755   std::vector<bool> b(_fields.size(),true);
10756   for(const int *i=startIds;i!=endIds;i++)
10757     {
10758       if(*i<0 || *i>=(int)_fields.size())
10759         {
10760           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10761           throw INTERP_KERNEL::Exception(oss.str());
10762         }
10763       b[*i]=false;
10764     }
10765   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10766   std::size_t j=0;
10767   for(std::size_t i=0;i<_fields.size();i++)
10768     if(b[i])
10769       fields[j++]=_fields[i];
10770   _fields=fields;
10771 }
10772
10773 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10774 {
10775   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10776   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10777   std::vector<bool> b(_fields.size(),true);
10778   int k=bg;
10779   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10780     {
10781       if(k<0 || k>=(int)_fields.size())
10782         {
10783           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10784           throw INTERP_KERNEL::Exception(oss.str());
10785         }
10786       b[k]=false;
10787     }
10788   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10789   std::size_t j(0);
10790   for(std::size_t i=0;i<_fields.size();i++)
10791     if(b[i])
10792       fields[j++]=_fields[i];
10793   _fields=fields;
10794 }
10795
10796 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10797 {
10798   bool ret(false);
10799   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10800     {
10801       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10802       if(cur)
10803         ret=cur->changeMeshNames(modifTab) || ret;
10804     }
10805   return ret;
10806 }
10807
10808 /*!
10809  * \param [in] meshName the name of the mesh that will be renumbered.
10810  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10811  *             This code corresponds to the distribution of types in the corresponding mesh.
10812  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10813  * \param [in] renumO2N the old to new renumber array.
10814  * \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 
10815  *         field in \a this.
10816  */
10817 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10818 {
10819   bool ret(false);
10820   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10821     {
10822       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10823       if(fmts)
10824         {
10825           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10826         }
10827     }
10828   return ret;
10829 }
10830
10831 /*!
10832  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10833  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10834  *
10835  * \return A new object that the caller is responsible to deallocate.
10836  */
10837 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10838 {
10839   if(!mm)
10840     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10841   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10842   int nbFields(getNumberOfFields());
10843   for(int i=0;i<nbFields;i++)
10844     {
10845       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10846       if(!fmts)
10847         {
10848           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10849           throw INTERP_KERNEL::Exception(oss.str());
10850         }
10851       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10852       fsOut->pushField(fmtsOut);
10853     }
10854   return fsOut.retn();
10855 }
10856
10857 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10858 {
10859   if(i<0 || i>=(int)_fields.size())
10860     {
10861       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10862       throw INTERP_KERNEL::Exception(oss.str());
10863     }
10864   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10865   if(!fmts)
10866     return 0;
10867   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10868   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10869   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10870   if(fmtsC)
10871     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10872   else if(fmtsC2)
10873     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10874   else
10875     {
10876       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10877       throw INTERP_KERNEL::Exception(oss.str());
10878     }
10879   ret->shallowCpyGlobs(*this);
10880   return ret.retn();
10881 }
10882
10883 /*!
10884  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10885  * This method is accessible in python using __getitem__ with a list in input.
10886  * \return a new object that the caller should deal with.
10887  */
10888 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10889 {
10890   MCAuto<MEDFileFields> ret=shallowCpy();
10891   std::size_t sz=std::distance(startIds,endIds);
10892   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10893   int j=0;
10894   for(const int *i=startIds;i!=endIds;i++,j++)
10895     {
10896       if(*i<0 || *i>=(int)_fields.size())
10897         {
10898           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10899           throw INTERP_KERNEL::Exception(oss.str());
10900         }
10901       fields[j]=_fields[*i];
10902     }
10903   ret->_fields=fields;
10904   return ret.retn();
10905 }
10906
10907 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10908 {
10909   return getFieldAtPos(getPosFromFieldName(fieldName));
10910 }
10911
10912 /*!
10913  * This method removes, if any, fields in \a this having no time steps.
10914  * If there is one or more than one such field in \a this true is returned and those fields will not be referenced anymore in \a this.
10915  * 
10916  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10917  */
10918 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10919 {
10920   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10921   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10922     {
10923       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10924       if(elt)
10925         {
10926           if(elt->getNumberOfTS()>0)
10927             newFields.push_back(*it);
10928         }
10929     }
10930   if(_fields.size()==newFields.size())
10931     return false;
10932   _fields=newFields;
10933   return true;
10934 }
10935
10936 /*!
10937  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10938  * This method can be seen as a filter applied on \a this, that returns an object containing
10939  * 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
10940  * shallow copied from \a this.
10941  * 
10942  * \param [in] meshName - the name of the mesh on w
10943  * \return a new object that the caller should deal with.
10944  */
10945 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10946 {
10947   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10948   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10949     {
10950       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10951       if(!cur)
10952         continue;
10953       if(cur->getMeshName()==meshName)
10954         {
10955           cur->incrRef();
10956           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10957           ret->_fields.push_back(cur2);
10958         }
10959     }
10960   ret->shallowCpyOnlyUsedGlobs(*this);
10961   return ret.retn();
10962 }
10963
10964 /*!
10965  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10966  * Input time steps are specified using a pair of integer (iteration, order).
10967  * 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,
10968  * but for each multitimestep only the time steps in \a timeSteps are kept.
10969  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10970  * 
10971  * The returned object points to shallow copy of elements in \a this.
10972  * 
10973  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10974  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10975  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10976  */
10977 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10978 {
10979   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10980   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10981     {
10982       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10983       if(!cur)
10984         continue;
10985       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10986       ret->_fields.push_back(elt);
10987     }
10988   ret->shallowCpyOnlyUsedGlobs(*this);
10989   return ret.retn();
10990 }
10991
10992 /*!
10993  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10994  */
10995 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10996 {
10997   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10998   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10999     {
11000       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11001       if(!cur)
11002         continue;
11003       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11004       if(elt->getNumberOfTS()!=0)
11005         ret->_fields.push_back(elt);
11006     }
11007   ret->shallowCpyOnlyUsedGlobs(*this);
11008   return ret.retn();
11009 }
11010
11011 bool MEDFileFields::presenceOfStructureElements() const
11012 {
11013   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11014     if((*it).isNotNull())
11015       if((*it)->presenceOfStructureElements())
11016         return true;
11017   return false;
11018 }
11019
11020 void MEDFileFields::killStructureElements()
11021 {
11022   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11023   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11024     if((*it).isNotNull())
11025       {
11026         if((*it)->presenceOfStructureElements())
11027           {
11028             if(!(*it)->onlyStructureElements())
11029               {
11030                 (*it)->killStructureElements();
11031                 ret.push_back(*it);
11032               }
11033           }
11034       }
11035     else
11036       {
11037         ret.push_back(*it);
11038       }
11039   _fields=ret;
11040 }
11041
11042 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11043 {
11044   throw INTERP_KERNEL::Exception("partOfThisOnStructureElements : not implemented yet !");
11045 }
11046
11047 MEDFileFieldsIterator *MEDFileFields::iterator()
11048 {
11049   return new MEDFileFieldsIterator(this);
11050 }
11051
11052 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11053 {
11054   std::string tmp(fieldName);
11055   std::vector<std::string> poss;
11056   for(std::size_t i=0;i<_fields.size();i++)
11057     {
11058       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11059       if(f)
11060         {
11061           std::string fname(f->getName());
11062           if(tmp==fname)
11063             return i;
11064           else
11065             poss.push_back(fname);
11066         }
11067     }
11068   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11069   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11070   oss << " !";
11071   throw INTERP_KERNEL::Exception(oss.str());
11072 }
11073
11074 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11075 {
11076   if(fs)
11077     {
11078       fs->incrRef();
11079       _nb_iter=fs->getNumberOfFields();
11080     }
11081 }
11082
11083 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
11084 {
11085 }
11086
11087 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11088 {
11089   if(_iter_id<_nb_iter)
11090     {
11091       MEDFileFields *fs(_fs);
11092       if(fs)
11093         return fs->getFieldAtPos(_iter_id++);
11094       else
11095         return 0;
11096     }
11097   else
11098     return 0;
11099 }